diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 982bec0..4c7aee4 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -91,6 +91,23 @@ return ret; } +int gpio_find_by_label(const char *label) +{ + int i; + + for (i = 0; i < ARCH_NR_GPIOS; i++) { + struct gpio_info *info = &gpio_desc[i]; + + if (!info->requested || !info->chip || !info->label) + continue; + + if (!strcmp(info->label, label)) + return i; + } + + return -ENOENT; +} + void gpio_free(unsigned gpio) { struct gpio_info *gi = gpio_to_desc(gpio); diff --git a/include/gpio.h b/include/gpio.h index e42fa23..38d6ba2 100644 --- a/include/gpio.h +++ b/include/gpio.h @@ -92,6 +92,11 @@ return 0; } +static inline int gpio_find_by_label(const char *label) +{ + return -ENOSYS; +} + static inline void gpio_free(unsigned gpio) { } @@ -114,6 +119,7 @@ } #else int gpio_request(unsigned gpio, const char *label); +int gpio_find_by_label(const char *label); void gpio_free(unsigned gpio); int gpio_request_one(unsigned gpio, unsigned long flags, const char *label); int gpio_request_array(const struct gpio *array, size_t num);