Re: [bug report] iio: adc: Add support for ad4062

Jorge Marques
2026-03-05T17:10:23Z

On Sun, Mar 01, 2026 at 12:34:29PM +0000, Jonathan Cameron wrote:
> On Fri, 6 Feb 2026 16:07:36 +0200
> Andy Shevchenko <andriy.shevchenko@intel.com> wrote:
>
> > On Fri, Feb 06, 2026 at 04:40:31PM +0300, Dan Carpenter wrote:
> > > [ Smatch checking is paused while we raise funding. #SadFace
> > > https://lore.kernel.org/all/aTaiGSbWZ9DJaGo7@stanley.mountain/ -dan ]
> >
> > Oh, this is indeed sad. Wondering if LF can donate...
> >
> > > Commit d5284402d28f ("iio: adc: Add support for ad4062") from Dec 17,
> > > 2025 (linux-next), leads to the following Smatch static checker
> > > warning:
> > >
> > > drivers/iio/adc/ad4062.c:1557 ad4062_probe()
> > > warn: passing positive error code 's32min-(-1),1-3' to 'dev_err_probe'
> >
> > > 1555 ret = ad4062_request_ibi(i3cdev);
> > > 1556 if (ret)
> >
> > if (ret < 0)
> >
> > resolves immediate isssue, but...
> >
> > > --> 1557 return dev_err_probe(dev, ret, "Failed to request i3c ibi\n");
> > >
> > > The comments for ad4062_request_ibi() say it returns negative error codes
> > > but the comments for i3c_master_enec_locked() say it returns "a positive
> > > I3C error code if the error is one of the official Mx error codes, and
> > > a negative error code otherwise."
> >
> > ...would be nice to have a conversion helper to get Linux error codes
> > from the Mx ones.
> >
>
> @Jorge, can you take a look at this please and ideally send a fix.

Hi Andy, Jonathan,

I found nine paths that returned positive Mx error codes when 0 or
negative was expected.

i3c/device.h suggests returning -EIO. The error codes range from M0 to
M2; only M2 is suppressed during [RST|ENT]DAA (means "no active device
on the bus"), which is already done internally but duplicated.

I will submit the changes to the i3c subsystem after CI/CD and hardware
tests are run to make sure, since many paths are involved.

Note that the immediate fix is not valid, if a Mx code was returned as
is, we would like to return an error still, since that would mean the
target device did not acknowledge the enable target events (instead we
would convert to -EIO).

Thanks,
Jorge
>
> Thanks,
>
> Jonathan