* [RFT PATCH v2 01/14] gpio: regmap: use the correct number for .ngpio_per_reg
2026-11-27 14:52 [RFT PATCH v2 00/14] gpio: regmap: IRQ domain cleanups Michael Walle
@ 2026-11-27 14:52 ` Michael Walle
2026-11-27 17:19 ` Andy Shevchenko
2026-11-27 14:52 ` [RFT PATCH v2 02/14] gpio: regmap: remove gpiochip before tearing down irqchip Michael Walle
` (12 subsequent siblings)
13 siblings, 1 reply; 21+ messages in thread
From: Michael Walle @ 2026-11-27 14:52 UTC (permalink / raw)
To: William Breathitt Gray, Linus Walleij, Bartosz Golaszewski,
Petar Stepanovic, SriNavmani A, Prasad Bolisetty, Tzu-Hao Wei,
Karthikeyan Mitran, Mathieu Dubois-Briand, Michael Walle,
Lee Jones, Andy Shevchenko, Long Zhao, Joseph Telaak
Cc: linux-gpio, linux-arm-kernel, Sashiko
Setting .ngpio_per_reg to 0 means that gpio-regmap assumes there is only
one register. If the number of GPIOs comes from gpiochip_get_ngpios()
config->ngpio is still 0 and it's taking over the wrong number.
Fix it by using chip->ngpio, which uses either config->ngpio or
gpiochip_get_ngpios().
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://sashiko.dev/#/bug/linux-85577bd9-c441-47ec-b415-cd40acf50e01
Fixes: db305161880a ("gpio: regmap: Allow ngpio to be read from the property")
Signed-off-by: Michael Walle <mwalle@kernel.org>
---
drivers/gpio/gpio-regmap.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpio/gpio-regmap.c b/drivers/gpio/gpio-regmap.c
index ac6ad56f4479..65e87177baf0 100644
--- a/drivers/gpio/gpio-regmap.c
+++ b/drivers/gpio/gpio-regmap.c
@@ -523,7 +523,7 @@ struct gpio_regmap *gpio_regmap_register(const struct gpio_regmap_config *config
/* if not set, assume there is only one register */
gpio->ngpio_per_reg = config->ngpio_per_reg;
if (!gpio->ngpio_per_reg)
- gpio->ngpio_per_reg = config->ngpio;
+ gpio->ngpio_per_reg = chip->ngpio;
/* if not set, assume they are consecutive */
gpio->reg_stride = config->reg_stride;
--
2.47.3
^ permalink raw reply related [flat|nested] 21+ messages in thread* Re: [RFT PATCH v2 01/14] gpio: regmap: use the correct number for .ngpio_per_reg
2026-11-27 14:52 ` [RFT PATCH v2 01/14] gpio: regmap: use the correct number for .ngpio_per_reg Michael Walle
@ 2026-11-27 17:19 ` Andy Shevchenko
0 siblings, 0 replies; 21+ messages in thread
From: Andy Shevchenko @ 2026-11-27 17:19 UTC (permalink / raw)
To: Michael Walle
Cc: William Breathitt Gray, Linus Walleij, Bartosz Golaszewski,
Petar Stepanovic, SriNavmani A, Prasad Bolisetty, Tzu-Hao Wei,
Karthikeyan Mitran, Mathieu Dubois-Briand, Lee Jones, Long Zhao,
Joseph Telaak, linux-gpio, linux-arm-kernel, Sashiko
On Fri, Nov 27, 2026 at 03:52:18PM +0100, Michael Walle wrote:
> Setting .ngpio_per_reg to 0 means that gpio-regmap assumes there is only
> one register. If the number of GPIOs comes from gpiochip_get_ngpios()
> config->ngpio is still 0 and it's taking over the wrong number.
>
> Fix it by using chip->ngpio, which uses either config->ngpio or
> gpiochip_get_ngpios().
...
> Fixes: db305161880a ("gpio: regmap: Allow ngpio to be read from the property")
Not sure, before that commit the assumed configuration never worked.
But not objecting it, up to Bart.
...
> /* if not set, assume there is only one register */
^^^ Seems like the comment lacks of an adjustment.
> gpio->ngpio_per_reg = config->ngpio_per_reg;
> if (!gpio->ngpio_per_reg)
> - gpio->ngpio_per_reg = config->ngpio;
> + gpio->ngpio_per_reg = chip->ngpio;
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 21+ messages in thread
* [RFT PATCH v2 02/14] gpio: regmap: remove gpiochip before tearing down irqchip
2026-11-27 14:52 [RFT PATCH v2 00/14] gpio: regmap: IRQ domain cleanups Michael Walle
2026-11-27 14:52 ` [RFT PATCH v2 01/14] gpio: regmap: use the correct number for .ngpio_per_reg Michael Walle
@ 2026-11-27 14:52 ` Michael Walle
2026-11-27 14:52 ` [RFT PATCH v2 03/14] gpio: regmap: add callbacks to handle IRQ domains Michael Walle
` (11 subsequent siblings)
13 siblings, 0 replies; 21+ messages in thread
From: Michael Walle @ 2026-11-27 14:52 UTC (permalink / raw)
To: William Breathitt Gray, Linus Walleij, Bartosz Golaszewski,
Petar Stepanovic, SriNavmani A, Prasad Bolisetty, Tzu-Hao Wei,
Karthikeyan Mitran, Mathieu Dubois-Briand, Michael Walle,
Lee Jones, Andy Shevchenko, Long Zhao, Joseph Telaak
Cc: linux-gpio, linux-arm-kernel
From: Long Zhao <longzhao@ambarella.com>
gpiochip_remove() calls acpi_gpiochip_free_interrupts() and
gpiod_free_irqs(). Both still need the irq domain.
regmap_del_irq_chip() removes that domain, so remove the
gpiochip first.
Fixes: 553b75d4bfe9 ("gpio: regmap: Allow to allocate regmap-irq device")
Signed-off-by: Long Zhao <longzhao@ambarella.com>
Signed-off-by: Michael Walle <mwalle@kernel.org>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/gpio/gpio-regmap.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/drivers/gpio/gpio-regmap.c b/drivers/gpio/gpio-regmap.c
index 65e87177baf0..c04b79da5cdb 100644
--- a/drivers/gpio/gpio-regmap.c
+++ b/drivers/gpio/gpio-regmap.c
@@ -593,12 +593,19 @@ EXPORT_SYMBOL_GPL(gpio_regmap_register);
*/
void gpio_regmap_unregister(struct gpio_regmap *gpio)
{
+ /*
+ * gpiochip_remove() runs acpi_gpiochip_free_interrupts() and
+ * gpiod_free_irqs(). Both still need the irq domain.
+ * regmap_del_irq_chip() removes that domain, so remove the
+ * gpiochip first.
+ */
+ gpiochip_remove(&gpio->gpio_chip);
+
#ifdef CONFIG_REGMAP_IRQ
if (gpio->irq_chip_data)
regmap_del_irq_chip(gpio->regmap_irq_line, gpio->irq_chip_data);
#endif
- gpiochip_remove(&gpio->gpio_chip);
bitmap_free(gpio->fixed_direction_output);
bitmap_free(gpio->fixed_direction_mask);
kfree(gpio);
--
2.47.3
^ permalink raw reply related [flat|nested] 21+ messages in thread* [RFT PATCH v2 03/14] gpio: regmap: add callbacks to handle IRQ domains
2026-11-27 14:52 [RFT PATCH v2 00/14] gpio: regmap: IRQ domain cleanups Michael Walle
2026-11-27 14:52 ` [RFT PATCH v2 01/14] gpio: regmap: use the correct number for .ngpio_per_reg Michael Walle
2026-11-27 14:52 ` [RFT PATCH v2 02/14] gpio: regmap: remove gpiochip before tearing down irqchip Michael Walle
@ 2026-11-27 14:52 ` Michael Walle
2026-11-27 17:27 ` Andy Shevchenko
2026-11-27 14:52 ` [RFT PATCH v2 04/14] gpio: rtd1625: create the IRQ domain from the gpio-regmap callback Michael Walle
` (10 subsequent siblings)
13 siblings, 1 reply; 21+ messages in thread
From: Michael Walle @ 2026-11-27 14:52 UTC (permalink / raw)
To: William Breathitt Gray, Linus Walleij, Bartosz Golaszewski,
Petar Stepanovic, SriNavmani A, Prasad Bolisetty, Tzu-Hao Wei,
Karthikeyan Mitran, Mathieu Dubois-Briand, Michael Walle,
Lee Jones, Andy Shevchenko, Long Zhao, Joseph Telaak
Cc: linux-gpio, linux-arm-kernel
At the moment, an IRQ domain is attached via config->irq_domain.
This means, that it has to be created before the gpio_regmap_register()
call. The callbacks of the IRQ domain might use the gpio_regmap_*_irq()
functions. Consumers can already use the domain as soon as it is
created and this creates a small window where the callbacks dereference
a NULL pointer.
To fix this, create a new create_irq_domain() callback, that is called
after the gpio_chip is added.
Also add a remove_irq_domain() callback, which is called after the
gpio_chip is removed and before the gpio_regmap is freed. It is supposed
to dispose the IRQ mappings and remove the domain.
Also ordering of the resources matter, so we forbid any device managed
resource handling. Any resources allocated in the create_irq_domain()
callback has to be freed manually in the remove_irq_domain() callback.
Signed-off-by: Michael Walle <mwalle@kernel.org>
Tested-by: Joseph Telaak <joseph@telaak.dev>
---
drivers/gpio/gpio-regmap.c | 30 ++++++++++++++++++++++++++++--
include/linux/gpio/regmap.h | 15 ++++++++++++++-
2 files changed, 42 insertions(+), 3 deletions(-)
diff --git a/drivers/gpio/gpio-regmap.c b/drivers/gpio/gpio-regmap.c
index c04b79da5cdb..061d2800d0a0 100644
--- a/drivers/gpio/gpio-regmap.c
+++ b/drivers/gpio/gpio-regmap.c
@@ -39,6 +39,8 @@ struct gpio_regmap {
unsigned long *fixed_direction_mask;
unsigned long *fixed_direction_output;
+ void (*remove_irq_domain)(struct gpio_regmap *gpio);
+
#ifdef CONFIG_REGMAP_IRQ
int regmap_irq_line;
struct regmap_irq_chip_data *irq_chip_data;
@@ -454,6 +456,14 @@ struct gpio_regmap *gpio_regmap_register(const struct gpio_regmap_config *config
if (config->reg_dir_out_base && config->reg_dir_in_base)
return ERR_PTR(-EINVAL);
+ /* there is only one way to provide an IRQ domain */
+ if (config->create_irq_domain && config->irq_domain)
+ return ERR_PTR(-EINVAL);
+#ifdef CONFIG_REGMAP_IRQ
+ if (config->create_irq_domain && config->regmap_irq_chip)
+ return ERR_PTR(-EINVAL);
+#endif
+
gpio = kzalloc_obj(*gpio);
if (!gpio)
return ERR_PTR(-ENOMEM);
@@ -545,6 +555,17 @@ struct gpio_regmap *gpio_regmap_register(const struct gpio_regmap_config *config
if (ret < 0)
goto err_free_bitmap_output;
+ irq_domain = config->irq_domain;
+
+ if (config->create_irq_domain) {
+ irq_domain = config->create_irq_domain(gpio);
+ if (IS_ERR(irq_domain)) {
+ ret = PTR_ERR(irq_domain);
+ goto err_remove_gpiochip;
+ }
+ gpio->remove_irq_domain = config->remove_irq_domain;
+ }
+
#ifdef CONFIG_REGMAP_IRQ
if (config->regmap_irq_chip) {
gpio->regmap_irq_line = config->regmap_irq_line;
@@ -558,9 +579,8 @@ struct gpio_regmap *gpio_regmap_register(const struct gpio_regmap_config *config
goto err_remove_gpiochip;
irq_domain = regmap_irq_get_domain(gpio->irq_chip_data);
- } else
+ }
#endif
- irq_domain = config->irq_domain;
if (irq_domain) {
ret = gpiochip_irqchip_add_domain(chip, irq_domain);
@@ -573,6 +593,9 @@ struct gpio_regmap *gpio_regmap_register(const struct gpio_regmap_config *config
err_remove_gpiochip:
gpiochip_remove(chip);
+ if (gpio->remove_irq_domain)
+ gpio->remove_irq_domain(gpio);
+
#ifdef CONFIG_REGMAP_IRQ
if (gpio->irq_chip_data)
regmap_del_irq_chip(gpio->regmap_irq_line, gpio->irq_chip_data);
@@ -601,6 +624,9 @@ void gpio_regmap_unregister(struct gpio_regmap *gpio)
*/
gpiochip_remove(&gpio->gpio_chip);
+ if (gpio->remove_irq_domain)
+ gpio->remove_irq_domain(gpio);
+
#ifdef CONFIG_REGMAP_IRQ
if (gpio->irq_chip_data)
regmap_del_irq_chip(gpio->regmap_irq_line, gpio->irq_chip_data);
diff --git a/include/linux/gpio/regmap.h b/include/linux/gpio/regmap.h
index 6fe0877717cb..dee5f8d2c48c 100644
--- a/include/linux/gpio/regmap.h
+++ b/include/linux/gpio/regmap.h
@@ -62,7 +62,18 @@ enum gpio_regmap_operation {
* same type, dat, set, etc) are not consecutive.
* @ngpio_per_reg: (Optional) Number of GPIOs per register
* @irq_domain: (Optional) IRQ domain if the controller is
- * interrupt-capable
+ * interrupt-capable. Cannot be used together with the
+ * gpio_regmap_*_irq() callbacks. Use @create_irq_domain
+ * instead.
+ * @create_irq_domain: (Optional) Callback to create the IRQ domain in the
+ * controller driver. Called after the gpio_chip is added
+ * so the gpio_regmap_*_irq() have a valid gpio_regmap
+ * pointer. Do NOT use any resource managed allocations in
+ * this callback.
+ * Mutually exclusive with @irq_domain and @regmap_irq_chip.
+ * @remove_irq_domain: (Optional) Callback to remove the IRQ domain created in
+ * the .create_irq_domain() callback. Dispose any IRQ
+ * mappings, remove the IRQ domain and free any resources.
* @fixed_direction_mask:
* (Optional) Bitmap representing the GPIO lines that
* make use of the @fixed_direction_output list to
@@ -133,6 +144,8 @@ struct gpio_regmap_config {
int reg_stride;
int ngpio_per_reg;
struct irq_domain *irq_domain;
+ struct irq_domain *(*create_irq_domain)(struct gpio_regmap *gpio);
+ void (*remove_irq_domain)(struct gpio_regmap *gpio);
unsigned long *fixed_direction_mask;
unsigned long *fixed_direction_output;
--
2.47.3
^ permalink raw reply related [flat|nested] 21+ messages in thread* Re: [RFT PATCH v2 03/14] gpio: regmap: add callbacks to handle IRQ domains
2026-11-27 14:52 ` [RFT PATCH v2 03/14] gpio: regmap: add callbacks to handle IRQ domains Michael Walle
@ 2026-11-27 17:27 ` Andy Shevchenko
0 siblings, 0 replies; 21+ messages in thread
From: Andy Shevchenko @ 2026-11-27 17:27 UTC (permalink / raw)
To: Michael Walle
Cc: William Breathitt Gray, Linus Walleij, Bartosz Golaszewski,
Petar Stepanovic, SriNavmani A, Prasad Bolisetty, Tzu-Hao Wei,
Karthikeyan Mitran, Mathieu Dubois-Briand, Lee Jones, Long Zhao,
Joseph Telaak, linux-gpio, linux-arm-kernel
On Fri, Nov 27, 2026 at 03:52:20PM +0100, Michael Walle wrote:
> At the moment, an IRQ domain is attached via config->irq_domain.
> This means, that it has to be created before the gpio_regmap_register()
> call. The callbacks of the IRQ domain might use the gpio_regmap_*_irq()
> functions. Consumers can already use the domain as soon as it is
> created and this creates a small window where the callbacks dereference
> a NULL pointer.
>
> To fix this, create a new create_irq_domain() callback, that is called
> after the gpio_chip is added.
>
> Also add a remove_irq_domain() callback, which is called after the
> gpio_chip is removed and before the gpio_regmap is freed. It is supposed
> to dispose the IRQ mappings and remove the domain.
>
> Also ordering of the resources matter, so we forbid any device managed
> resource handling. Any resources allocated in the create_irq_domain()
> callback has to be freed manually in the remove_irq_domain() callback.
...
> unsigned long *fixed_direction_mask;
> unsigned long *fixed_direction_output;
Perhaps a short comment why create_irq_domain is not here?
> + void (*remove_irq_domain)(struct gpio_regmap *gpio);
...
> + irq_domain = config->irq_domain;
> +
> + if (config->create_irq_domain) {
> + irq_domain = config->create_irq_domain(gpio);
> + if (IS_ERR(irq_domain)) {
> + ret = PTR_ERR(irq_domain);
> + goto err_remove_gpiochip;
> + }
ret = PTR_ERR_OR_ZERO(...);
if (ret)
goto ...;
> + gpio->remove_irq_domain = config->remove_irq_domain;
> + }
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 21+ messages in thread
* [RFT PATCH v2 04/14] gpio: rtd1625: create the IRQ domain from the gpio-regmap callback
2026-11-27 14:52 [RFT PATCH v2 00/14] gpio: regmap: IRQ domain cleanups Michael Walle
` (2 preceding siblings ...)
2026-11-27 14:52 ` [RFT PATCH v2 03/14] gpio: regmap: add callbacks to handle IRQ domains Michael Walle
@ 2026-11-27 14:52 ` Michael Walle
2026-11-27 18:30 ` Andy Shevchenko
2026-11-27 14:52 ` [RFT PATCH v2 05/14] gpio: axiado-sgpio: " Michael Walle
` (9 subsequent siblings)
13 siblings, 1 reply; 21+ messages in thread
From: Michael Walle @ 2026-11-27 14:52 UTC (permalink / raw)
To: William Breathitt Gray, Linus Walleij, Bartosz Golaszewski,
Petar Stepanovic, SriNavmani A, Prasad Bolisetty, Tzu-Hao Wei,
Karthikeyan Mitran, Mathieu Dubois-Briand, Michael Walle,
Lee Jones, Andy Shevchenko, Long Zhao, Joseph Telaak
Cc: linux-gpio, linux-arm-kernel
Use the new .create_irq_domain() to actually create the domain. This
way, there is no window where a NULL pointer could be dereferenced.
Switch the irq host_data to the gpio_regmap pointer because it will
already be needed in the irq domain callbacks. Otherwise the
.create_irq_domain() callback would have to set the data->gpio_reg
pointer which looks odd.
Split the interrupt handling into two steps: first fill in the
interrupts and in the callback attach the handler.
Don't use device managed resources anymore. Instead use the new
.remove_irq_domain() callback. The driver didn't dispose any of the IRQ
mappings before, although irq_domain_remove() mandates that. Thus add
that to this callback, too.
Fixes: 6435d21cbd42 ("gpio: realtek: Add driver for Realtek DHC RTD1625 SoC")
Signed-off-by: Michael Walle <mwalle@kernel.org>
---
drivers/gpio/gpio-rtd1625.c | 91 ++++++++++++++++++++++++-------------
1 file changed, 60 insertions(+), 31 deletions(-)
diff --git a/drivers/gpio/gpio-rtd1625.c b/drivers/gpio/gpio-rtd1625.c
index cf4f61603dfb..20ec4182725d 100644
--- a/drivers/gpio/gpio-rtd1625.c
+++ b/drivers/gpio/gpio-rtd1625.c
@@ -79,7 +79,6 @@ struct rtd1625_gpio_info {
};
struct rtd1625_gpio {
- struct gpio_regmap *gpio_reg;
const struct rtd1625_gpio_info *info;
struct regmap *regmap;
unsigned int irqs[RTD1625_MAX_IRQS];
@@ -290,7 +289,7 @@ static void rtd1625_gpio_irq_handle(struct irq_desc *desc)
static void rtd1625_gpio_ack_irq(struct irq_data *d)
{
- struct rtd1625_gpio *data = irq_data_get_irq_chip_data(d);
+ struct rtd1625_gpio *data = gpio_regmap_get_drvdata(irq_data_get_irq_chip_data(d));
irq_hw_number_t hwirq = irqd_to_hwirq(d);
u32 irq_type = irqd_get_trigger_type(d);
u32 bit_mask = BIT(hwirq % 32);
@@ -352,11 +351,12 @@ static void rtd1625_gpio_disable_level_irq(struct rtd1625_gpio *data, irq_hw_num
static void rtd1625_gpio_enable_irq(struct irq_data *d)
{
- struct rtd1625_gpio *data = irq_data_get_irq_chip_data(d);
+ struct gpio_regmap *gpio_reg = irq_data_get_irq_chip_data(d);
+ struct rtd1625_gpio *data = gpio_regmap_get_drvdata(gpio_reg);
irq_hw_number_t hwirq = irqd_to_hwirq(d);
u32 irq_type = irqd_get_trigger_type(d);
- gpio_regmap_enable_irq(data->gpio_reg, hwirq);
+ gpio_regmap_enable_irq(gpio_reg, hwirq);
if (irq_type & IRQ_TYPE_EDGE_BOTH)
rtd1625_gpio_enable_edge_irq(data, hwirq);
@@ -366,7 +366,8 @@ static void rtd1625_gpio_enable_irq(struct irq_data *d)
static void rtd1625_gpio_disable_irq(struct irq_data *d)
{
- struct rtd1625_gpio *data = irq_data_get_irq_chip_data(d);
+ struct gpio_regmap *gpio_reg = irq_data_get_irq_chip_data(d);
+ struct rtd1625_gpio *data = gpio_regmap_get_drvdata(gpio_reg);
irq_hw_number_t hwirq = irqd_to_hwirq(d);
u32 irq_type = irqd_get_trigger_type(d);
@@ -375,7 +376,7 @@ static void rtd1625_gpio_disable_irq(struct irq_data *d)
else if (irq_type & IRQ_TYPE_LEVEL_MASK)
rtd1625_gpio_disable_level_irq(data, hwirq);
- gpio_regmap_disable_irq(data->gpio_reg, hwirq);
+ gpio_regmap_disable_irq(gpio_reg, hwirq);
}
static int rtd1625_gpio_irq_set_level_type(struct irq_data *d, bool level)
@@ -385,7 +386,7 @@ static int rtd1625_gpio_irq_set_level_type(struct irq_data *d, bool level)
struct rtd1625_gpio *data;
int ret;
- data = irq_data_get_irq_chip_data(d);
+ data = gpio_regmap_get_drvdata(irq_data_get_irq_chip_data(d));
if (!(data->info->irq_type_support & IRQ_TYPE_LEVEL_MASK))
return -EINVAL;
@@ -406,7 +407,7 @@ static int rtd1625_gpio_irq_set_level_type(struct irq_data *d, bool level)
static int rtd1625_gpio_irq_set_edge_type(struct irq_data *d, bool polarity)
{
- struct rtd1625_gpio *data = irq_data_get_irq_chip_data(d);
+ struct rtd1625_gpio *data = gpio_regmap_get_drvdata(irq_data_get_irq_chip_data(d));
u32 val = RTD1625_GPIO_WREN(RTD1625_GPIO_EDGE_INT_DP);
irq_hw_number_t hwirq = irqd_to_hwirq(d);
int ret;
@@ -454,16 +455,16 @@ static int rtd1625_gpio_irq_set_type(struct irq_data *d, unsigned int type)
static int rtd1625_gpio_irq_request_resources(struct irq_data *d)
{
- struct rtd1625_gpio *data = irq_data_get_irq_chip_data(d);
+ struct gpio_regmap *gpio_reg = irq_data_get_irq_chip_data(d);
- return gpio_regmap_reqres_irq(data->gpio_reg, d->hwirq);
+ return gpio_regmap_reqres_irq(gpio_reg, d->hwirq);
}
static void rtd1625_gpio_irq_release_resources(struct irq_data *d)
{
- struct rtd1625_gpio *data = irq_data_get_irq_chip_data(d);
+ struct gpio_regmap *gpio_reg = irq_data_get_irq_chip_data(d);
- gpio_regmap_relres_irq(data->gpio_reg, d->hwirq);
+ gpio_regmap_relres_irq(gpio_reg, d->hwirq);
}
static struct irq_chip rtd1625_iso_gpio_irq_chip = {
@@ -477,7 +478,7 @@ static struct irq_chip rtd1625_iso_gpio_irq_chip = {
.irq_release_resources = rtd1625_gpio_irq_release_resources,
};
-static int rtd1625_gpio_setup_irq(struct platform_device *pdev, struct rtd1625_gpio *data)
+static int rtd1625_gpio_get_irqs(struct platform_device *pdev, struct rtd1625_gpio *data)
{
unsigned int num_irqs;
int irq;
@@ -496,7 +497,6 @@ static int rtd1625_gpio_setup_irq(struct platform_device *pdev, struct rtd1625_g
return irq;
data->irqs[i] = irq;
- irq_set_chained_handler_and_data(data->irqs[i], rtd1625_gpio_irq_handle, data);
}
return 0;
@@ -505,9 +505,9 @@ static int rtd1625_gpio_setup_irq(struct platform_device *pdev, struct rtd1625_g
static int rtd1625_gpio_irq_map(struct irq_domain *domain, unsigned int irq,
irq_hw_number_t hwirq)
{
- struct rtd1625_gpio *data = domain->host_data;
+ struct gpio_regmap *gpio_reg = domain->host_data;
- irq_set_chip_data(irq, data);
+ irq_set_chip_data(irq, gpio_reg);
irq_set_chip_and_handler(irq, &rtd1625_iso_gpio_irq_chip, handle_bad_irq);
@@ -524,6 +524,47 @@ static const struct irq_domain_ops rtd1625_gpio_irq_domain_ops = {
.xlate = irq_domain_xlate_twocell,
};
+static struct irq_domain *rtd1625_gpio_create_irq_domain(struct gpio_regmap *gpio_reg)
+{
+ struct rtd1625_gpio *data = gpio_regmap_get_drvdata(gpio_reg);
+ struct device *dev = regmap_get_device(data->regmap);
+ struct irq_domain_info d_info = {};
+
+ d_info.fwnode = dev_fwnode(dev);
+ d_info.size = data->info->num_gpios;
+ d_info.hwirq_max = data->info->num_gpios;
+ d_info.ops = &rtd1625_gpio_irq_domain_ops;
+ d_info.host_data = gpio_reg;
+
+ data->domain = irq_domain_instantiate(&d_info);
+ if (IS_ERR(data->domain))
+ return data->domain;
+
+ for (unsigned int i = 0; i < RTD1625_MAX_IRQS; i++) {
+ if (data->irqs[i])
+ irq_set_chained_handler_and_data(data->irqs[i],
+ rtd1625_gpio_irq_handle,
+ data);
+ }
+
+ return data->domain;
+}
+
+static void rtd1625_gpio_remove_irq_domain(struct gpio_regmap *gpio_reg)
+{
+ struct rtd1625_gpio *data = gpio_regmap_get_drvdata(gpio_reg);
+
+ for (unsigned int i = 0; i < RTD1625_MAX_IRQS; i++) {
+ if (data->irqs[i])
+ irq_set_chained_handler_and_data(data->irqs[i], NULL, NULL);
+ }
+
+ for (irq_hw_number_t hwirq = 0; hwirq < data->info->num_gpios; hwirq++)
+ irq_dispose_mapping(irq_find_mapping(data->domain, hwirq));
+
+ irq_domain_remove(data->domain);
+}
+
static const struct regmap_config rtd1625_gpio_regmap_config = {
.reg_bits = 32,
.reg_stride = 4,
@@ -536,7 +577,6 @@ static const struct regmap_config rtd1625_gpio_regmap_config = {
static int rtd1625_gpio_probe(struct platform_device *pdev)
{
struct gpio_regmap_config config = {};
- struct irq_domain_info d_info = {};
struct device *dev = &pdev->dev;
struct gpio_regmap *gpio_reg;
struct rtd1625_gpio *data;
@@ -578,29 +618,18 @@ static int rtd1625_gpio_probe(struct platform_device *pdev)
config.set_config = rtd1625_gpio_set_config;
config.value_xlate = rtd1625_value_xlate;
- d_info.fwnode = dev_fwnode(&pdev->dev);
- d_info.size = data->info->num_gpios;
- d_info.hwirq_max = data->info->num_gpios;
- d_info.ops = &rtd1625_gpio_irq_domain_ops;
- d_info.host_data = data;
-
- data->domain = devm_irq_domain_instantiate(dev, &d_info);
- if (IS_ERR(data->domain))
- return PTR_ERR(data->domain);
-
- ret = rtd1625_gpio_setup_irq(pdev, data);
+ ret = rtd1625_gpio_get_irqs(pdev, data);
if (ret)
return ret;
- config.irq_domain = data->domain;
config.drvdata = data;
+ config.create_irq_domain = rtd1625_gpio_create_irq_domain;
+ config.remove_irq_domain = rtd1625_gpio_remove_irq_domain;
gpio_reg = devm_gpio_regmap_register(dev, &config);
if (IS_ERR(gpio_reg))
return PTR_ERR(gpio_reg);
- data->gpio_reg = gpio_reg;
-
return 0;
}
--
2.47.3
^ permalink raw reply related [flat|nested] 21+ messages in thread* Re: [RFT PATCH v2 04/14] gpio: rtd1625: create the IRQ domain from the gpio-regmap callback
2026-11-27 14:52 ` [RFT PATCH v2 04/14] gpio: rtd1625: create the IRQ domain from the gpio-regmap callback Michael Walle
@ 2026-11-27 18:30 ` Andy Shevchenko
0 siblings, 0 replies; 21+ messages in thread
From: Andy Shevchenko @ 2026-11-27 18:30 UTC (permalink / raw)
To: Michael Walle
Cc: William Breathitt Gray, Linus Walleij, Bartosz Golaszewski,
Petar Stepanovic, SriNavmani A, Prasad Bolisetty, Tzu-Hao Wei,
Karthikeyan Mitran, Mathieu Dubois-Briand, Lee Jones, Long Zhao,
Joseph Telaak, linux-gpio, linux-arm-kernel
On Fri, Nov 27, 2026 at 03:52:21PM +0100, Michael Walle wrote:
> Use the new .create_irq_domain() to actually create the domain. This
> way, there is no window where a NULL pointer could be dereferenced.
>
> Switch the irq host_data to the gpio_regmap pointer because it will
> already be needed in the irq domain callbacks. Otherwise the
> .create_irq_domain() callback would have to set the data->gpio_reg
> pointer which looks odd.
>
> Split the interrupt handling into two steps: first fill in the
> interrupts and in the callback attach the handler.
>
> Don't use device managed resources anymore. Instead use the new
> .remove_irq_domain() callback. The driver didn't dispose any of the IRQ
> mappings before, although irq_domain_remove() mandates that. Thus add
> that to this callback, too.
...
> +static struct irq_domain *rtd1625_gpio_create_irq_domain(struct gpio_regmap *gpio_reg)
> +{
> + struct rtd1625_gpio *data = gpio_regmap_get_drvdata(gpio_reg);
> + struct device *dev = regmap_get_device(data->regmap);
> + struct irq_domain_info d_info = {};
> +
> + d_info.fwnode = dev_fwnode(dev);
> + d_info.size = data->info->num_gpios;
> + d_info.hwirq_max = data->info->num_gpios;
> + d_info.ops = &rtd1625_gpio_irq_domain_ops;
> + d_info.host_data = gpio_reg;
> +
> + data->domain = irq_domain_instantiate(&d_info);
> + if (IS_ERR(data->domain))
> + return data->domain;
This is open coded irq_domain_create_linear(). The only difference is that we
propagate the underneath error code instead of decoding NULL as ENOMEM or
EINVAL or something like that. If this is the case, add a comment explaining
why, otherwise somebody will change that in the future w/o much thinking.
Note, it was open coded since there is no devm_*() helper for that.
> + for (unsigned int i = 0; i < RTD1625_MAX_IRQS; i++) {
> + if (data->irqs[i])
> + irq_set_chained_handler_and_data(data->irqs[i],
> + rtd1625_gpio_irq_handle,
> + data);
> + }
> +
> + return data->domain;
> +}
...
> +static void rtd1625_gpio_remove_irq_domain(struct gpio_regmap *gpio_reg)
> +{
> + struct rtd1625_gpio *data = gpio_regmap_get_drvdata(gpio_reg);
> +
> + for (unsigned int i = 0; i < RTD1625_MAX_IRQS; i++) {
> + if (data->irqs[i])
Do you need this? It seems to me that irq_to_desc() returns NULL
and scoped_irqdesc_get_and_buslock() does nothing. Yes, I know
it's a tricky code.
> + irq_set_chained_handler_and_data(data->irqs[i], NULL, NULL);
> + }
> +
> + for (irq_hw_number_t hwirq = 0; hwirq < data->info->num_gpios; hwirq++)
> + irq_dispose_mapping(irq_find_mapping(data->domain, hwirq));
> +
> + irq_domain_remove(data->domain);
> +}
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 21+ messages in thread
* [RFT PATCH v2 05/14] gpio: axiado-sgpio: create the IRQ domain from the gpio-regmap callback
2026-11-27 14:52 [RFT PATCH v2 00/14] gpio: regmap: IRQ domain cleanups Michael Walle
` (3 preceding siblings ...)
2026-11-27 14:52 ` [RFT PATCH v2 04/14] gpio: rtd1625: create the IRQ domain from the gpio-regmap callback Michael Walle
@ 2026-11-27 14:52 ` Michael Walle
2026-11-27 18:35 ` Andy Shevchenko
2026-11-27 14:52 ` [RFT PATCH v2 06/14] gpio: regmap: add helpers to add a regmap-irq chip Michael Walle
` (8 subsequent siblings)
13 siblings, 1 reply; 21+ messages in thread
From: Michael Walle @ 2026-11-27 14:52 UTC (permalink / raw)
To: William Breathitt Gray, Linus Walleij, Bartosz Golaszewski,
Petar Stepanovic, SriNavmani A, Prasad Bolisetty, Tzu-Hao Wei,
Karthikeyan Mitran, Mathieu Dubois-Briand, Michael Walle,
Lee Jones, Andy Shevchenko, Long Zhao, Joseph Telaak
Cc: linux-gpio, linux-arm-kernel
Use the new .create_irq_domain() to actually create the domain. This
way, there is no window where a NULL pointer could be dereferenced in
the irq callbacks.
Switch the irq host_data to the gpio_regmap pointer because it will
already be needed in the irq domain callbacks. Otherwise, the
.create_irq_domain() callback would have to set the sgpio->gpio pointer
which looks odd.
Don't use device managed resources anymore. Instead use the new
.remove_irq_domain() callback. The driver didn't dispose any of the IRQ
mappings before, although irq_domain_remove() mandates that. Thus add
that to this callback, too.
Fixes: dd36a4b7f391 ("gpio: axiado: add AX3005 SGPIO controller support")
Signed-off-by: Michael Walle <mwalle@kernel.org>
---
drivers/gpio/gpio-axiado-sgpio.c | 75 ++++++++++++++++++++------------
1 file changed, 48 insertions(+), 27 deletions(-)
diff --git a/drivers/gpio/gpio-axiado-sgpio.c b/drivers/gpio/gpio-axiado-sgpio.c
index 3af222b718e6..a18e46bddb95 100644
--- a/drivers/gpio/gpio-axiado-sgpio.c
+++ b/drivers/gpio/gpio-axiado-sgpio.c
@@ -155,7 +155,6 @@ struct axiado_sgpio {
u32 nsignals;
u32 din_bank_shift;
unsigned long *dir_out;
- struct gpio_regmap *gpio;
struct irq_domain *domain;
struct regmap *regmap;
const struct axiado_sgpio_reg_offsets *regs;
@@ -376,7 +375,7 @@ static void axiado_sgpio_disable(void *data)
static int axiado_sgpio_set_irq_type(struct irq_data *d, unsigned int type)
{
- struct axiado_sgpio *sgpio = irq_data_get_irq_chip_data(d);
+ struct axiado_sgpio *sgpio = gpio_regmap_get_drvdata(irq_data_get_irq_chip_data(d));
irq_hw_number_t hwirq = irqd_to_hwirq(d);
unsigned int position;
@@ -407,34 +406,36 @@ static int axiado_sgpio_set_irq_type(struct irq_data *d, unsigned int type)
static void axiado_sgpio_mask_irq(struct irq_data *d)
{
- struct axiado_sgpio *sgpio = irq_data_get_irq_chip_data(d);
+ struct gpio_regmap *gpio = irq_data_get_irq_chip_data(d);
+ struct axiado_sgpio *sgpio = gpio_regmap_get_drvdata(gpio);
irq_hw_number_t hwirq = irqd_to_hwirq(d);
clear_bit(hwirq / 2, sgpio->irq_unmasked);
- gpio_regmap_disable_irq(sgpio->gpio, hwirq);
+ gpio_regmap_disable_irq(gpio, hwirq);
}
static void axiado_sgpio_unmask_irq(struct irq_data *d)
{
- struct axiado_sgpio *sgpio = irq_data_get_irq_chip_data(d);
+ struct gpio_regmap *gpio = irq_data_get_irq_chip_data(d);
+ struct axiado_sgpio *sgpio = gpio_regmap_get_drvdata(gpio);
irq_hw_number_t hwirq = irqd_to_hwirq(d);
- gpio_regmap_enable_irq(sgpio->gpio, hwirq);
+ gpio_regmap_enable_irq(gpio, hwirq);
set_bit(hwirq / 2, sgpio->irq_unmasked);
}
static int axiado_sgpio_irq_request_resources(struct irq_data *d)
{
- struct axiado_sgpio *sgpio = irq_data_get_irq_chip_data(d);
+ struct gpio_regmap *gpio = irq_data_get_irq_chip_data(d);
- return gpio_regmap_reqres_irq(sgpio->gpio, d->hwirq);
+ return gpio_regmap_reqres_irq(gpio, d->hwirq);
}
static void axiado_sgpio_irq_release_resources(struct irq_data *d)
{
- struct axiado_sgpio *sgpio = irq_data_get_irq_chip_data(d);
+ struct gpio_regmap *gpio = irq_data_get_irq_chip_data(d);
- gpio_regmap_relres_irq(sgpio->gpio, d->hwirq);
+ gpio_regmap_relres_irq(gpio, d->hwirq);
}
static const struct irq_chip axiado_sgpio_irqchip = {
@@ -450,13 +451,13 @@ static const struct irq_chip axiado_sgpio_irqchip = {
static int axiado_sgpio_irq_map(struct irq_domain *domain, unsigned int virq,
irq_hw_number_t hwirq)
{
- struct axiado_sgpio *sgpio = domain->host_data;
+ struct gpio_regmap *gpio = domain->host_data;
/* Only even offsets represent input GPIOs. */
if (hwirq % 2)
return -EINVAL;
- irq_set_chip_data(virq, sgpio);
+ irq_set_chip_data(virq, gpio);
irq_set_lockdep_class(virq, &axiado_sgpio_irq_lock_class,
&axiado_sgpio_irq_request_class);
irq_set_chip_and_handler(virq, &axiado_sgpio_irqchip, handle_simple_irq);
@@ -471,6 +472,35 @@ static const struct irq_domain_ops axiado_sgpio_domain_ops = {
.xlate = irq_domain_xlate_twocell,
};
+static struct irq_domain *axiado_sgpio_create_irq_domain(struct gpio_regmap *gpio)
+{
+ struct axiado_sgpio *sgpio = gpio_regmap_get_drvdata(gpio);
+ struct device *dev = regmap_get_device(sgpio->regmap);
+ struct platform_device *pdev = to_platform_device(dev);
+ unsigned int ngpio = sgpio->nsignals * 2;
+ struct irq_domain_info d_info = { };
+
+ d_info.fwnode = dev_fwnode(&pdev->dev);
+ d_info.size = ngpio;
+ d_info.hwirq_max = ngpio;
+ d_info.ops = &axiado_sgpio_domain_ops;
+ d_info.host_data = gpio;
+
+ sgpio->domain = irq_domain_instantiate(&d_info);
+
+ return sgpio->domain;
+}
+
+static void axiado_sgpio_remove_irq_domain(struct gpio_regmap *gpio)
+{
+ struct axiado_sgpio *sgpio = gpio_regmap_get_drvdata(gpio);
+
+ for (irq_hw_number_t hwirq = 0; hwirq < sgpio->nsignals * 2; hwirq++)
+ irq_dispose_mapping(irq_find_mapping(sgpio->domain, hwirq));
+
+ irq_domain_remove(sgpio->domain);
+}
+
static int axiado_sgpio_init_input_cache(struct axiado_sgpio *sgpio)
{
unsigned int num_banks = DIV_ROUND_UP(sgpio->nsignals,
@@ -548,8 +578,8 @@ static const struct regmap_config axiado_sgpio_regmap_config = {
static int axiado_sgpio_probe(struct platform_device *pdev)
{
struct gpio_regmap_config config = { };
- struct irq_domain_info d_info = { };
struct axiado_sgpio *sgpio;
+ struct gpio_regmap *gpio;
unsigned int ngpio, i;
unsigned long apb_freq;
struct clk *apb_clk;
@@ -658,16 +688,6 @@ static int axiado_sgpio_probe(struct platform_device *pdev)
for (i = 1; i < ngpio; i += 2)
__set_bit(i, sgpio->dir_out);
- d_info.fwnode = dev_fwnode(&pdev->dev);
- d_info.size = ngpio;
- d_info.hwirq_max = ngpio;
- d_info.ops = &axiado_sgpio_domain_ops;
- d_info.host_data = sgpio;
-
- sgpio->domain = devm_irq_domain_instantiate(&pdev->dev, &d_info);
- if (IS_ERR(sgpio->domain))
- return PTR_ERR(sgpio->domain);
-
config.parent = &pdev->dev;
config.regmap = sgpio->regmap;
config.ngpio = ngpio;
@@ -675,12 +695,13 @@ static int axiado_sgpio_probe(struct platform_device *pdev)
config.reg_set_base = GPIO_REGMAP_ADDR(sgpio->regs->dout_ss);
config.reg_mask_xlate = axiado_sgpio_reg_mask_xlate;
config.fixed_direction_output = sgpio->dir_out;
- config.irq_domain = sgpio->domain;
config.drvdata = sgpio;
+ config.create_irq_domain = axiado_sgpio_create_irq_domain;
+ config.remove_irq_domain = axiado_sgpio_remove_irq_domain;
- sgpio->gpio = devm_gpio_regmap_register(&pdev->dev, &config);
- if (IS_ERR(sgpio->gpio))
- return dev_err_probe(&pdev->dev, PTR_ERR(sgpio->gpio),
+ gpio = devm_gpio_regmap_register(&pdev->dev, &config);
+ if (IS_ERR(gpio))
+ return dev_err_probe(&pdev->dev, PTR_ERR(gpio),
"Could not register gpiochip\n");
irq = platform_get_irq(pdev, 0);
--
2.47.3
^ permalink raw reply related [flat|nested] 21+ messages in thread* Re: [RFT PATCH v2 05/14] gpio: axiado-sgpio: create the IRQ domain from the gpio-regmap callback
2026-11-27 14:52 ` [RFT PATCH v2 05/14] gpio: axiado-sgpio: " Michael Walle
@ 2026-11-27 18:35 ` Andy Shevchenko
0 siblings, 0 replies; 21+ messages in thread
From: Andy Shevchenko @ 2026-11-27 18:35 UTC (permalink / raw)
To: Michael Walle
Cc: William Breathitt Gray, Linus Walleij, Bartosz Golaszewski,
Petar Stepanovic, SriNavmani A, Prasad Bolisetty, Tzu-Hao Wei,
Karthikeyan Mitran, Mathieu Dubois-Briand, Lee Jones, Long Zhao,
Joseph Telaak, linux-gpio, linux-arm-kernel
On Fri, Nov 27, 2026 at 03:52:22PM +0100, Michael Walle wrote:
> Use the new .create_irq_domain() to actually create the domain. This
> way, there is no window where a NULL pointer could be dereferenced in
> the irq callbacks.
>
> Switch the irq host_data to the gpio_regmap pointer because it will
> already be needed in the irq domain callbacks. Otherwise, the
> .create_irq_domain() callback would have to set the sgpio->gpio pointer
> which looks odd.
>
> Don't use device managed resources anymore. Instead use the new
> .remove_irq_domain() callback. The driver didn't dispose any of the IRQ
> mappings before, although irq_domain_remove() mandates that. Thus add
> that to this callback, too.
...
> +static struct irq_domain *axiado_sgpio_create_irq_domain(struct gpio_regmap *gpio)
> +{
> + struct axiado_sgpio *sgpio = gpio_regmap_get_drvdata(gpio);
> + struct device *dev = regmap_get_device(sgpio->regmap);
> + struct platform_device *pdev = to_platform_device(dev);
> + unsigned int ngpio = sgpio->nsignals * 2;
> + struct irq_domain_info d_info = { };
> +
> + d_info.fwnode = dev_fwnode(&pdev->dev);
> + d_info.size = ngpio;
> + d_info.hwirq_max = ngpio;
> + d_info.ops = &axiado_sgpio_domain_ops;
> + d_info.host_data = gpio;
> +
> + sgpio->domain = irq_domain_instantiate(&d_info);
Same comment here, because it was no devm_*() helper for linear IRQ mappings.
Not sure if we need to consider error pointer after all in each of the
callbacks. We can just check NULL versus not-NULL inside gpio-regmap core.
> + return sgpio->domain;
> +}
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 21+ messages in thread
* [RFT PATCH v2 06/14] gpio: regmap: add helpers to add a regmap-irq chip
2026-11-27 14:52 [RFT PATCH v2 00/14] gpio: regmap: IRQ domain cleanups Michael Walle
` (4 preceding siblings ...)
2026-11-27 14:52 ` [RFT PATCH v2 05/14] gpio: axiado-sgpio: " Michael Walle
@ 2026-11-27 14:52 ` Michael Walle
2026-11-27 18:43 ` Andy Shevchenko
2026-11-27 14:52 ` [RFT PATCH v2 07/14] gpio: max7360: create the regmap-irq chip from the gpio-regmap callback Michael Walle
` (7 subsequent siblings)
13 siblings, 1 reply; 21+ messages in thread
From: Michael Walle @ 2026-11-27 14:52 UTC (permalink / raw)
To: William Breathitt Gray, Linus Walleij, Bartosz Golaszewski,
Petar Stepanovic, SriNavmani A, Prasad Bolisetty, Tzu-Hao Wei,
Karthikeyan Mitran, Mathieu Dubois-Briand, Michael Walle,
Lee Jones, Andy Shevchenko, Long Zhao, Joseph Telaak
Cc: linux-gpio, linux-arm-kernel
The most common use-case is to use regmap-irq together with gpio-regmap.
To make life easier for that and to avoid code duplication, add helpers
to create and attach a regmap-irq domain. These helpers are intended to
be called by the new .create_irq_domain() callback.
gpio_regmap_add_irq_chip() locks the GPIO line while its interrupt is
requested. This assumes that the hwirq numbers match the GPIO offsets.
If a driver doesn't follow that, there is one without the locking called
gpio_regmap_add_irq_chip_nolock().
Signed-off-by: Michael Walle <mwalle@kernel.org>
---
drivers/gpio/gpio-regmap.c | 74 +++++++++++++++++++++++++++++++++++++
include/linux/gpio/regmap.h | 25 +++++++++++++
2 files changed, 99 insertions(+)
diff --git a/drivers/gpio/gpio-regmap.c b/drivers/gpio/gpio-regmap.c
index 061d2800d0a0..a0d99710dc4f 100644
--- a/drivers/gpio/gpio-regmap.c
+++ b/drivers/gpio/gpio-regmap.c
@@ -409,6 +409,80 @@ static void __maybe_unused gpio_regmap_irq_relres(void *irq_drv_data, irq_hw_num
gpio_regmap_relres_irq(irq_drv_data, hwirq);
}
+#ifdef CONFIG_REGMAP_IRQ
+/**
+ * gpio_regmap_add_irq_chip_nolock() - Add a regmap-irq chip without line locking
+ * @gpio: gpio_regmap device
+ * @irq: the parent interrupt
+ * @irq_flags: the IRQF_ flags to use for @irq
+ * @chip: the regmap-irq chip description
+ *
+ * Same as gpio_regmap_add_irq_chip() but doesn't lock the GPIO lines.
+ * Can be used if the hwirq numbers of the regmap-irq chip don't match
+ * the GPIO offsets.
+ *
+ * Return: irq_domain or an ERR_PTR() error value.
+ */
+struct irq_domain *gpio_regmap_add_irq_chip_nolock(struct gpio_regmap *gpio, int irq,
+ int irq_flags,
+ struct regmap_irq_chip *chip)
+{
+ int ret;
+
+ /* shouldn't be called more than once */
+ if (WARN_ON(gpio->irq_chip_data))
+ return ERR_PTR(-EBUSY);
+
+ chip->irq_drv_data = gpio;
+
+ ret = regmap_add_irq_chip_fwnode(dev_fwnode(gpio->parent), gpio->regmap,
+ irq, irq_flags, 0, chip,
+ &gpio->irq_chip_data);
+ if (ret)
+ return ERR_PTR(ret);
+
+ gpio->regmap_irq_line = irq;
+
+ return regmap_irq_get_domain(gpio->irq_chip_data);
+}
+EXPORT_SYMBOL_GPL(gpio_regmap_add_irq_chip_nolock);
+
+/**
+ * gpio_regmap_add_irq_chip() - Add a regmap-irq chip for the GPIO lines
+ * @gpio: gpio_regmap device
+ * @irq: the parent interrupt
+ * @irq_flags: the IRQF_ flags to use for @irq
+ * @chip: the regmap-irq chip description
+ *
+ * Add a regmap-irq chip on the regmap of @gpio. Must be called from the
+ * .create_irq_domain() callback and only once per gpio_regmap.
+ *
+ * The GPIO line of an interrupt is locked as long as the interrupt is
+ * requested and can't be switched to an output. This assumes that the
+ * hwirq number of each interrupt is the same as the offset of the
+ * corresponding GPIO line. If that isn't the case, use
+ * gpio_regmap_add_irq_chip_nolock() instead.
+ *
+ * You can use gpio_regmap_get_drvdata() to get the driver data in the
+ * regmap-irq callbacks.
+ *
+ * The regmap-irq chip is automatically removed when the gpio_regmap is
+ * unregistered.
+ *
+ * Return: irq_domain or an ERR_PTR() error value.
+ */
+struct irq_domain *gpio_regmap_add_irq_chip(struct gpio_regmap *gpio, int irq,
+ int irq_flags,
+ struct regmap_irq_chip *chip)
+{
+ chip->irq_reqres = gpio_regmap_irq_reqres;
+ chip->irq_relres = gpio_regmap_irq_relres;
+
+ return gpio_regmap_add_irq_chip_nolock(gpio, irq, irq_flags, chip);
+}
+EXPORT_SYMBOL_GPL(gpio_regmap_add_irq_chip);
+#endif
+
void *gpio_regmap_get_drvdata(struct gpio_regmap *gpio)
{
return gpio->driver_data;
diff --git a/include/linux/gpio/regmap.h b/include/linux/gpio/regmap.h
index dee5f8d2c48c..ff2732f909d9 100644
--- a/include/linux/gpio/regmap.h
+++ b/include/linux/gpio/regmap.h
@@ -3,6 +3,7 @@
#ifndef _LINUX_GPIO_REGMAP_H
#define _LINUX_GPIO_REGMAP_H
+#include <linux/err.h>
#include <linux/types.h>
struct device;
@@ -11,6 +12,7 @@ struct gpio_regmap;
struct gpio_chip;
struct irq_domain;
struct regmap;
+struct regmap_irq_chip;
#define GPIO_REGMAP_ADDR_ZERO ((unsigned int)(-1))
#define GPIO_REGMAP_ADDR(addr) ((addr) ? : GPIO_REGMAP_ADDR_ZERO)
@@ -185,4 +187,27 @@ void gpio_regmap_relres_irq(struct gpio_regmap *gpio, unsigned int offset);
void gpio_regmap_enable_irq(struct gpio_regmap *gpio, irq_hw_number_t hwirq);
void gpio_regmap_disable_irq(struct gpio_regmap *gpio, irq_hw_number_t hwirq);
+#ifdef CONFIG_REGMAP_IRQ
+struct irq_domain *gpio_regmap_add_irq_chip(struct gpio_regmap *gpio, int irq,
+ int irq_flags,
+ struct regmap_irq_chip *chip);
+struct irq_domain *gpio_regmap_add_irq_chip_nolock(struct gpio_regmap *gpio, int irq,
+ int irq_flags,
+ struct regmap_irq_chip *chip);
+#else
+static inline struct irq_domain *
+gpio_regmap_add_irq_chip(struct gpio_regmap *gpio, int irq, int irq_flags,
+ struct regmap_irq_chip *chip)
+{
+ return ERR_PTR(-EOPNOTSUPP);
+}
+
+static inline struct irq_domain *
+gpio_regmap_add_irq_chip_nolock(struct gpio_regmap *gpio, int irq, int irq_flags,
+ struct regmap_irq_chip *chip)
+{
+ return ERR_PTR(-EOPNOTSUPP);
+}
+#endif
+
#endif /* _LINUX_GPIO_REGMAP_H */
--
2.47.3
^ permalink raw reply related [flat|nested] 21+ messages in thread* Re: [RFT PATCH v2 06/14] gpio: regmap: add helpers to add a regmap-irq chip
2026-11-27 14:52 ` [RFT PATCH v2 06/14] gpio: regmap: add helpers to add a regmap-irq chip Michael Walle
@ 2026-11-27 18:43 ` Andy Shevchenko
0 siblings, 0 replies; 21+ messages in thread
From: Andy Shevchenko @ 2026-11-27 18:43 UTC (permalink / raw)
To: Michael Walle
Cc: William Breathitt Gray, Linus Walleij, Bartosz Golaszewski,
Petar Stepanovic, SriNavmani A, Prasad Bolisetty, Tzu-Hao Wei,
Karthikeyan Mitran, Mathieu Dubois-Briand, Lee Jones, Long Zhao,
Joseph Telaak, linux-gpio, linux-arm-kernel
On Fri, Nov 27, 2026 at 03:52:23PM +0100, Michael Walle wrote:
> The most common use-case is to use regmap-irq together with gpio-regmap.
> To make life easier for that and to avoid code duplication, add helpers
> to create and attach a regmap-irq domain. These helpers are intended to
> be called by the new .create_irq_domain() callback.
>
> gpio_regmap_add_irq_chip() locks the GPIO line while its interrupt is
> requested. This assumes that the hwirq numbers match the GPIO offsets.
> If a driver doesn't follow that, there is one without the locking called
> gpio_regmap_add_irq_chip_nolock().
Hmm... Can't we simply have a boolean flag instead in GPIO regmap configuration
and just distinguish it inside the common helper?
...
> +/**
> + * gpio_regmap_add_irq_chip_nolock() - Add a regmap-irq chip without line locking
> + * @gpio: gpio_regmap device
> + * @irq: the parent interrupt
> + * @irq_flags: the IRQF_ flags to use for @irq
> + * @chip: the regmap-irq chip description
> + *
> + * Same as gpio_regmap_add_irq_chip() but doesn't lock the GPIO lines.
> + * Can be used if the hwirq numbers of the regmap-irq chip don't match
> + * the GPIO offsets.
> + *
> + * Return: irq_domain or an ERR_PTR() error value.
Okay, this might justify returning error pointer, but irq_domain_create_*()
shadows that with NULL, which questions the usefulness of it (the error code).
I'm fine with either approach but still tend towards using
irq_domain_create_*() helpers instead their open coded variants.
On the other hand there is no much win, especially if you replace
info = {};
info.XXX = ...;
... = irq_domain_instantiate(&info);
with direct assignment as it's done inside irq_domain_create_*(),
> + */
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 21+ messages in thread
* [RFT PATCH v2 07/14] gpio: max7360: create the regmap-irq chip from the gpio-regmap callback
2026-11-27 14:52 [RFT PATCH v2 00/14] gpio: regmap: IRQ domain cleanups Michael Walle
` (5 preceding siblings ...)
2026-11-27 14:52 ` [RFT PATCH v2 06/14] gpio: regmap: add helpers to add a regmap-irq chip Michael Walle
@ 2026-11-27 14:52 ` Michael Walle
2026-11-27 18:48 ` Andy Shevchenko
2026-11-27 14:52 ` [RFT PATCH v2 08/14] gpio: sl28cpld: " Michael Walle
` (6 subsequent siblings)
13 siblings, 1 reply; 21+ messages in thread
From: Michael Walle @ 2026-11-27 14:52 UTC (permalink / raw)
To: William Breathitt Gray, Linus Walleij, Bartosz Golaszewski,
Petar Stepanovic, SriNavmani A, Prasad Bolisetty, Tzu-Hao Wei,
Karthikeyan Mitran, Mathieu Dubois-Briand, Michael Walle,
Lee Jones, Andy Shevchenko, Long Zhao, Joseph Telaak
Cc: linux-gpio, linux-arm-kernel
Use the new gpio_regmap_add_irq_chip() helper to create the regmap-irq
domain.
Signed-off-by: Michael Walle <mwalle@kernel.org>
---
drivers/gpio/gpio-max7360.c | 35 ++++++++++++++++++++++++++++-------
1 file changed, 28 insertions(+), 7 deletions(-)
diff --git a/drivers/gpio/gpio-max7360.c b/drivers/gpio/gpio-max7360.c
index b77a51092dcb..372659edc8fb 100644
--- a/drivers/gpio/gpio-max7360.c
+++ b/drivers/gpio/gpio-max7360.c
@@ -27,6 +27,12 @@ struct max7360_gpio_plat_data {
unsigned int function;
};
+struct max7360_gpio {
+ struct regmap *regmap;
+ struct regmap_irq_chip *irq_chip;
+ int irq;
+};
+
static struct max7360_gpio_plat_data max7360_gpio_port_plat = { .function = MAX7360_GPIO_PORT };
static struct max7360_gpio_plat_data max7360_gpio_col_plat = { .function = MAX7360_GPIO_COL };
@@ -128,7 +134,8 @@ static int max7360_handle_mask_sync(const int index,
const unsigned int mask_buf,
void *const irq_drv_data)
{
- struct regmap *regmap = gpio_regmap_get_drvdata(irq_drv_data);
+ struct max7360_gpio *max7360_gpio = gpio_regmap_get_drvdata(irq_drv_data);
+ struct regmap *regmap = max7360_gpio->regmap;
int ret;
for (unsigned int i = 0; i < MAX7360_MAX_GPIO; i++) {
@@ -141,10 +148,19 @@ static int max7360_handle_mask_sync(const int index,
return 0;
}
+static struct irq_domain *max7360_gpio_create_irq_domain(struct gpio_regmap *gpio)
+{
+ struct max7360_gpio *max7360_gpio = gpio_regmap_get_drvdata(gpio);
+
+ return gpio_regmap_add_irq_chip(gpio, max7360_gpio->irq, IRQF_ONESHOT | IRQF_SHARED,
+ max7360_gpio->irq_chip);
+}
+
static int max7360_gpio_probe(struct platform_device *pdev)
{
const struct max7360_gpio_plat_data *plat_data;
struct gpio_regmap_config gpio_config = { };
+ struct max7360_gpio *max7360_gpio;
struct regmap_irq_chip *irq_chip;
struct device *dev = &pdev->dev;
struct regmap *regmap;
@@ -162,11 +178,15 @@ static int max7360_gpio_probe(struct platform_device *pdev)
* Port GPIOs with interrupt-controller property: add IRQ
* controller.
*/
- gpio_config.regmap_irq_flags = IRQF_ONESHOT | IRQF_SHARED;
- gpio_config.regmap_irq_line =
+ max7360_gpio = devm_kzalloc_obj(dev, *max7360_gpio);
+ if (!max7360_gpio)
+ return -ENOMEM;
+
+ max7360_gpio->regmap = regmap;
+ max7360_gpio->irq =
fwnode_irq_get_byname(dev_fwnode(dev->parent), "inti");
- if (gpio_config.regmap_irq_line < 0)
- return dev_err_probe(dev, gpio_config.regmap_irq_line,
+ if (max7360_gpio->irq < 0)
+ return dev_err_probe(dev, max7360_gpio->irq,
"Failed to get IRQ\n");
/* Create custom IRQ configuration. */
@@ -181,9 +201,10 @@ static int max7360_gpio_probe(struct platform_device *pdev)
irq_chip->num_irqs = MAX7360_MAX_GPIO;
irq_chip->irqs = max7360_regmap_irqs;
irq_chip->handle_mask_sync = max7360_handle_mask_sync;
+ max7360_gpio->irq_chip = irq_chip;
- gpio_config.regmap_irq_chip = irq_chip;
- gpio_config.drvdata = regmap;
+ gpio_config.drvdata = max7360_gpio;
+ gpio_config.create_irq_domain = max7360_gpio_create_irq_domain;
for (unsigned int i = 0; i < MAX7360_MAX_GPIO; i++) {
ret = regmap_write_bits(regmap, MAX7360_REG_PWMCFG(i),
--
2.47.3
^ permalink raw reply related [flat|nested] 21+ messages in thread* Re: [RFT PATCH v2 07/14] gpio: max7360: create the regmap-irq chip from the gpio-regmap callback
2026-11-27 14:52 ` [RFT PATCH v2 07/14] gpio: max7360: create the regmap-irq chip from the gpio-regmap callback Michael Walle
@ 2026-11-27 18:48 ` Andy Shevchenko
0 siblings, 0 replies; 21+ messages in thread
From: Andy Shevchenko @ 2026-11-27 18:48 UTC (permalink / raw)
To: Michael Walle
Cc: William Breathitt Gray, Linus Walleij, Bartosz Golaszewski,
Petar Stepanovic, SriNavmani A, Prasad Bolisetty, Tzu-Hao Wei,
Karthikeyan Mitran, Mathieu Dubois-Briand, Lee Jones, Long Zhao,
Joseph Telaak, linux-gpio, linux-arm-kernel
On Fri, Nov 27, 2026 at 03:52:24PM +0100, Michael Walle wrote:
> Use the new gpio_regmap_add_irq_chip() helper to create the regmap-irq
> domain.
Okay, but now it makes me think why we don't call regmap_del_irq_chip()...
Missing part?
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 21+ messages in thread
* [RFT PATCH v2 08/14] gpio: sl28cpld: create the regmap-irq chip from the gpio-regmap callback
2026-11-27 14:52 [RFT PATCH v2 00/14] gpio: regmap: IRQ domain cleanups Michael Walle
` (6 preceding siblings ...)
2026-11-27 14:52 ` [RFT PATCH v2 07/14] gpio: max7360: create the regmap-irq chip from the gpio-regmap callback Michael Walle
@ 2026-11-27 14:52 ` Michael Walle
2026-11-27 14:52 ` [RFT PATCH v2 09/14] gpio: idio-16: " Michael Walle
` (5 subsequent siblings)
13 siblings, 0 replies; 21+ messages in thread
From: Michael Walle @ 2026-11-27 14:52 UTC (permalink / raw)
To: William Breathitt Gray, Linus Walleij, Bartosz Golaszewski,
Petar Stepanovic, SriNavmani A, Prasad Bolisetty, Tzu-Hao Wei,
Karthikeyan Mitran, Mathieu Dubois-Briand, Michael Walle,
Lee Jones, Andy Shevchenko, Long Zhao, Joseph Telaak
Cc: linux-gpio, linux-arm-kernel
Use the new gpio_regmap_add_irq_chip() helper to create the regmap-irq
domain.
Signed-off-by: Michael Walle <mwalle@kernel.org>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/gpio/gpio-sl28cpld.c | 34 +++++++++++++++++++++++-----------
1 file changed, 23 insertions(+), 11 deletions(-)
diff --git a/drivers/gpio/gpio-sl28cpld.c b/drivers/gpio/gpio-sl28cpld.c
index 57cadeb07fde..46141da2d2f7 100644
--- a/drivers/gpio/gpio-sl28cpld.c
+++ b/drivers/gpio/gpio-sl28cpld.c
@@ -44,14 +44,28 @@ static const struct regmap_irq sl28cpld_gpio_irqs[] = {
REGMAP_IRQ_REG_LINE(7, 8),
};
+struct sl28cpld_gpio {
+ struct regmap_irq_chip irq_chip;
+ int irq;
+};
+
+static struct irq_domain *sl28cpld_gpio_create_irq_domain(struct gpio_regmap *gpio)
+{
+ struct sl28cpld_gpio *sl28cpld_gpio = gpio_regmap_get_drvdata(gpio);
+
+ return gpio_regmap_add_irq_chip(gpio, sl28cpld_gpio->irq,
+ IRQF_SHARED | IRQF_ONESHOT,
+ &sl28cpld_gpio->irq_chip);
+}
+
static int sl28cpld_gpio_irq_init(struct platform_device *pdev,
unsigned int base,
struct gpio_regmap_config *config)
{
- struct regmap_irq_chip_data *irq_data;
+ struct sl28cpld_gpio *sl28cpld_gpio;
struct regmap_irq_chip *irq_chip;
struct device *dev = &pdev->dev;
- int irq, ret;
+ int irq;
if (!device_property_read_bool(dev, "interrupt-controller"))
return 0;
@@ -60,10 +74,12 @@ static int sl28cpld_gpio_irq_init(struct platform_device *pdev,
if (irq < 0)
return irq;
- irq_chip = devm_kzalloc_obj(dev, *irq_chip);
- if (!irq_chip)
+ sl28cpld_gpio = devm_kzalloc_obj(dev, *sl28cpld_gpio);
+ if (!sl28cpld_gpio)
return -ENOMEM;
+ irq_chip = &sl28cpld_gpio->irq_chip;
+
irq_chip->name = "sl28cpld-gpio-irq";
irq_chip->irqs = sl28cpld_gpio_irqs;
irq_chip->num_irqs = ARRAY_SIZE(sl28cpld_gpio_irqs);
@@ -72,14 +88,10 @@ static int sl28cpld_gpio_irq_init(struct platform_device *pdev,
irq_chip->unmask_base = base + GPIO_REG_IE;
irq_chip->ack_base = base + GPIO_REG_IP;
- ret = devm_regmap_add_irq_chip_fwnode(dev, dev_fwnode(dev),
- config->regmap, irq,
- IRQF_SHARED | IRQF_ONESHOT,
- 0, irq_chip, &irq_data);
- if (ret)
- return ret;
+ sl28cpld_gpio->irq = irq;
- config->irq_domain = regmap_irq_get_domain(irq_data);
+ config->drvdata = sl28cpld_gpio;
+ config->create_irq_domain = sl28cpld_gpio_create_irq_domain;
return 0;
}
--
2.47.3
^ permalink raw reply related [flat|nested] 21+ messages in thread* [RFT PATCH v2 09/14] gpio: idio-16: create the regmap-irq chip from the gpio-regmap callback
2026-11-27 14:52 [RFT PATCH v2 00/14] gpio: regmap: IRQ domain cleanups Michael Walle
` (7 preceding siblings ...)
2026-11-27 14:52 ` [RFT PATCH v2 08/14] gpio: sl28cpld: " Michael Walle
@ 2026-11-27 14:52 ` Michael Walle
2026-11-27 14:52 ` [RFT PATCH v2 10/14] gpio: pcie-idio-24: " Michael Walle
` (4 subsequent siblings)
13 siblings, 0 replies; 21+ messages in thread
From: Michael Walle @ 2026-11-27 14:52 UTC (permalink / raw)
To: William Breathitt Gray, Linus Walleij, Bartosz Golaszewski,
Petar Stepanovic, SriNavmani A, Prasad Bolisetty, Tzu-Hao Wei,
Karthikeyan Mitran, Mathieu Dubois-Briand, Michael Walle,
Lee Jones, Andy Shevchenko, Long Zhao, Joseph Telaak
Cc: linux-gpio, linux-arm-kernel
Use the new gpio_regmap_add_irq_chip_nolock() helper to create the
regmap-irq domain. Use the _nolock() variant because the hwirq don't
match the GPIO offsets.
Signed-off-by: Michael Walle <mwalle@kernel.org>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/gpio/gpio-idio-16.c | 28 ++++++++++++++++++++--------
1 file changed, 20 insertions(+), 8 deletions(-)
diff --git a/drivers/gpio/gpio-idio-16.c b/drivers/gpio/gpio-idio-16.c
index b9aa8bb9347a..16744ecb5fad 100644
--- a/drivers/gpio/gpio-idio-16.c
+++ b/drivers/gpio/gpio-idio-16.c
@@ -34,12 +34,14 @@
struct idio_16_data {
struct regmap *map;
unsigned int irq_mask;
+ struct regmap_irq_chip *chip;
+ unsigned int irq;
};
static int idio_16_handle_mask_sync(const int index, const unsigned int mask_buf_def,
const unsigned int mask_buf, void *const irq_drv_data)
{
- struct idio_16_data *const data = irq_drv_data;
+ struct idio_16_data *const data = gpio_regmap_get_drvdata(irq_drv_data);
const unsigned int prev_mask = data->irq_mask;
int err;
unsigned int val;
@@ -66,6 +68,19 @@ static int idio_16_handle_mask_sync(const int index, const unsigned int mask_buf
return 0;
}
+static struct irq_domain *idio_16_create_irq_domain(struct gpio_regmap *gpio)
+{
+ struct idio_16_data *data = gpio_regmap_get_drvdata(gpio);
+ struct irq_domain *domain;
+
+ domain = gpio_regmap_add_irq_chip_nolock(gpio, data->irq, 0, data->chip);
+ if (IS_ERR(domain))
+ return dev_err_cast_probe(regmap_get_device(data->map), domain,
+ "IRQ registration failed\n");
+
+ return domain;
+}
+
static int idio_16_reg_mask_xlate(struct gpio_regmap *const gpio, enum gpio_regmap_operation op,
const unsigned int base, const unsigned int offset,
unsigned int *const reg, unsigned int *const mask)
@@ -107,7 +122,6 @@ int devm_idio_16_regmap_register(struct device *const dev,
int err;
struct idio_16_data *data;
struct regmap_irq_chip *chip;
- struct regmap_irq_chip_data *chip_data;
DECLARE_BITMAP(fixed_direction_output, IDIO_16_NGPIO);
if (!config->parent)
@@ -137,17 +151,14 @@ int devm_idio_16_regmap_register(struct device *const dev,
chip->irqs = config->regmap_irqs;
chip->num_irqs = config->num_regmap_irqs;
chip->handle_mask_sync = idio_16_handle_mask_sync;
- chip->irq_drv_data = data;
+ data->chip = chip;
+ data->irq = config->irq;
/* Disable IRQ to prevent spurious interrupts before we're ready */
err = regmap_write(data->map, IDIO_16_DISABLE_IRQ, 0x00);
if (err)
return err;
- err = devm_regmap_add_irq_chip(dev, data->map, config->irq, 0, 0, chip, &chip_data);
- if (err)
- return dev_err_probe(dev, err, "IRQ registration failed\n");
-
if (config->filters) {
/* Deactivate input filters */
err = regmap_write(data->map, IDIO_16_DEACTIVATE_INPUT_FILTERS, 0x00);
@@ -163,7 +174,8 @@ int devm_idio_16_regmap_register(struct device *const dev,
gpio_config.reg_set_base = GPIO_REGMAP_ADDR(IDIO_16_DAT_BASE);
gpio_config.ngpio_per_reg = IDIO_16_NGPIO_PER_REG;
gpio_config.reg_stride = IDIO_16_REG_STRIDE;
- gpio_config.irq_domain = regmap_irq_get_domain(chip_data);
+ gpio_config.drvdata = data;
+ gpio_config.create_irq_domain = idio_16_create_irq_domain;
gpio_config.reg_mask_xlate = idio_16_reg_mask_xlate;
bitmap_from_u64(fixed_direction_output, GENMASK_U64(15, 0));
--
2.47.3
^ permalink raw reply related [flat|nested] 21+ messages in thread* [RFT PATCH v2 10/14] gpio: pcie-idio-24: create the regmap-irq chip from the gpio-regmap callback
2026-11-27 14:52 [RFT PATCH v2 00/14] gpio: regmap: IRQ domain cleanups Michael Walle
` (8 preceding siblings ...)
2026-11-27 14:52 ` [RFT PATCH v2 09/14] gpio: idio-16: " Michael Walle
@ 2026-11-27 14:52 ` Michael Walle
2026-11-27 14:52 ` [RFT PATCH v2 11/14] gpio: ws16c48: " Michael Walle
` (3 subsequent siblings)
13 siblings, 0 replies; 21+ messages in thread
From: Michael Walle @ 2026-11-27 14:52 UTC (permalink / raw)
To: William Breathitt Gray, Linus Walleij, Bartosz Golaszewski,
Petar Stepanovic, SriNavmani A, Prasad Bolisetty, Tzu-Hao Wei,
Karthikeyan Mitran, Mathieu Dubois-Briand, Michael Walle,
Lee Jones, Andy Shevchenko, Long Zhao, Joseph Telaak
Cc: linux-gpio, linux-arm-kernel
Use the new gpio_regmap_add_irq_chip_nolock() helper to create the
regmap-irq domain. Use the _nolock() variant because the hwirq don't
match the GPIO offsets.
Signed-off-by: Michael Walle <mwalle@kernel.org>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/gpio/gpio-pcie-idio-24.c | 36 ++++++++++++++++++++++----------
1 file changed, 25 insertions(+), 11 deletions(-)
diff --git a/drivers/gpio/gpio-pcie-idio-24.c b/drivers/gpio/gpio-pcie-idio-24.c
index 8fb34398053d..604558bed12e 100644
--- a/drivers/gpio/gpio-pcie-idio-24.c
+++ b/drivers/gpio/gpio-pcie-idio-24.c
@@ -148,18 +148,22 @@ static const struct regmap_irq idio_24_regmap_irqs[] = {
* @map: regmap for the device
* @lock: synchronization lock to prevent I/O race conditions
* @irq_type: type configuration for IRQs
+ * @chip: regmap_irq_chip for the device
+ * @irq: parent IRQ
*/
struct idio_24_gpio {
struct regmap *map;
raw_spinlock_t lock;
u8 irq_type;
+ struct regmap_irq_chip *chip;
+ int irq;
};
static int idio_24_handle_mask_sync(const int index, const unsigned int mask_buf_def,
const unsigned int mask_buf, void *const irq_drv_data)
{
const unsigned int type_mask = COS_ENABLE_BOTH << index;
- struct idio_24_gpio *const idio24gpio = irq_drv_data;
+ struct idio_24_gpio *const idio24gpio = gpio_regmap_get_drvdata(irq_drv_data);
u8 type;
int ret;
@@ -183,7 +187,7 @@ static int idio_24_set_type_config(unsigned int **const buf, const unsigned int
const unsigned int rising = COS_ENABLE_RISING << offset;
const unsigned int falling = COS_ENABLE_FALLING << offset;
const unsigned int mask = COS_ENABLE_BOTH << offset;
- struct idio_24_gpio *const idio24gpio = irq_drv_data;
+ struct idio_24_gpio *const idio24gpio = gpio_regmap_get_drvdata(irq_drv_data);
unsigned int new;
unsigned int cos_enable;
int ret;
@@ -225,13 +229,27 @@ static int idio_24_set_type_config(unsigned int **const buf, const unsigned int
return ret;
}
+static struct irq_domain *idio_24_create_irq_domain(struct gpio_regmap *gpio)
+{
+ struct idio_24_gpio *const idio24gpio = gpio_regmap_get_drvdata(gpio);
+ struct irq_domain *domain;
+
+ domain = gpio_regmap_add_irq_chip_nolock(gpio, idio24gpio->irq, 0, idio24gpio->chip);
+ if (IS_ERR(domain))
+ return dev_err_cast_probe(regmap_get_device(idio24gpio->map), domain,
+ "IRQ registration failed\n");
+
+ return domain;
+}
+
static int idio_24_reg_mask_xlate(struct gpio_regmap *const gpio, enum gpio_regmap_operation op,
const unsigned int base, const unsigned int offset,
unsigned int *const reg, unsigned int *const mask)
{
const unsigned int out_stride = offset / IDIO_24_NGPIO_PER_REG;
const unsigned int in_stride = (offset - 24) / IDIO_24_NGPIO_PER_REG;
- struct regmap *const map = gpio_regmap_get_drvdata(gpio);
+ struct idio_24_gpio *const idio24gpio = gpio_regmap_get_drvdata(gpio);
+ struct regmap *const map = idio24gpio->map;
int err;
unsigned int ctrl_reg;
@@ -302,7 +320,6 @@ static int idio_24_probe(struct pci_dev *pdev, const struct pci_device_id *id)
void __iomem *idio_24_regs;
struct regmap *intcsr_map;
struct regmap_irq_chip *chip;
- struct regmap_irq_chip_data *chip_data;
err = pcim_enable_device(pdev);
if (err)
@@ -348,7 +365,8 @@ static int idio_24_probe(struct pci_dev *pdev, const struct pci_device_id *id)
chip->num_irqs = ARRAY_SIZE(idio_24_regmap_irqs);
chip->handle_mask_sync = idio_24_handle_mask_sync;
chip->set_type_config = idio_24_set_type_config;
- chip->irq_drv_data = idio24gpio;
+ idio24gpio->chip = chip;
+ idio24gpio->irq = pdev->irq;
/* Software board reset */
err = regmap_write(idio24gpio->map, IDIO_24_SOFT_RESET, 0);
@@ -362,10 +380,6 @@ static int idio_24_probe(struct pci_dev *pdev, const struct pci_device_id *id)
if (err)
return err;
- err = devm_regmap_add_irq_chip(dev, idio24gpio->map, pdev->irq, 0, 0, chip, &chip_data);
- if (err)
- return dev_err_probe(dev, err, "IRQ registration failed\n");
-
gpio_config.parent = dev;
gpio_config.regmap = idio24gpio->map;
gpio_config.ngpio = IDIO_24_NGPIO;
@@ -374,9 +388,9 @@ static int idio_24_probe(struct pci_dev *pdev, const struct pci_device_id *id)
gpio_config.reg_set_base = GPIO_REGMAP_ADDR(IDIO_24_OUT_BASE);
gpio_config.reg_dir_out_base = GPIO_REGMAP_ADDR(IDIO_24_CONTROL_REG);
gpio_config.ngpio_per_reg = IDIO_24_NGPIO_PER_REG;
- gpio_config.irq_domain = regmap_irq_get_domain(chip_data);
gpio_config.reg_mask_xlate = idio_24_reg_mask_xlate;
- gpio_config.drvdata = idio24gpio->map;
+ gpio_config.drvdata = idio24gpio;
+ gpio_config.create_irq_domain = idio_24_create_irq_domain;
return PTR_ERR_OR_ZERO(devm_gpio_regmap_register(dev, &gpio_config));
}
--
2.47.3
^ permalink raw reply related [flat|nested] 21+ messages in thread* [RFT PATCH v2 11/14] gpio: ws16c48: create the regmap-irq chip from the gpio-regmap callback
2026-11-27 14:52 [RFT PATCH v2 00/14] gpio: regmap: IRQ domain cleanups Michael Walle
` (9 preceding siblings ...)
2026-11-27 14:52 ` [RFT PATCH v2 10/14] gpio: pcie-idio-24: " Michael Walle
@ 2026-11-27 14:52 ` Michael Walle
2026-11-27 14:52 ` [RFT PATCH v2 12/14] gpio: 104-idi-48: " Michael Walle
` (2 subsequent siblings)
13 siblings, 0 replies; 21+ messages in thread
From: Michael Walle @ 2026-11-27 14:52 UTC (permalink / raw)
To: William Breathitt Gray, Linus Walleij, Bartosz Golaszewski,
Petar Stepanovic, SriNavmani A, Prasad Bolisetty, Tzu-Hao Wei,
Karthikeyan Mitran, Mathieu Dubois-Briand, Michael Walle,
Lee Jones, Andy Shevchenko, Long Zhao, Joseph Telaak
Cc: linux-gpio, linux-arm-kernel
Use the new gpio_regmap_add_irq_chip() helper to create the regmap-irq
domain.
Signed-off-by: Michael Walle <mwalle@kernel.org>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/gpio/gpio-ws16c48.c | 36 +++++++++++++++++++++++++-----------
1 file changed, 25 insertions(+), 11 deletions(-)
diff --git a/drivers/gpio/gpio-ws16c48.c b/drivers/gpio/gpio-ws16c48.c
index cd0c35c057cb..6a5e74fc3395 100644
--- a/drivers/gpio/gpio-ws16c48.c
+++ b/drivers/gpio/gpio-ws16c48.c
@@ -104,16 +104,20 @@ static const struct regmap_irq ws16c48_regmap_irqs[WS16C48_NUM_IRQS] = {
* @map: regmap for the device
* @lock: synchronization lock to prevent I/O race conditions
* @irq_mask: I/O bits affected by interrupts
+ * @chip: regmap_irq_chip for the device
+ * @irq: parent IRQ
*/
struct ws16c48_gpio {
struct regmap *map;
raw_spinlock_t lock;
u8 irq_mask[WS16C48_NUM_IRQS / WS16C48_NGPIO_PER_REG];
+ struct regmap_irq_chip *chip;
+ unsigned int irq;
};
static int ws16c48_handle_pre_irq(void *const irq_drv_data) __acquires(&ws16c48gpio->lock)
{
- struct ws16c48_gpio *const ws16c48gpio = irq_drv_data;
+ struct ws16c48_gpio *const ws16c48gpio = gpio_regmap_get_drvdata(irq_drv_data);
/* Lock to prevent Page/Lock register change while we handle IRQ */
raw_spin_lock(&ws16c48gpio->lock);
@@ -123,7 +127,7 @@ static int ws16c48_handle_pre_irq(void *const irq_drv_data) __acquires(&ws16c48g
static int ws16c48_handle_post_irq(void *const irq_drv_data) __releases(&ws16c48gpio->lock)
{
- struct ws16c48_gpio *const ws16c48gpio = irq_drv_data;
+ struct ws16c48_gpio *const ws16c48gpio = gpio_regmap_get_drvdata(irq_drv_data);
raw_spin_unlock(&ws16c48gpio->lock);
@@ -133,7 +137,7 @@ static int ws16c48_handle_post_irq(void *const irq_drv_data) __releases(&ws16c48
static int ws16c48_handle_mask_sync(const int index, const unsigned int mask_buf_def,
const unsigned int mask_buf, void *const irq_drv_data)
{
- struct ws16c48_gpio *const ws16c48gpio = irq_drv_data;
+ struct ws16c48_gpio *const ws16c48gpio = gpio_regmap_get_drvdata(irq_drv_data);
unsigned long flags;
int ret = 0;
@@ -167,7 +171,7 @@ static int ws16c48_set_type_config(unsigned int **const buf, const unsigned int
const struct regmap_irq *const irq_data, const int idx,
void *const irq_drv_data)
{
- struct ws16c48_gpio *const ws16c48gpio = irq_drv_data;
+ struct ws16c48_gpio *const ws16c48gpio = gpio_regmap_get_drvdata(irq_drv_data);
unsigned int polarity;
unsigned long flags;
int ret;
@@ -242,6 +246,19 @@ static int ws16c48_irq_init_hw(struct regmap *const map)
return regmap_write(map, WS16C48_PAGE_LOCK, INT_ID_PAGE);
}
+static struct irq_domain *ws16c48_create_irq_domain(struct gpio_regmap *gpio)
+{
+ struct ws16c48_gpio *const ws16c48gpio = gpio_regmap_get_drvdata(gpio);
+ struct irq_domain *domain;
+
+ domain = gpio_regmap_add_irq_chip(gpio, ws16c48gpio->irq, 0, ws16c48gpio->chip);
+ if (IS_ERR(domain))
+ return dev_err_cast_probe(regmap_get_device(ws16c48gpio->map), domain,
+ "IRQ registration failed\n");
+
+ return domain;
+}
+
static int ws16c48_probe(struct device *dev, unsigned int id)
{
struct ws16c48_gpio *ws16c48gpio;
@@ -250,7 +267,6 @@ static int ws16c48_probe(struct device *dev, unsigned int id)
struct gpio_regmap_config gpio_config = {};
void __iomem *regs;
struct regmap_irq_chip *chip;
- struct regmap_irq_chip_data *chip_data;
ws16c48gpio = devm_kzalloc_obj(dev, *ws16c48gpio);
if (!ws16c48gpio)
@@ -286,7 +302,8 @@ static int ws16c48_probe(struct device *dev, unsigned int id)
chip->handle_post_irq = ws16c48_handle_post_irq;
chip->handle_mask_sync = ws16c48_handle_mask_sync;
chip->set_type_config = ws16c48_set_type_config;
- chip->irq_drv_data = ws16c48gpio;
+ ws16c48gpio->chip = chip;
+ ws16c48gpio->irq = irq[id];
raw_spin_lock_init(&ws16c48gpio->lock);
@@ -295,10 +312,6 @@ static int ws16c48_probe(struct device *dev, unsigned int id)
if (err)
return err;
- err = devm_regmap_add_irq_chip(dev, ws16c48gpio->map, irq[id], 0, 0, chip, &chip_data);
- if (err)
- return dev_err_probe(dev, err, "IRQ registration failed\n");
-
gpio_config.parent = dev;
gpio_config.regmap = ws16c48gpio->map;
gpio_config.ngpio = WS16C48_NGPIO;
@@ -308,7 +321,8 @@ static int ws16c48_probe(struct device *dev, unsigned int id)
/* Setting a GPIO to 0 allows it to be used as an input */
gpio_config.reg_dir_out_base = GPIO_REGMAP_ADDR(WS16C48_DAT_BASE);
gpio_config.ngpio_per_reg = WS16C48_NGPIO_PER_REG;
- gpio_config.irq_domain = regmap_irq_get_domain(chip_data);
+ gpio_config.drvdata = ws16c48gpio;
+ gpio_config.create_irq_domain = ws16c48_create_irq_domain;
return PTR_ERR_OR_ZERO(devm_gpio_regmap_register(dev, &gpio_config));
}
--
2.47.3
^ permalink raw reply related [flat|nested] 21+ messages in thread* [RFT PATCH v2 12/14] gpio: 104-idi-48: create the regmap-irq chip from the gpio-regmap callback
2026-11-27 14:52 [RFT PATCH v2 00/14] gpio: regmap: IRQ domain cleanups Michael Walle
` (10 preceding siblings ...)
2026-11-27 14:52 ` [RFT PATCH v2 11/14] gpio: ws16c48: " Michael Walle
@ 2026-11-27 14:52 ` Michael Walle
2026-11-27 14:52 ` [RFT PATCH v2 13/14] gpio: i8255: " Michael Walle
2026-11-27 14:52 ` [RFT PATCH v2 14/14] gpio: regmap: remove irq_domain and the regmap-irq configuration Michael Walle
13 siblings, 0 replies; 21+ messages in thread
From: Michael Walle @ 2026-11-27 14:52 UTC (permalink / raw)
To: William Breathitt Gray, Linus Walleij, Bartosz Golaszewski,
Petar Stepanovic, SriNavmani A, Prasad Bolisetty, Tzu-Hao Wei,
Karthikeyan Mitran, Mathieu Dubois-Briand, Michael Walle,
Lee Jones, Andy Shevchenko, Long Zhao, Joseph Telaak
Cc: linux-gpio, linux-arm-kernel
Use the new gpio_regmap_add_irq_chip() helper to create the regmap-irq
domain.
Signed-off-by: Michael Walle <mwalle@kernel.org>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/gpio/gpio-104-idi-48.c | 38 +++++++++++++++++++++++++---------
1 file changed, 28 insertions(+), 10 deletions(-)
diff --git a/drivers/gpio/gpio-104-idi-48.c b/drivers/gpio/gpio-104-idi-48.c
index 93d7ccaded83..434704c06d7e 100644
--- a/drivers/gpio/gpio-104-idi-48.c
+++ b/drivers/gpio/gpio-104-idi-48.c
@@ -123,15 +123,33 @@ static const char *idi48_names[IDI48_NGPIO] = {
"Bit 18 B", "Bit 19 B", "Bit 20 B", "Bit 21 B", "Bit 22 B", "Bit 23 B"
};
+struct idi_48_gpio {
+ struct regmap_irq_chip chip;
+ struct device *dev;
+ unsigned int irq;
+};
+
+static struct irq_domain *idi_48_create_irq_domain(struct gpio_regmap *gpio)
+{
+ struct idi_48_gpio *const idi48gpio = gpio_regmap_get_drvdata(gpio);
+ struct irq_domain *domain;
+
+ domain = gpio_regmap_add_irq_chip(gpio, idi48gpio->irq, IRQF_SHARED, &idi48gpio->chip);
+ if (IS_ERR(domain))
+ return dev_err_cast_probe(idi48gpio->dev, domain,
+ "IRQ registration failed\n");
+
+ return domain;
+}
+
static int idi_48_probe(struct device *dev, unsigned int id)
{
const char *const name = dev_name(dev);
struct gpio_regmap_config config = {};
+ struct idi_48_gpio *idi48gpio;
void __iomem *regs;
struct regmap *map;
struct regmap_irq_chip *chip;
- struct regmap_irq_chip_data *chip_data;
- int err;
if (!devm_request_region(dev, base[id], IDI_48_EXTENT, name)) {
dev_err(dev, "Unable to lock port addresses (0x%X-0x%X)\n",
@@ -148,10 +166,14 @@ static int idi_48_probe(struct device *dev, unsigned int id)
return dev_err_probe(dev, PTR_ERR(map),
"Unable to initialize register map\n");
- chip = devm_kzalloc_obj(dev, *chip);
- if (!chip)
+ idi48gpio = devm_kzalloc_obj(dev, *idi48gpio);
+ if (!idi48gpio)
return -ENOMEM;
+ idi48gpio->dev = dev;
+ idi48gpio->irq = irq[id];
+ chip = &idi48gpio->chip;
+
chip->name = name;
chip->status_base = IDI48_IRQ_STATUS;
chip->unmask_base = IDI48_IRQ_ENABLE;
@@ -160,11 +182,6 @@ static int idi_48_probe(struct device *dev, unsigned int id)
chip->irqs = idi48_regmap_irqs;
chip->num_irqs = ARRAY_SIZE(idi48_regmap_irqs);
- err = devm_regmap_add_irq_chip(dev, map, irq[id], IRQF_SHARED, 0, chip,
- &chip_data);
- if (err)
- return dev_err_probe(dev, err, "IRQ registration failed\n");
-
config.parent = dev;
config.regmap = map;
config.ngpio = IDI48_NGPIO;
@@ -172,7 +189,8 @@ static int idi_48_probe(struct device *dev, unsigned int id)
config.reg_dat_base = GPIO_REGMAP_ADDR(0x0);
config.ngpio_per_reg = 8;
config.reg_mask_xlate = idi_48_reg_mask_xlate;
- config.irq_domain = regmap_irq_get_domain(chip_data);
+ config.drvdata = idi48gpio;
+ config.create_irq_domain = idi_48_create_irq_domain;
return PTR_ERR_OR_ZERO(devm_gpio_regmap_register(dev, &config));
}
--
2.47.3
^ permalink raw reply related [flat|nested] 21+ messages in thread* [RFT PATCH v2 13/14] gpio: i8255: create the regmap-irq chip from the gpio-regmap callback
2026-11-27 14:52 [RFT PATCH v2 00/14] gpio: regmap: IRQ domain cleanups Michael Walle
` (11 preceding siblings ...)
2026-11-27 14:52 ` [RFT PATCH v2 12/14] gpio: 104-idi-48: " Michael Walle
@ 2026-11-27 14:52 ` Michael Walle
2026-11-27 14:52 ` [RFT PATCH v2 14/14] gpio: regmap: remove irq_domain and the regmap-irq configuration Michael Walle
13 siblings, 0 replies; 21+ messages in thread
From: Michael Walle @ 2026-11-27 14:52 UTC (permalink / raw)
To: William Breathitt Gray, Linus Walleij, Bartosz Golaszewski,
Petar Stepanovic, SriNavmani A, Prasad Bolisetty, Tzu-Hao Wei,
Karthikeyan Mitran, Mathieu Dubois-Briand, Michael Walle,
Lee Jones, Andy Shevchenko, Long Zhao, Joseph Telaak
Cc: linux-gpio, linux-arm-kernel
Use the new gpio_regmap_add_irq_chip_nolock() helper to create the
regmap-irq domain. Use the _nolock() variant because the hwirq don't
match the GPIO offsets.
Signed-off-by: Michael Walle <mwalle@kernel.org>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/gpio/gpio-104-dio-48e.c | 31 +++++++++++++++++++++++--------
drivers/gpio/gpio-i8255.c | 3 ++-
drivers/gpio/gpio-i8255.h | 8 ++++++--
3 files changed, 31 insertions(+), 11 deletions(-)
diff --git a/drivers/gpio/gpio-104-dio-48e.c b/drivers/gpio/gpio-104-dio-48e.c
index 7ddf578ba530..27a3f94c6e79 100644
--- a/drivers/gpio/gpio-104-dio-48e.c
+++ b/drivers/gpio/gpio-104-dio-48e.c
@@ -9,6 +9,7 @@
#include <linux/bits.h>
#include <linux/device.h>
#include <linux/err.h>
+#include <linux/gpio/regmap.h>
#include <linux/i8254.h>
#include <linux/ioport.h>
#include <linux/irq.h>
@@ -113,6 +114,8 @@ static const struct regmap_irq dio48e_regmap_irqs[] = {
* @regs: virtual mapping for device registers
* @flags: IRQ flags saved during locking
* @irq_mask: Current IRQ mask state on the device
+ * @chip: regmap_irq_chip for the device
+ * @irq: Parent IRQ
*/
struct dio48e_gpio {
raw_spinlock_t lock;
@@ -120,6 +123,8 @@ struct dio48e_gpio {
void __iomem *regs;
unsigned long flags;
unsigned int irq_mask;
+ struct regmap_irq_chip *chip;
+ unsigned int irq;
};
static void dio48e_regmap_lock(void *lock_arg) __acquires(&dio48egpio->lock)
@@ -163,7 +168,7 @@ static int dio48e_handle_mask_sync(const int index,
const unsigned int mask_buf,
void *const irq_drv_data)
{
- struct dio48e_gpio *const dio48egpio = irq_drv_data;
+ struct dio48e_gpio *const dio48egpio = gpio_regmap_get_drvdata(irq_drv_data);
const unsigned int prev_mask = dio48egpio->irq_mask;
int err;
unsigned int val;
@@ -218,6 +223,19 @@ static int dio48e_irq_init_hw(struct regmap *const map)
return regmap_read(map, DIO48E_DISABLE_INTERRUPT, &val);
}
+static struct irq_domain *dio48e_create_irq_domain(struct gpio_regmap *gpio)
+{
+ struct dio48e_gpio *const dio48egpio = gpio_regmap_get_drvdata(gpio);
+ struct irq_domain *domain;
+
+ domain = gpio_regmap_add_irq_chip_nolock(gpio, dio48egpio->irq, 0, dio48egpio->chip);
+ if (IS_ERR(domain))
+ return dev_err_cast_probe(regmap_get_device(dio48egpio->map), domain,
+ "IRQ registration failed\n");
+
+ return domain;
+}
+
static int dio48e_probe(struct device *dev, unsigned int id)
{
const char *const name = dev_name(dev);
@@ -230,7 +248,6 @@ static int dio48e_probe(struct device *dev, unsigned int id)
int err;
struct regmap_irq_chip *chip;
struct dio48e_gpio *dio48egpio;
- struct regmap_irq_chip_data *chip_data;
if (!devm_request_region(dev, base[id], DIO48E_EXTENT, name)) {
dev_err(dev, "Unable to lock port addresses (0x%X-0x%X)\n",
@@ -302,17 +319,14 @@ static int dio48e_probe(struct device *dev, unsigned int id)
chip->irqs = dio48e_regmap_irqs;
chip->num_irqs = ARRAY_SIZE(dio48e_regmap_irqs);
chip->handle_mask_sync = dio48e_handle_mask_sync;
- chip->irq_drv_data = dio48egpio;
+ dio48egpio->chip = chip;
+ dio48egpio->irq = irq[id];
/* Initialize to prevent spurious interrupts before we're ready */
err = dio48e_irq_init_hw(map);
if (err)
return err;
- err = devm_regmap_add_irq_chip(dev, map, irq[id], 0, 0, chip, &chip_data);
- if (err)
- return dev_err_probe(dev, err, "IRQ registration failed\n");
-
pit_config.parent = dev;
err = devm_i8254_regmap_register(dev, &pit_config);
@@ -323,7 +337,8 @@ static int dio48e_probe(struct device *dev, unsigned int id)
config.map = map;
config.num_ppi = DIO48E_NUM_PPI;
config.names = dio48e_names;
- config.domain = regmap_irq_get_domain(chip_data);
+ config.drvdata = dio48egpio;
+ config.create_irq_domain = dio48e_create_irq_domain;
return devm_i8255_regmap_register(dev, &config);
}
diff --git a/drivers/gpio/gpio-i8255.c b/drivers/gpio/gpio-i8255.c
index 541a348447cd..8ac46bb2c235 100644
--- a/drivers/gpio/gpio-i8255.c
+++ b/drivers/gpio/gpio-i8255.c
@@ -129,7 +129,8 @@ int devm_i8255_regmap_register(struct device *const dev,
gpio_config.reg_set_base = GPIO_REGMAP_ADDR(I8255_REG_DAT_BASE);
gpio_config.reg_dir_in_base = GPIO_REGMAP_ADDR(I8255_REG_DIR_IN_BASE);
gpio_config.ngpio_per_reg = I8255_NGPIO_PER_REG;
- gpio_config.irq_domain = config->domain;
+ gpio_config.drvdata = config->drvdata;
+ gpio_config.create_irq_domain = config->create_irq_domain;
gpio_config.reg_mask_xlate = i8255_reg_mask_xlate;
return PTR_ERR_OR_ZERO(devm_gpio_regmap_register(dev, &gpio_config));
diff --git a/drivers/gpio/gpio-i8255.h b/drivers/gpio/gpio-i8255.h
index 9dcf639b94df..fa90044c9cd5 100644
--- a/drivers/gpio/gpio-i8255.h
+++ b/drivers/gpio/gpio-i8255.h
@@ -4,6 +4,7 @@
#define _I8255_H_
struct device;
+struct gpio_regmap;
struct irq_domain;
struct regmap;
@@ -15,7 +16,9 @@ struct regmap;
* @map: regmap for the i8255
* @num_ppi: number of i8255 Programmable Peripheral Interface
* @names: (optional) array of names for gpios
- * @domain: (optional) IRQ domain if the controller is interrupt-capable
+ * @drvdata: (optional) driver data, see gpio_regmap_get_drvdata()
+ * @create_irq_domain: (optional) create the IRQ domain if the controller is
+ * interrupt-capable, see struct gpio_regmap_config
*
* Note: The regmap is expected to have cache enabled and i8255 control
* registers not marked as volatile.
@@ -25,7 +28,8 @@ struct i8255_regmap_config {
struct regmap *map;
int num_ppi;
const char *const *names;
- struct irq_domain *domain;
+ void *drvdata;
+ struct irq_domain *(*create_irq_domain)(struct gpio_regmap *gpio);
};
int devm_i8255_regmap_register(struct device *dev,
--
2.47.3
^ permalink raw reply related [flat|nested] 21+ messages in thread* [RFT PATCH v2 14/14] gpio: regmap: remove irq_domain and the regmap-irq configuration
2026-11-27 14:52 [RFT PATCH v2 00/14] gpio: regmap: IRQ domain cleanups Michael Walle
` (12 preceding siblings ...)
2026-11-27 14:52 ` [RFT PATCH v2 13/14] gpio: i8255: " Michael Walle
@ 2026-11-27 14:52 ` Michael Walle
13 siblings, 0 replies; 21+ messages in thread
From: Michael Walle @ 2026-11-27 14:52 UTC (permalink / raw)
To: William Breathitt Gray, Linus Walleij, Bartosz Golaszewski,
Petar Stepanovic, SriNavmani A, Prasad Bolisetty, Tzu-Hao Wei,
Karthikeyan Mitran, Mathieu Dubois-Briand, Michael Walle,
Lee Jones, Andy Shevchenko, Long Zhao, Joseph Telaak
Cc: linux-gpio, linux-arm-kernel
Now that all users have been converted to the new .create_irq_domain()
callback, remove the old methods.
Also remove the __maybe_unused annotations because the helpers are now
guarded with CONFIG_REGMAP_IRQ.
Signed-off-by: Michael Walle <mwalle@kernel.org>
Tested-by: Joseph Telaak <joseph@telaak.dev>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/gpio/gpio-regmap.c | 34 ++++------------------------------
include/linux/gpio/regmap.h | 17 -----------------
2 files changed, 4 insertions(+), 47 deletions(-)
diff --git a/drivers/gpio/gpio-regmap.c b/drivers/gpio/gpio-regmap.c
index a0d99710dc4f..5d9520143f99 100644
--- a/drivers/gpio/gpio-regmap.c
+++ b/drivers/gpio/gpio-regmap.c
@@ -399,17 +399,17 @@ void gpio_regmap_relres_irq(struct gpio_regmap *gpio, unsigned int offset)
}
EXPORT_SYMBOL_GPL(gpio_regmap_relres_irq);
-static int __maybe_unused gpio_regmap_irq_reqres(void *irq_drv_data, irq_hw_number_t hwirq)
+#ifdef CONFIG_REGMAP_IRQ
+static int gpio_regmap_irq_reqres(void *irq_drv_data, irq_hw_number_t hwirq)
{
return gpio_regmap_reqres_irq(irq_drv_data, hwirq);
}
-static void __maybe_unused gpio_regmap_irq_relres(void *irq_drv_data, irq_hw_number_t hwirq)
+static void gpio_regmap_irq_relres(void *irq_drv_data, irq_hw_number_t hwirq)
{
gpio_regmap_relres_irq(irq_drv_data, hwirq);
}
-#ifdef CONFIG_REGMAP_IRQ
/**
* gpio_regmap_add_irq_chip_nolock() - Add a regmap-irq chip without line locking
* @gpio: gpio_regmap device
@@ -509,7 +509,7 @@ EXPORT_SYMBOL_GPL(gpio_regmap_disable_irq);
*/
struct gpio_regmap *gpio_regmap_register(const struct gpio_regmap_config *config)
{
- struct irq_domain *irq_domain;
+ struct irq_domain *irq_domain = NULL;
struct gpio_regmap *gpio;
struct gpio_chip *chip;
int ret;
@@ -530,14 +530,6 @@ struct gpio_regmap *gpio_regmap_register(const struct gpio_regmap_config *config
if (config->reg_dir_out_base && config->reg_dir_in_base)
return ERR_PTR(-EINVAL);
- /* there is only one way to provide an IRQ domain */
- if (config->create_irq_domain && config->irq_domain)
- return ERR_PTR(-EINVAL);
-#ifdef CONFIG_REGMAP_IRQ
- if (config->create_irq_domain && config->regmap_irq_chip)
- return ERR_PTR(-EINVAL);
-#endif
-
gpio = kzalloc_obj(*gpio);
if (!gpio)
return ERR_PTR(-ENOMEM);
@@ -629,8 +621,6 @@ struct gpio_regmap *gpio_regmap_register(const struct gpio_regmap_config *config
if (ret < 0)
goto err_free_bitmap_output;
- irq_domain = config->irq_domain;
-
if (config->create_irq_domain) {
irq_domain = config->create_irq_domain(gpio);
if (IS_ERR(irq_domain)) {
@@ -640,22 +630,6 @@ struct gpio_regmap *gpio_regmap_register(const struct gpio_regmap_config *config
gpio->remove_irq_domain = config->remove_irq_domain;
}
-#ifdef CONFIG_REGMAP_IRQ
- if (config->regmap_irq_chip) {
- gpio->regmap_irq_line = config->regmap_irq_line;
- config->regmap_irq_chip->irq_reqres = gpio_regmap_irq_reqres;
- config->regmap_irq_chip->irq_relres = gpio_regmap_irq_relres;
- config->regmap_irq_chip->irq_drv_data = gpio;
- ret = regmap_add_irq_chip_fwnode(dev_fwnode(config->parent), config->regmap,
- config->regmap_irq_line, config->regmap_irq_flags,
- 0, config->regmap_irq_chip, &gpio->irq_chip_data);
- if (ret)
- goto err_remove_gpiochip;
-
- irq_domain = regmap_irq_get_domain(gpio->irq_chip_data);
- }
-#endif
-
if (irq_domain) {
ret = gpiochip_irqchip_add_domain(chip, irq_domain);
if (ret)
diff --git a/include/linux/gpio/regmap.h b/include/linux/gpio/regmap.h
index ff2732f909d9..eff3a6f11479 100644
--- a/include/linux/gpio/regmap.h
+++ b/include/linux/gpio/regmap.h
@@ -63,16 +63,11 @@ enum gpio_regmap_operation {
* @reg_stride: (Optional) May be set if the registers (of the
* same type, dat, set, etc) are not consecutive.
* @ngpio_per_reg: (Optional) Number of GPIOs per register
- * @irq_domain: (Optional) IRQ domain if the controller is
- * interrupt-capable. Cannot be used together with the
- * gpio_regmap_*_irq() callbacks. Use @create_irq_domain
- * instead.
* @create_irq_domain: (Optional) Callback to create the IRQ domain in the
* controller driver. Called after the gpio_chip is added
* so the gpio_regmap_*_irq() have a valid gpio_regmap
* pointer. Do NOT use any resource managed allocations in
* this callback.
- * Mutually exclusive with @irq_domain and @regmap_irq_chip.
* @remove_irq_domain: (Optional) Callback to remove the IRQ domain created in
* the .create_irq_domain() callback. Dispose any IRQ
* mappings, remove the IRQ domain and free any resources.
@@ -86,11 +81,6 @@ enum gpio_regmap_operation {
* (Optional) Bitmap representing the fixed direction of
* the GPIO lines. Useful when there are GPIO lines with a
* fixed direction mixed together in the same register.
- * @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.
- * @regmap_irq_line: (Optional) The IRQ the device uses to signal interrupts.
- * @regmap_irq_flags: (Optional) The IRQF_ flags to use for the interrupt.
* @reg_mask_xlate: (Optional) Translates base address and GPIO
* offset to a register/bitmask pair. If not
* given the default gpio_regmap_simple_xlate()
@@ -145,18 +135,11 @@ struct gpio_regmap_config {
unsigned int reg_dir_out_base;
int reg_stride;
int ngpio_per_reg;
- struct irq_domain *irq_domain;
struct irq_domain *(*create_irq_domain)(struct gpio_regmap *gpio);
void (*remove_irq_domain)(struct gpio_regmap *gpio);
unsigned long *fixed_direction_mask;
unsigned long *fixed_direction_output;
-#ifdef CONFIG_REGMAP_IRQ
- struct regmap_irq_chip *regmap_irq_chip;
- int regmap_irq_line;
- unsigned long regmap_irq_flags;
-#endif
-
int (*reg_mask_xlate)(struct gpio_regmap *gpio, enum gpio_regmap_operation,
unsigned int base, unsigned int offset,
unsigned int *reg, unsigned int *mask);
--
2.47.3
^ permalink raw reply related [flat|nested] 21+ messages in thread