Re: [PATCH v1 1/2] devres: Switch to use dev_err_probe() for unification

From: Andy Shevchenko
Date: Thu Feb 29 2024 - 05:40:07 EST


On Thu, Feb 29, 2024 at 09:52:34AM +0100, Philipp Stanner wrote:
> On Tue, 2024-02-27 at 19:58 +0200, Andy Shevchenko wrote:
> > The devm_*() APIs are supposed to be called during the ->probe()
> > stage.
> > Many drivers (especially new ones) has switched to use
>
> has -> have

Thanks, will fix.

> > dev_err_probe()
> > for error messaging for the sake of unification. Let's do the same in
> > the devres APIs.
>
> No objections on principle. Just one thing about the implementation:

..

> > +               ret = dev_err_probe(dev, -EINVAL, "invalid resource
> > %pR\n", res);
> > +               return IOMEM_ERR_PTR(ret);
>
> So as I see it -EINVAL is just piped through dev_err_probe() and is
> never changed.
> Don't you think it would be better to drop variable 'ret' and just do
> return IOMEM_ERR_PTR(-EINVAL);
> as before?

dev_err_probe() requires error code as a parameter. Are you suggesting to have
a duplication?

dev_err_probe(-EINVAL);
return -EINVAL;

I don't think it's a good suggestion, so the answer is "No, I don't think it
would be better."

> That way it would be obvious that the error code is never changed and
> it will always return -EINVAL. Otherwise you have to look up the
> function definition of dev_err_probe().

..

> The same would apply below.

Same answer.

--
With Best Regards,
Andy Shevchenko