Re: [PATCH v2] iio: adc: stm32: Simplify with dev_err_probe()

From: Krzysztof Kozlowski
Date: Thu Aug 27 2020 - 15:07:01 EST


On Thu, Aug 27, 2020 at 11:27:12AM +0300, Andy Shevchenko wrote:
> On Wed, Aug 26, 2020 at 7:19 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.
>
>
>
>
>
>
> > priv->aclk = devm_clk_get(&pdev->dev, "adc");
> > if (IS_ERR(priv->aclk)) {
> > ret = PTR_ERR(priv->aclk);
> > - if (ret != -ENOENT) {
> > - if (ret != -EPROBE_DEFER)
> > - dev_err(&pdev->dev, "Can't get 'adc' clock\n");
> > - return ret;
> > - }
> > + if (ret != -ENOENT)
> > + return dev_err_probe(&pdev->dev, ret, "Can't get 'adc' clock\n");
> > +
> > priv->aclk = NULL;
> > }
> >
> > priv->bclk = devm_clk_get(&pdev->dev, "bus");
> > if (IS_ERR(priv->bclk)) {
> > ret = PTR_ERR(priv->bclk);
> > - if (ret != -ENOENT) {
> > - if (ret != -EPROBE_DEFER)
> > - dev_err(&pdev->dev, "Can't get 'bus' clock\n");
> > - return ret;
> > - }
> > + if (ret != -ENOENT)
> > + return dev_err_probe(&pdev->dev, ret, "Can't get 'bus' clock\n");
> > +
> > priv->bclk = NULL;
> > }
>
> Again, devm_clk_get_optional() and even, if it exists,
> devm_clk_bulk_get_optional().

Sure.

>
> Please, revisit all patches on this topic.

I'll check them.


Best regards,
Krzysztof