diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 4c7aee4..f960098 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -475,6 +475,13 @@ return -EPROBE_DEFER; } +struct gpio_chip *gpio_get_chip(int gpio) +{ + struct gpio_info *gi = gpio_to_desc(gpio); + + return gi ? gi->chip : NULL; +} + #ifdef CONFIG_CMD_GPIO static int do_gpiolib(int argc, char *argv[]) { diff --git a/include/gpio.h b/include/gpio.h index 38d6ba2..e822fd5 100644 --- a/include/gpio.h +++ b/include/gpio.h @@ -153,5 +153,6 @@ void gpiochip_remove(struct gpio_chip *chip); int gpio_get_num(struct device_d *dev, int gpio); +struct gpio_chip *gpio_get_chip(int gpio); #endif /* __GPIO_H */