Re: [PATCH 3/7] iio: light: opt3001: prefer dev_err_probe()
From: Joshua Crofts
Date: Mon May 11 2026 - 07:13:26 EST
On Mon, 11 May 2026 at 13:04, Andy Shevchenko
<andriy.shevchenko@xxxxxxxxx> wrote:
>
> On Mon, May 11, 2026 at 12:04:08PM +0200, Joshua Crofts via B4 Relay wrote:
>
> > Switch driver to use dev_err_probe() to unify
> > error messages generated in *_probe() and probe path functions.
>
> ...
>
> > ret = i2c_smbus_read_word_swapped(opt->client, OPT3001_CONFIGURATION);
> > - if (ret < 0) {
> > - dev_err(opt->dev, "failed to read register %02x\n",
> > - OPT3001_CONFIGURATION);
> > - return ret;
> > - }
> > + if (ret < 0)
> > + return dev_err_probe(opt->dev, ret,
>
> We have client available, and here is dev in use. With this being said,
> I think the proper order of cleanups is to get rid of dev member and
> use local 'dev' variable here
>
> struct device *dev = &opt->client->dev;
>
> > + "failed to read register %02x\n",
> > + OPT3001_CONFIGURATION);
Fair enough, I'll slip in a preparatory patch.
--
Kind regards
CJD