Re: [PATCH v2] iio: adc: stm32: Simplify with dev_err_probe()
From: Andy Shevchenko
Date: Thu Aug 27 2020 - 04:27:31 EST
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().
Please, revisit all patches on this topic.
--
With Best Regards,
Andy Shevchenko