[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v5 1/5] gpiolib: Add support for gpiochipN-based table lookup

From: Geert Uytterhoeven
Subject: [PATCH v5 1/5] gpiolib: Add support for gpiochipN-based table lookup
Date: Tue, 18 Feb 2020 16:18:08 +0100

Currently GPIO controllers can only be referred to by label in GPIO
lookup tables.

Add support for looking them up by "gpiochipN" name, with "N" the
corresponding GPIO device's ID number.

Signed-off-by: Geert Uytterhoeven <address@hidden>
Reviewed-by: Ulrich Hecht <address@hidden>
Reviewed-by: Eugeniu Rosca <address@hidden>
Tested-by: Eugeniu Rosca <address@hidden>
  - Add Reviewed-by, Tested-by,

  - Add Reviewed-by,
  - Drop support for legacy sysfs interface based name matching,
  - Replace complex custom matching by a simple additional check in the
    existing gpiochip_match_name() function,
  - Add kerneldoc() for find_chip_by_name(), documenting matching order.

  - New.
 drivers/gpio/gpiolib.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 4d0106ceeba7bb24..200c2d2be4b78043 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -1738,9 +1738,18 @@ static int gpiochip_match_name(struct gpio_chip *chip, 
void *data)
        const char *name = data;
-       return !strcmp(chip->label, name);
+       return !strcmp(chip->label, name) ||
+              !strcmp(dev_name(&chip->gpiodev->dev), name);
+ * find_chip_by_name() - Find a specific gpio_chip by name
+ * @name: Name to match
+ *
+ * Return a reference to a gpio_chip that matches the passed name.
+ * This function first tries matching on the gpio_chip's label, followed by
+ * matching on dev_name() of the corresponding gpio_device.
+ */
 static struct gpio_chip *find_chip_by_name(const char *name)
        return gpiochip_find((void *)name, gpiochip_match_name);

reply via email to

[Prev in Thread] Current Thread [Next in Thread]