Skip to content

Commit 8c85a10

Browse files
author
Bartosz Golaszewski
committed
gpiolib: provide gpio_device_get_base()
Let's start adding getters for the opaque struct gpio_device. Start with a function allowing to retrieve the base GPIO number. Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org> Acked-by: Linus Walleij <linus.walleij@linaro.org>
1 parent 9acdf62 commit 8c85a10

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

drivers/gpio/gpiolib.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,19 @@ struct gpio_device *gpiod_to_gpio_device(struct gpio_desc *desc)
241241
}
242242
EXPORT_SYMBOL_GPL(gpiod_to_gpio_device);
243243

244+
/**
245+
* gpio_device_get_base() - Get the base GPIO number allocated by this device
246+
* @gdev: GPIO device
247+
*
248+
* Returns:
249+
* First GPIO number in the global GPIO numberspace for this device.
250+
*/
251+
int gpio_device_get_base(struct gpio_device *gdev)
252+
{
253+
return gdev->base;
254+
}
255+
EXPORT_SYMBOL_GPL(gpio_device_get_base);
256+
244257
/**
245258
* gpio_device_get_chip() - Get the gpio_chip implementation of this GPIO device
246259
* @gdev: GPIO device

include/linux/gpio/driver.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -787,6 +787,9 @@ void gpiochip_unlock_as_irq(struct gpio_chip *gc, unsigned int offset);
787787
struct gpio_chip *gpiod_to_chip(const struct gpio_desc *desc);
788788
struct gpio_device *gpiod_to_gpio_device(struct gpio_desc *desc);
789789

790+
/* struct gpio_device getters */
791+
int gpio_device_get_base(struct gpio_device *gdev);
792+
790793
#else /* CONFIG_GPIOLIB */
791794

792795
#include <linux/err.h>

0 commit comments

Comments
 (0)