Message ID | 20250214-mdb-max7360-support-v4-5-8a35c6dbb966@bootlin.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | Add support for MAX7360 | expand |
On Fri, Feb 14, 2025 at 12:49:55PM +0100, Mathieu Dubois-Briand wrote: > 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. I don't think it will be needed after looking at the user. Since we have somewhat around ten of them already and no-one wanted it makes me feel that this is a hack which can be avoided.
diff --git a/drivers/gpio/gpio-regmap.c b/drivers/gpio/gpio-regmap.c index ba72c23bcf97..7d8bfde386a4 100644 --- a/drivers/gpio/gpio-regmap.c +++ b/drivers/gpio/gpio-regmap.c @@ -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 diff --git a/include/linux/gpio/regmap.h b/include/linux/gpio/regmap.h index 16f0c33df75d..0fdc213178d1 100644 --- a/include/linux/gpio/regmap.h +++ b/include/linux/gpio/regmap.h @@ -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(+)