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

From: Andy Shevchenko

Date: Thu Oct 15 2026 - 14:42:19 EST


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.

...

> struct fwnode_handle *fwnode_back __free(fwnode_handle) =
> fwnode_find_reference(fwnode, "io-backends", index);
> - if (IS_ERR(fwnode_back))
> + if (IS_ERR(fwnode_back)) {
> + /* not described in firmware, let the caller decide what to do */
> + if (PTR_ERR(fwnode_back) == -ENOENT)
> + return ERR_CAST(fwnode_back);
> +
> return dev_err_cast_probe(dev, fwnode_back,
> "Cannot get Firmware reference\n");
> + }

Simpler to do is just to add

/* not described in firmware, let the caller decide what to do */
if (PTR_ERR(fwnode_back) == -ENOENT)
return ERR_CAST(fwnode_back);

just before IS_ERR() check.

...

> 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.

> if (ret < 0)
> return ERR_PTR(ret);

--
With Best Regards,
Andy Shevchenko