Re: [PATCH 02/10] iio: backend: add devm_iio_backend_get_optional()

From: Rodrigo Alencar

Date: Fri Oct 16 2026 - 07:21:02 EST


On 16/10/26 09:45, Nuno Sá wrote:
> On Thu, Oct 15, 2026 at 09:41:40PM +0300, Andy Shevchenko wrote:
> > On Thu, Oct 15, 2026 at 01:49:42PM -0300, Rodrigo Alencar via B4 Relay wrote:
> >
> > > Frontend devices might not need a backend driver to rely on. An IIO device
> > > that supports backends can behave differently when they are not available
> > > and that should be acceptable. Such parts may provide basic functionality
> > > solely using the control interface (SPI for instance), being able to have
> > > extended features when a backend is present.
> > >
> > > Add devm_iio_backend_get_optional(), which returns NULL when the backend
> > > is not described in firmware, i.e., when the io-backends property is not
> > > present or, for a named lookup, when the name is not listed in the
> > > io-backend-names property. Other errors, such as probe deferral, are
> > > still returned.
> > >
> > > To make that possible, a named lookup that does not match any entry of
> > > io-backend-names now fails with -ENOENT, the same error returned when the
> > > io-backends reference is missing. Also, the missing reference is no longer
> > > logged as an error, leaving that to the caller.

...

> > > ret = device_property_match_string(dev, "io-backend-names", name);
> > > + if (ret == -EINVAL || ret == -ENODATA)
> > > + return ERR_PTR(-ENOENT);
> >
> > No. Please, use device_property_present() instead.
>
> Oh right! Totally forgot about that internally :). And it fits into my
> internal point where I don't agree much in treating -ENODATA the same
> way as property does not exist.

Say a frontend consumes multiple backends, but some of them are optional.
If we care only about the presence of the property we would fail when
trying to acquire the optional ones when the required ones are defined.
am I thinking correctly?

--
Kind regards,

Rodrigo Alencar