Re: [PATCH v2 03/18] iio: adc: envelope-detector: Simplify with dev_err_probe()

From: Andy Shevchenko
Date: Thu Aug 27 2020 - 15:46:37 EST


On Thu, Aug 27, 2020 at 10:27 PM Krzysztof Kozlowski <krzk@xxxxxxxxxx> wrote:
>
> Common pattern of handling deferred probe can be simplified with
> dev_err_probe(). Less code and also it prints the error value.

Reviewed-by: Andy Shevchenko <andy.shevchenko@xxxxxxxxx>

> Signed-off-by: Krzysztof Kozlowski <krzk@xxxxxxxxxx>
>
> ---
>
> Changes since v1:
> 1. Wrap dev_err_probe() lines at 100 character
> ---
> drivers/iio/adc/envelope-detector.c | 15 +++++----------
> 1 file changed, 5 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/iio/adc/envelope-detector.c b/drivers/iio/adc/envelope-detector.c
> index 2a4fd3bb64cf..91a7be4a3f1b 100644
> --- a/drivers/iio/adc/envelope-detector.c
> +++ b/drivers/iio/adc/envelope-detector.c
> @@ -348,11 +348,8 @@ static int envelope_detector_probe(struct platform_device *pdev)
> indio_dev->num_channels = 1;
>
> env->dac = devm_iio_channel_get(dev, "dac");
> - if (IS_ERR(env->dac)) {
> - if (PTR_ERR(env->dac) != -EPROBE_DEFER)
> - dev_err(dev, "failed to get dac input channel\n");
> - return PTR_ERR(env->dac);
> - }
> + if (IS_ERR(env->dac))
> + return dev_err_probe(dev, PTR_ERR(env->dac), "failed to get dac input channel\n");
>
> env->comp_irq = platform_get_irq_byname(pdev, "comp");
> if (env->comp_irq < 0)
> @@ -360,11 +357,9 @@ static int envelope_detector_probe(struct platform_device *pdev)
>
> ret = devm_request_irq(dev, env->comp_irq, envelope_detector_comp_isr,
> 0, "envelope-detector", env);
> - if (ret) {
> - if (ret != -EPROBE_DEFER)
> - dev_err(dev, "failed to request interrupt\n");
> - return ret;
> - }
> + if (ret)
> + return dev_err_probe(dev, ret, "failed to request interrupt\n");
> +
> env->comp_irq_trigger = irq_get_trigger_type(env->comp_irq);
> if (env->comp_irq_trigger & IRQF_TRIGGER_RISING)
> env->comp_irq_trigger_inv |= IRQF_TRIGGER_FALLING;
> --
> 2.17.1
>


--
With Best Regards,
Andy Shevchenko