diff mbox series

[v3,6/9] iio: adc: meson_saradc: Make use of the helper function dev_err_probe()

Message ID 20210928141956.2148-6-caihuoqing@baidu.com (mailing list archive)
State New, archived
Headers show
Series [v3,1/9] iio: adc: ab8500-gpadc: Make use of the helper function dev_err_probe() | expand

Commit Message

Cai,Huoqing Sept. 28, 2021, 2:19 p.m. UTC
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>
---
v1->v2: Remove the separate line of PTR_ERR().

 drivers/iio/adc/meson_saradc.c | 39 +++++++++++++-----------------
 1 file changed, 17 insertions(+), 22 deletions(-)

Comments

Martin Blumenstingl Oct. 2, 2021, 1:01 p.m. UTC | #1
On Tue, Sep 28, 2021 at 4:20 PM Cai Huoqing <caihuoqing@baidu.com> wrote:
>
> 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>
Reviewed-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
as well as:
Reviewed-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
# Odroid-C1

Thanks for your contribution!


Best regards,
Martin
Jonathan Cameron Oct. 2, 2021, 4:09 p.m. UTC | #2
On Sat, 2 Oct 2021 15:01:56 +0200
Martin Blumenstingl <martin.blumenstingl@googlemail.com> wrote:

> On Tue, Sep 28, 2021 at 4:20 PM Cai Huoqing <caihuoqing@baidu.com> wrote:
> >
> > 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>  
> Reviewed-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
> as well as:
> Reviewed-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
> # Odroid-C1
Hi Martin,

Confusing tag.  Was the second meant to be a Tested-by?

Thanks,

Jonathan
> 
> Thanks for your contribution!
> 
> 
> Best regards,
> Martin
Martin Blumenstingl Oct. 2, 2021, 5:06 p.m. UTC | #3
Hi Jonathan,

On Sat, Oct 2, 2021 at 6:05 PM Jonathan Cameron <jic23@kernel.org> wrote:
>
> On Sat, 2 Oct 2021 15:01:56 +0200
> Martin Blumenstingl <martin.blumenstingl@googlemail.com> wrote:
>
> > On Tue, Sep 28, 2021 at 4:20 PM Cai Huoqing <caihuoqing@baidu.com> wrote:
> > >
> > > 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>
> > Reviewed-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
> > as well as:
> > Reviewed-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
> > # Odroid-C1
> Hi Martin,
>
> Confusing tag.  Was the second meant to be a Tested-by?
my bad - it is indeed supposed to be:
Tested-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>

Testing was done on a Meson8b Odroid-C1 board.


Best regards,
Martin
diff mbox series

Patch

diff --git a/drivers/iio/adc/meson_saradc.c b/drivers/iio/adc/meson_saradc.c
index 705d5e11a54b..014a77f98b98 100644
--- a/drivers/iio/adc/meson_saradc.c
+++ b/drivers/iio/adc/meson_saradc.c
@@ -1230,35 +1230,31 @@  static int meson_sar_adc_probe(struct platform_device *pdev)
 		return ret;
 
 	priv->clkin = devm_clk_get(&pdev->dev, "clkin");
-	if (IS_ERR(priv->clkin)) {
-		dev_err(&pdev->dev, "failed to get clkin\n");
-		return PTR_ERR(priv->clkin);
-	}
+	if (IS_ERR(priv->clkin))
+		return dev_err_probe(&pdev->dev, PTR_ERR(priv->clkin),
+				     "failed to get clkin\n");
 
 	priv->core_clk = devm_clk_get(&pdev->dev, "core");
-	if (IS_ERR(priv->core_clk)) {
-		dev_err(&pdev->dev, "failed to get core clk\n");
-		return PTR_ERR(priv->core_clk);
-	}
+	if (IS_ERR(priv->core_clk))
+		return dev_err_probe(&pdev->dev, PTR_ERR(priv->core_clk),
+				     "failed to get core clk\n");
 
 	priv->adc_clk = devm_clk_get(&pdev->dev, "adc_clk");
 	if (IS_ERR(priv->adc_clk)) {
-		if (PTR_ERR(priv->adc_clk) == -ENOENT) {
+		if (PTR_ERR(priv->adc_clk) == -ENOENT)
 			priv->adc_clk = NULL;
-		} else {
-			dev_err(&pdev->dev, "failed to get adc clk\n");
-			return PTR_ERR(priv->adc_clk);
-		}
+		else
+			return dev_err_probe(&pdev->dev, PTR_ERR(priv->adc_clk),
+					     "failed to get adc clk\n");
 	}
 
 	priv->adc_sel_clk = devm_clk_get(&pdev->dev, "adc_sel");
 	if (IS_ERR(priv->adc_sel_clk)) {
-		if (PTR_ERR(priv->adc_sel_clk) == -ENOENT) {
+		if (PTR_ERR(priv->adc_sel_clk) == -ENOENT)
 			priv->adc_sel_clk = NULL;
-		} else {
-			dev_err(&pdev->dev, "failed to get adc_sel clk\n");
-			return PTR_ERR(priv->adc_sel_clk);
-		}
+		else
+			return dev_err_probe(&pdev->dev, PTR_ERR(priv->adc_sel_clk),
+					     "failed to get adc_sel clk\n");
 	}
 
 	/* on pre-GXBB SoCs the SAR ADC itself provides the ADC clock: */
@@ -1265,10 +1265,9 @@  static int meson_sar_adc_probe(struct platform_device *pdev)
 	}
 
 	priv->vref = devm_regulator_get(&pdev->dev, "vref");
-	if (IS_ERR(priv->vref)) {
-		dev_err(&pdev->dev, "failed to get vref regulator\n");
-		return PTR_ERR(priv->vref);
-	}
+	if (IS_ERR(priv->vref))
+		return dev_err_probe(&pdev->dev, PTR_ERR(priv->vref),
+				     "failed to get vref regulator\n");
 
 	priv->calibscale = MILLION;