iio: Aspeed ADC - Handle return value of clk_prepare_enable
authorArvind Yadav <arvind.yadav.cs@gmail.com>
Mon, 29 May 2017 07:42:12 +0000 (13:12 +0530)
committerJonathan Cameron <jic23@kernel.org>
Sun, 11 Jun 2017 14:08:20 +0000 (15:08 +0100)
clk_prepare_enable() can fail here and we must check its return value.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Reviewed-by: Rick Altherr <raltherr@google.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
drivers/iio/adc/aspeed_adc.c

index 62670cbfa2bbeb19961bd01ff5f82bf97be34513..e0ea411a0b2df9563085c70552086946843ba2ca 100644 (file)
@@ -212,7 +212,10 @@ static int aspeed_adc_probe(struct platform_device *pdev)
        }
 
        /* Start all channels in normal mode. */
-       clk_prepare_enable(data->clk_scaler->clk);
+       ret = clk_prepare_enable(data->clk_scaler->clk);
+       if (ret)
+               goto clk_enable_error;
+
        adc_engine_control_reg_val = GENMASK(31, 16) |
                ASPEED_OPERATION_MODE_NORMAL | ASPEED_ENGINE_ENABLE;
        writel(adc_engine_control_reg_val,
@@ -236,6 +239,7 @@ iio_register_error:
        writel(ASPEED_OPERATION_MODE_POWER_DOWN,
                data->base + ASPEED_REG_ENGINE_CONTROL);
        clk_disable_unprepare(data->clk_scaler->clk);
+clk_enable_error:
        clk_hw_unregister_divider(data->clk_scaler);
 
 scaler_error: