@@ -195,6 +195,12 @@ void *gpio_regmap_get_drvdata(struct gpio_regmap *gpio)
}
EXPORT_SYMBOL_GPL(gpio_regmap_get_drvdata);
+u16 gpio_regmap_get_ngpio(struct gpio_regmap *gpio)
+{
+ return gpio->gpio_chip.ngpio;
+}
+EXPORT_SYMBOL_GPL(gpio_regmap_get_ngpio);
+
/**
* gpio_regmap_register() - Register a generic regmap GPIO controller
* @config: configuration for gpio_regmap
@@ -3,6 +3,8 @@
#ifndef _LINUX_GPIO_REGMAP_H
#define _LINUX_GPIO_REGMAP_H
+#include <linux/types.h>
+
struct device;
struct fwnode_handle;
struct gpio_regmap;
@@ -97,5 +99,6 @@ void gpio_regmap_unregister(struct gpio_regmap *gpio);
struct gpio_regmap *devm_gpio_regmap_register(struct device *dev,
const struct gpio_regmap_config *config);
void *gpio_regmap_get_drvdata(struct gpio_regmap *gpio);
+u16 gpio_regmap_get_ngpio(struct gpio_regmap *gpio);
#endif /* _LINUX_GPIO_REGMAP_H */
Drivers can leave the ngpio field of the gpio_regmap_config structure uninitialized, letting gpio_regmap_register() retrieve its value from the "ngpios" device property. Yet, the driver might still need to know the ngpio value later: allow to extract this value from the gpio_regmap structure. Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com> --- drivers/gpio/gpio-regmap.c | 6 ++++++ include/linux/gpio/regmap.h | 3 +++ 2 files changed, 9 insertions(+)