iio: adc: rockchip_saradc: Make use of the helper function dev_err_probe()
authorCai Huoqing <caihuoqing@baidu.com>
Fri, 8 Oct 2021 09:28:56 +0000 (17:28 +0800)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Wed, 20 Oct 2021 13:43:53 +0000 (14:43 +0100)
When possible use dev_err_probe help to properly deal with the
PROBE_DEFER error, the benefit is that DEFER issue will be logged
in the devices_deferred debugfs file.
Using dev_err_probe() can reduce code size, and the error value
gets printed.

Signed-off-by: Cai Huoqing <caihuoqing@baidu.com>
Link: https://lore.kernel.org/r/20211008092858.495-8-caihuoqing@baidu.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/adc/rockchip_saradc.c

index a56a0d7337ca025bcbee5e89a4e73115b1e58742..14b8df4ca9c879852dd2a3b392c9982d41a2be59 100644 (file)
@@ -360,7 +360,8 @@ static int rockchip_saradc_probe(struct platform_device *pdev)
        if (IS_ERR(info->reset)) {
                ret = PTR_ERR(info->reset);
                if (ret != -ENOENT)
-                       return ret;
+                       return dev_err_probe(&pdev->dev, ret,
+                                            "failed to get saradc-apb\n");
 
                dev_dbg(&pdev->dev, "no reset control found\n");
                info->reset = NULL;
@@ -370,7 +371,7 @@ static int rockchip_saradc_probe(struct platform_device *pdev)
 
        irq = platform_get_irq(pdev, 0);
        if (irq < 0)
-               return irq;
+               return dev_err_probe(&pdev->dev, irq, "failed to get irq\n");
 
        ret = devm_request_irq(&pdev->dev, irq, rockchip_saradc_isr,
                               0, dev_name(&pdev->dev), info);
@@ -380,23 +381,19 @@ static int rockchip_saradc_probe(struct platform_device *pdev)
        }
 
        info->pclk = devm_clk_get(&pdev->dev, "apb_pclk");
-       if (IS_ERR(info->pclk)) {
-               dev_err(&pdev->dev, "failed to get pclk\n");
-               return PTR_ERR(info->pclk);
-       }
+       if (IS_ERR(info->pclk))
+               return dev_err_probe(&pdev->dev, PTR_ERR(info->pclk),
+                                    "failed to get pclk\n");
 
        info->clk = devm_clk_get(&pdev->dev, "saradc");
-       if (IS_ERR(info->clk)) {
-               dev_err(&pdev->dev, "failed to get adc clock\n");
-               return PTR_ERR(info->clk);
-       }
+       if (IS_ERR(info->clk))
+               return dev_err_probe(&pdev->dev, PTR_ERR(info->clk),
+                                    "failed to get adc clock\n");
 
        info->vref = devm_regulator_get(&pdev->dev, "vref");
-       if (IS_ERR(info->vref)) {
-               dev_err(&pdev->dev, "failed to get regulator, %ld\n",
-                       PTR_ERR(info->vref));
-               return PTR_ERR(info->vref);
-       }
+       if (IS_ERR(info->vref))
+               return dev_err_probe(&pdev->dev, PTR_ERR(info->vref),
+                                    "failed to get regulator\n");
 
        if (info->reset)
                rockchip_saradc_reset_controller(info->reset);