]> git.baikalelectronics.ru Git - uboot.git/commitdiff
gpio: allow passing NULL to gpio_request_by_line_name() to search all gpio controllers
authorRasmus Villemoes <rasmus.villemoes@prevas.dk>
Fri, 17 Mar 2023 20:12:22 +0000 (21:12 +0100)
committerTom Rini <trini@konsulko.com>
Thu, 30 Mar 2023 19:09:59 +0000 (15:09 -0400)
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>
drivers/gpio/gpio-uclass.c
include/asm-generic/gpio.h

index dbebf3a53eb6747949a51c5ca1b63fab7b215be8..c8be5a4d668a78e180abb2679a451f332db3c448 100644 (file)
@@ -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;
index dd0bdf2315e8c1b0439a474632cce7db90096ca2..c4a7fd28439bca439052e555d72431b0c9d80fca 100644 (file)
@@ -580,7 +580,8 @@ int gpio_request_by_name(struct udevice *dev, const char *list_name,
  * This allows boards to implement common behaviours using GPIOs while not
  * requiring specific GPIO offsets be used.
  *
- * @dev:       An instance of a GPIO controller udevice
+ * @dev:        An instance of a GPIO controller udevice, or NULL to search
+ *              all GPIO controller devices
  * @line_name: The name of the GPIO (e.g. "bmc-secure-boot")
  * @desc:      A GPIO descriptor that is populated with the requested GPIO
  *              upon return