[PATCH v4 03/12] iio: backend: use the consumer fwnode for named lookups

From: Rodrigo Alencar via B4 Relay

Date: Mon Nov 16 2026 - 11:40:15 EST


From: Rodrigo Alencar <rodrigo.alencar@xxxxxxxxxx>

__devm_iio_backend_fwnode_get() receives the consumer fwnode, which is
used to resolve the io-backends reference. However, for a named lookup,
the index is obtained from the io-backend-names property of the device
instead. When devm_iio_backend_fwnode_get() is called with a fwnode other
than the device one, such as a child node, the name is then matched
against the wrong node, either failing or returning the index of a
different backend.

Look up io-backend-names in the given fwnode, so that both properties
are read from the same node.

The only current user of devm_iio_backend_fwnode_get() does not provide
a name, so it is not affected.

Fixes: c464cc610f51 ("iio: add child nodes support in iio backend framework")
Signed-off-by: Rodrigo Alencar <rodrigo.alencar@xxxxxxxxxx>
---
drivers/iio/industrialio-backend.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/industrialio-backend.c b/drivers/iio/industrialio-backend.c
index fbf5c39d7655..9a1072b39815 100644
--- a/drivers/iio/industrialio-backend.c
+++ b/drivers/iio/industrialio-backend.c
@@ -1034,7 +1034,7 @@ static struct iio_backend *__devm_iio_backend_fwnode_get(struct device *dev, con
int ret;

if (name) {
- ret = device_property_match_string(dev, "io-backend-names", name);
+ ret = fwnode_property_match_string(fwnode, "io-backend-names", name);
if (ret < 0)
return ERR_PTR(ret);
index = ret;

--
2.43.0