]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
gpio: regmap: Allow to provide init_valid_mask callback
authorMathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Sun, 24 Aug 2025 11:57:25 +0000 (13:57 +0200)
committerLee Jones <lee@kernel.org>
Tue, 16 Sep 2025 14:24:48 +0000 (15:24 +0100)
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>
drivers/gpio/gpio-regmap.c
include/linux/gpio/regmap.h

index e1944931ee7ccf5c3b47755dd72c06bb34892afd..d9d23853e0326b837eea423652b10a2bace88ed5 100644 (file)
@@ -261,6 +261,7 @@ struct gpio_regmap *gpio_regmap_register(const struct gpio_regmap_config *config
        chip->names = config->names;
        chip->label = config->label ?: dev_name(config->parent);
        chip->can_sleep = regmap_might_sleep(config->regmap);
+       chip->init_valid_mask = config->init_valid_mask;
 
        chip->request = gpiochip_generic_request;
        chip->free = gpiochip_generic_free;
index 19b52ac03a5dec797490c02af26ef8e8d52598b1..622a2939ebe0fd6b5f93dfa371331b2f4e674059 100644 (file)
@@ -6,6 +6,7 @@
 struct device;
 struct fwnode_handle;
 struct gpio_regmap;
+struct gpio_chip;
 struct irq_domain;
 struct regmap;
 
@@ -40,6 +41,8 @@ struct regmap;
  * @drvdata:           (Optional) Pointer to driver specific data which is
  *                     not used by gpio-remap but is provided "as is" to the
  *                     driver callback(s).
+ * @init_valid_mask:   (Optional) Routine to initialize @valid_mask, to be used
+ *                     if not all GPIOs are valid.
  * @regmap_irq_chip:   (Optional) Pointer on an regmap_irq_chip structure. If
  *                     set, a regmap-irq device will be created and the IRQ
  *                     domain will be set accordingly.
@@ -93,6 +96,10 @@ struct gpio_regmap_config {
                              unsigned int offset, unsigned int *reg,
                              unsigned int *mask);
 
+       int (*init_valid_mask)(struct gpio_chip *gc,
+                              unsigned long *valid_mask,
+                              unsigned int ngpios);
+
        void *drvdata;
 };