Skip to content

Commit 0627b71

Browse files
mbriandlag-linaro
authored andcommitted
gpio: regmap: Allow to provide init_valid_mask callback
Allows to populate the gpio_regmap_config structure with init_valid_mask() callback to set on the final gpio_chip structure. Reviewed-by: Michael Walle <mwalle@kernel.org> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org> Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com> Link: https://lore.kernel.org/r/20250824-mdb-max7360-support-v14-6-435cfda2b1ea@bootlin.com Signed-off-by: Lee Jones <lee@kernel.org>
1 parent 553b75d commit 0627b71

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

drivers/gpio/gpio-regmap.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ struct gpio_regmap *gpio_regmap_register(const struct gpio_regmap_config *config
261261
chip->names = config->names;
262262
chip->label = config->label ?: dev_name(config->parent);
263263
chip->can_sleep = regmap_might_sleep(config->regmap);
264+
chip->init_valid_mask = config->init_valid_mask;
264265

265266
chip->request = gpiochip_generic_request;
266267
chip->free = gpiochip_generic_free;

include/linux/gpio/regmap.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
struct device;
77
struct fwnode_handle;
88
struct gpio_regmap;
9+
struct gpio_chip;
910
struct irq_domain;
1011
struct regmap;
1112

@@ -40,6 +41,8 @@ struct regmap;
4041
* @drvdata: (Optional) Pointer to driver specific data which is
4142
* not used by gpio-remap but is provided "as is" to the
4243
* driver callback(s).
44+
* @init_valid_mask: (Optional) Routine to initialize @valid_mask, to be used
45+
* if not all GPIOs are valid.
4346
* @regmap_irq_chip: (Optional) Pointer on an regmap_irq_chip structure. If
4447
* set, a regmap-irq device will be created and the IRQ
4548
* domain will be set accordingly.
@@ -93,6 +96,10 @@ struct gpio_regmap_config {
9396
unsigned int offset, unsigned int *reg,
9497
unsigned int *mask);
9598

99+
int (*init_valid_mask)(struct gpio_chip *gc,
100+
unsigned long *valid_mask,
101+
unsigned int ngpios);
102+
96103
void *drvdata;
97104
};
98105

0 commit comments

Comments
 (0)