diff mbox series

[v5,07/11] gpio: regmap: Allow to provide init_valid_mask callback

Message ID 20250318-mdb-max7360-support-v5-7-fb20baf97da0@bootlin.com (mailing list archive)
State New
Headers show
Series Add support for MAX7360 | expand

Commit Message

Mathieu Dubois-Briand March 18, 2025, 4:26 p.m. UTC
Allows to populate the gpio_regmap_config structure with
init_valid_mask() callback to set on the final gpio_chip structure.

Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
---
 drivers/gpio/gpio-regmap.c  | 3 +--
 include/linux/gpio/regmap.h | 7 +++++++
 2 files changed, 8 insertions(+), 2 deletions(-)

Comments

Andy Shevchenko March 18, 2025, 4:53 p.m. UTC | #1
On Tue, Mar 18, 2025 at 05:26:23PM +0100, Mathieu Dubois-Briand wrote:
> Allows to populate the gpio_regmap_config structure with
> init_valid_mask() callback to set on the final gpio_chip structure.

...

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

Stray change.
Michael Walle March 19, 2025, 7:02 a.m. UTC | #2
Hi,

> Allows to populate the gpio_regmap_config structure with
> init_valid_mask() callback to set on the final gpio_chip structure.
>
> Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
> ---

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

With this removed:

Reviewed-by: Michael Walle <mwalle@kernel.org>
Mathieu Dubois-Briand March 20, 2025, 8:48 a.m. UTC | #3
On Tue Mar 18, 2025 at 5:53 PM CET, Andy Shevchenko wrote:
> On Tue, Mar 18, 2025 at 05:26:23PM +0100, Mathieu Dubois-Briand wrote:
> > Allows to populate the gpio_regmap_config structure with
> > init_valid_mask() callback to set on the final gpio_chip structure.
>
> ...
>
> > -	chip->request = gpiochip_generic_request;
> > -	chip->free = gpiochip_generic_free;
>
> Stray change.

Oops, reminder of a dropped patch, thanks for noticing this.

Best regards,
Mathieu
Mathieu Dubois-Briand March 20, 2025, 8:49 a.m. UTC | #4
On Wed Mar 19, 2025 at 8:02 AM CET, Michael Walle wrote:
> Hi,
>
> > Allows to populate the gpio_regmap_config structure with
> > init_valid_mask() callback to set on the final gpio_chip structure.
> >
> > Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
> > ---
>
> > -	chip->request = gpiochip_generic_request;
> > -	chip->free = gpiochip_generic_free;
>
> With this removed:
>
> Reviewed-by: Michael Walle <mwalle@kernel.org>

Yes, reminder of a dropped patch.

Thanks for your review and the tag.
Mathieu
diff mbox series

Patch

diff --git a/drivers/gpio/gpio-regmap.c b/drivers/gpio/gpio-regmap.c
index 61d5f48b445d..4c66a90bbbf1 100644
--- a/drivers/gpio/gpio-regmap.c
+++ b/drivers/gpio/gpio-regmap.c
@@ -262,9 +262,8 @@  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;
 	chip->get = gpio_regmap_get;
 	if (gpio->reg_set_base && gpio->reg_clr_base)
 		chip->set = gpio_regmap_set_with_clear;
diff --git a/include/linux/gpio/regmap.h b/include/linux/gpio/regmap.h
index 55df2527b982..c14bf65d22e9 100644
--- a/include/linux/gpio/regmap.h
+++ b/include/linux/gpio/regmap.h
@@ -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.
@@ -97,6 +100,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;
 };