diff options
author | Rasmus Villemoes <rasmus.villemoes@prevas.dk> | 2023-03-17 21:12:22 +0100 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2023-03-30 15:09:59 -0400 |
commit | e1c97949ee922ccc84c4ef4364c9810aa76f6306 (patch) | |
tree | a64c106aa1c54001e61e02de15ff3d45fbe90332 /drivers/gpio | |
parent | fdef6b982f0a24d4b3a83d107da4f817efa4566f (diff) |
gpio: allow passing NULL to gpio_request_by_line_name() to search all gpio controllers
The API is more convenient to use if one doesn't have to know upfront
which gpio controller has a line with the name one is searching for,
and arrange to look that device up somehow. Or implement this loop
oneself.
Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/gpio')
-rw-r--r-- | drivers/gpio/gpio-uclass.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c index dbebf3a53e..c8be5a4d66 100644 --- a/drivers/gpio/gpio-uclass.c +++ b/drivers/gpio/gpio-uclass.c @@ -1171,6 +1171,13 @@ int gpio_request_by_line_name(struct udevice *dev, const char *line_name, { int ret; + if (!dev) { + uclass_foreach_dev_probe(UCLASS_GPIO, dev) + if (!gpio_request_by_line_name(dev, line_name, desc, flags)) + return 0; + return -ENOENT; + } + ret = dev_read_stringlist_search(dev, "gpio-line-names", line_name); if (ret < 0) return ret; |