diff options
author | Bartosz Golaszewski | 2023-10-11 15:02:02 +0200 |
---|---|---|
committer | Bartosz Golaszewski | 2023-10-13 08:50:01 +0200 |
commit | 1559d14977b694570f010854b8192e6de034bc27 (patch) | |
tree | a42340abd3c23a1485fad6ad3ed881a7cfe435b1 /drivers/gpio | |
parent | 4f3b436eea7d7242ca5c528fca1d2d15bc242190 (diff) |
gpiolib: provide gpio_device_to_device()
There are users in the kernel who need to retrieve the address of the
struct device backing the GPIO device. Currently they needlessly poke in
the internals of GPIOLIB. Add a dedicated getter function.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Reviewed-by: Peter Rosin <peda@axentia.se>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio')
-rw-r--r-- | drivers/gpio/gpiolib.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index dd18dd56c33c..7e297ae35f8c 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -1189,6 +1189,23 @@ void gpio_device_put(struct gpio_device *gdev) } EXPORT_SYMBOL_GPL(gpio_device_put); +/** + * gpio_device_to_device() - Retrieve the address of the underlying struct + * device. + * @gdev: GPIO device for which to return the address. + * + * This does not increase the reference count of the GPIO device nor the + * underlying struct device. + * + * Returns: + * Address of struct device backing this GPIO device. + */ +struct device *gpio_device_to_device(struct gpio_device *gdev) +{ + return &gdev->dev; +} +EXPORT_SYMBOL_GPL(gpio_device_to_device); + #ifdef CONFIG_GPIOLIB_IRQCHIP /* |