Skip to content

Commit a6b0520

Browse files
Bartosz GolaszewskiSasha Levin
authored andcommitted
gpio: swnode: restore the swnode-name-against-chip-label matching
[ Upstream commit ff91965 ] Using the remote firmware node for software node lookup is the right thing to do. The GPIO controller we want to resolve should have the software node we scooped out of the reference attached to it. However, there are existing users who abuse the software node API by creating dummy swnodes whose name is set to the expected label string of the GPIO controller whose pins they want to control and use them in their local swnode references as GPIO properties. This used to work when we compared the software node's name to the chip's label. When we switched to using a real fwnode lookup, these users broke down because the firmware nodes in question were never attached to the controllers they were looking for. Restore the label matching as a fallback to fix the broken users but add a big FIXME urging for a better solution. Cc: stable@vger.kernel.org # v6.18, v6.19 Fixes: 216c120 ("gpio: swnode: allow referencing GPIO chips by firmware nodes") Link: https://lore.kernel.org/all/aYkdKfP5fg6iywgr@jekhomev/ Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Hans de Goede <johannes.goede@oss.qualcomm.com> Link: https://patch.msgid.link/20260211085313.16792-1-bartosz.golaszewski@oss.qualcomm.com Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 3c2b95b commit a6b0520

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

drivers/gpio/gpiolib-swnode.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,25 @@ static struct gpio_device *swnode_get_gpio_device(struct fwnode_handle *fwnode)
4343

4444
fwnode_lookup:
4545
gdev = gpio_device_find_by_fwnode(fwnode);
46+
if (!gdev && gdev_node && gdev_node->name)
47+
/*
48+
* FIXME: We shouldn't need to compare the GPIO controller's
49+
* label against the software node that is supposedly attached
50+
* to it. However there are currently GPIO users that - knowing
51+
* the expected label of the GPIO chip whose pins they want to
52+
* control - set up dummy software nodes named after those GPIO
53+
* controllers, which aren't actually attached to them. In this
54+
* case gpio_device_find_by_fwnode() will fail as no device on
55+
* the GPIO bus is actually associated with the fwnode we're
56+
* looking for.
57+
*
58+
* As a fallback: continue checking the label if we have no
59+
* match. However, the situation described above is an abuse
60+
* of the software node API and should be phased out and the
61+
* following line - eventually removed.
62+
*/
63+
gdev = gpio_device_find_by_label(gdev_node->name);
64+
4665
return gdev ?: ERR_PTR(-EPROBE_DEFER);
4766
}
4867

0 commit comments

Comments
 (0)