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

From: Andy Shevchenko

Date: Fri Oct 16 2026 - 09:21:56 EST


On Fri, Oct 16, 2026 at 02:01:59PM +0100, Nuno Sá wrote:
> On Fri, Oct 16, 2026 at 08:18:08AM -0300, Rodrigo Alencar wrote:
> > 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:

...

> > > > 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?
>
> Hmm not sure that makes much sense (I mean having optional and non
> optional backends for a frontend). At least I'm not aware of any
> possible usecase we might have internally. That said, you're thinking
> correctly and it's fairly simple to accommodate for that today. But
> Andy might still prefer something like:
>
> if (!device_property_present())
> return return ERR_PTR(-ENOENT);

> /* A comment here would make sense given it's not that clear what are we
> * trying to get with the below check */
> ret = device_property_match_string();
> if (ret == -ENODATA)
> return ERR_PTR(-ENOENT);

Yep, this must be well justified. Currently I (may be missing something) can't
see that justification.

--
With Best Regards,
Andy Shevchenko