diff options
author | Ahmad Fatoum <a.fatoum@pengutronix.de> | 2019-06-17 17:07:42 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2019-06-20 16:03:50 +0200 |
commit | 0bf713e53a1f2556e66f76a368476e233e5ab89d (patch) | |
tree | cce3d28f250d8e5d38966e14c566db68834716d7 /drivers/gpio | |
parent | 74c9e3df668067c7819bd3ce3cf58769971250b3 (diff) | |
download | barebox-0bf713e53a1f2556e66f76a368476e233e5ab89d.tar.gz barebox-0bf713e53a1f2556e66f76a368476e233e5ab89d.tar.xz |
gpiolib: add gpio_get_chip helper
Pinctrl nodes adhering to the generic pinctrl bindings may contain
properties like input-low/input-high, which require pinctrl_ops.set_state
to have a handle on the relevant gpio chip.
Currently this would lead to code duplication: Both the pinctrl driver
and gpiolib will need to store a list of registered gpiochips.
Avoid this by providing a helper to query the registered gpio_chip
given a gpio's number.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/gpio')
-rw-r--r-- | drivers/gpio/gpiolib.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 4c7aee4a0b..f96009896a 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -475,6 +475,13 @@ int gpio_get_num(struct device_d *dev, int gpio) 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[]) { |