linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] pinctrl: microchip-sgpio: make irq_chip immutable
@ 2022-04-28 11:16 Michael Walle
  2022-04-28 16:05 ` Marc Zyngier
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Michael Walle @ 2022-04-28 11:16 UTC (permalink / raw)
  To: Marc Zyngier, Lars Povlsen, Steen Hegelund, Linus Walleij
  Cc: UNGLinuxDriver, linux-arm-kernel, linux-gpio, linux-kernel,
	Michael Walle

Since recently, the kernel is nagging about mutable irq_chips:

[    4.967050] gpio gpiochip1: (e2004190.gpio-input): not an immutable chip, please consider fixing it!

Drop the unneeded copy, flag it as IRQCHIP_IMMUTABLE, add the new
helper functions and call the appropriate gpiolib functions.

Signed-off-by: Michael Walle <michael@walle.cc>
---
 drivers/pinctrl/pinctrl-microchip-sgpio.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-microchip-sgpio.c b/drivers/pinctrl/pinctrl-microchip-sgpio.c
index 80a8939ad0c0..6dbe37d3d558 100644
--- a/drivers/pinctrl/pinctrl-microchip-sgpio.c
+++ b/drivers/pinctrl/pinctrl-microchip-sgpio.c
@@ -688,11 +688,17 @@ static void microchip_sgpio_irq_setreg(struct irq_data *data,
 
 static void microchip_sgpio_irq_mask(struct irq_data *data)
 {
+	struct gpio_chip *chip = irq_data_get_irq_chip_data(data);
+
 	microchip_sgpio_irq_setreg(data, REG_INT_ENABLE, true);
+	gpiochip_disable_irq(chip, data->hwirq);
 }
 
 static void microchip_sgpio_irq_unmask(struct irq_data *data)
 {
+	struct gpio_chip *chip = irq_data_get_irq_chip_data(data);
+
+	gpiochip_enable_irq(chip, data->hwirq);
 	microchip_sgpio_irq_setreg(data, REG_INT_ENABLE, false);
 }
 
@@ -746,6 +752,8 @@ static const struct irq_chip microchip_sgpio_irqchip = {
 	.irq_ack	= microchip_sgpio_irq_ack,
 	.irq_unmask	= microchip_sgpio_irq_unmask,
 	.irq_set_type	= microchip_sgpio_irq_set_type,
+	.flags		= IRQCHIP_IMMUTABLE,
+	GPIOCHIP_IRQ_RESOURCE_HELPERS,
 };
 
 static void sgpio_irq_handler(struct irq_desc *desc)
@@ -861,11 +869,7 @@ static int microchip_sgpio_register_bank(struct device *dev,
 		if (irq) {
 			struct gpio_irq_chip *girq = &gc->irq;
 
-			girq->chip = devm_kmemdup(dev, &microchip_sgpio_irqchip,
-						  sizeof(microchip_sgpio_irqchip),
-						  GFP_KERNEL);
-			if (!girq->chip)
-				return -ENOMEM;
+			gpio_irq_chip_set_chip(girq, &microchip_sgpio_irqchip);
 			girq->parent_handler = sgpio_irq_handler;
 			girq->num_parents = 1;
 			girq->parents = devm_kcalloc(dev, 1,
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] pinctrl: microchip-sgpio: make irq_chip immutable
  2022-04-28 11:16 [PATCH] pinctrl: microchip-sgpio: make irq_chip immutable Michael Walle
@ 2022-04-28 16:05 ` Marc Zyngier
  2022-04-28 22:34 ` Linus Walleij
  2022-05-05 14:55 ` Linus Walleij
  2 siblings, 0 replies; 5+ messages in thread
From: Marc Zyngier @ 2022-04-28 16:05 UTC (permalink / raw)
  To: Michael Walle
  Cc: Lars Povlsen, Steen Hegelund, Linus Walleij, UNGLinuxDriver,
	linux-arm-kernel, linux-gpio, linux-kernel

On Thu, 28 Apr 2022 12:16:22 +0100,
Michael Walle <michael@walle.cc> wrote:
> 
> Since recently, the kernel is nagging about mutable irq_chips:
> 
> [    4.967050] gpio gpiochip1: (e2004190.gpio-input): not an immutable chip, please consider fixing it!
> 
> Drop the unneeded copy, flag it as IRQCHIP_IMMUTABLE, add the new
> helper functions and call the appropriate gpiolib functions.
> 
> Signed-off-by: Michael Walle <michael@walle.cc>

FWIW:

Reviewed-by: Marc Zyngier <maz@kernel.org>

	M.

-- 
Without deviation from the norm, progress is not possible.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] pinctrl: microchip-sgpio: make irq_chip immutable
  2022-04-28 11:16 [PATCH] pinctrl: microchip-sgpio: make irq_chip immutable Michael Walle
  2022-04-28 16:05 ` Marc Zyngier
@ 2022-04-28 22:34 ` Linus Walleij
  2022-05-05 14:55 ` Linus Walleij
  2 siblings, 0 replies; 5+ messages in thread
From: Linus Walleij @ 2022-04-28 22:34 UTC (permalink / raw)
  To: Michael Walle
  Cc: Marc Zyngier, Lars Povlsen, Steen Hegelund, UNGLinuxDriver,
	linux-arm-kernel, linux-gpio, linux-kernel

On Thu, Apr 28, 2022 at 1:16 PM Michael Walle <michael@walle.cc> wrote:

> Since recently, the kernel is nagging about mutable irq_chips:
>
> [    4.967050] gpio gpiochip1: (e2004190.gpio-input): not an immutable chip, please consider fixing it!
>
> Drop the unneeded copy, flag it as IRQCHIP_IMMUTABLE, add the new
> helper functions and call the appropriate gpiolib functions.
>
> Signed-off-by: Michael Walle <michael@walle.cc>

I'm still waiting to see if Bartosz pulls in the prerequisites
to the GPIO tree, when/if he does I will pull it in too and
apply this on top.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] pinctrl: microchip-sgpio: make irq_chip immutable
  2022-04-28 11:16 [PATCH] pinctrl: microchip-sgpio: make irq_chip immutable Michael Walle
  2022-04-28 16:05 ` Marc Zyngier
  2022-04-28 22:34 ` Linus Walleij
@ 2022-05-05 14:55 ` Linus Walleij
  2022-05-05 15:05   ` Marc Zyngier
  2 siblings, 1 reply; 5+ messages in thread
From: Linus Walleij @ 2022-05-05 14:55 UTC (permalink / raw)
  To: Michael Walle
  Cc: Marc Zyngier, Lars Povlsen, Steen Hegelund, UNGLinuxDriver,
	linux-arm-kernel, linux-gpio, linux-kernel

On Thu, Apr 28, 2022 at 1:16 PM Michael Walle <michael@walle.cc> wrote:

> Since recently, the kernel is nagging about mutable irq_chips:
>
> [    4.967050] gpio gpiochip1: (e2004190.gpio-input): not an immutable chip, please consider fixing it!
>
> Drop the unneeded copy, flag it as IRQCHIP_IMMUTABLE, add the new
> helper functions and call the appropriate gpiolib functions.
>
> Signed-off-by: Michael Walle <michael@walle.cc>

Patch applied after pulling in Marc's immutable branch.

(Hm a bit confusing since it is a immutable branch with code
for immutable GPIO chips ... I assume it is both.)

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] pinctrl: microchip-sgpio: make irq_chip immutable
  2022-05-05 14:55 ` Linus Walleij
@ 2022-05-05 15:05   ` Marc Zyngier
  0 siblings, 0 replies; 5+ messages in thread
From: Marc Zyngier @ 2022-05-05 15:05 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Michael Walle, Lars Povlsen, Steen Hegelund, UNGLinuxDriver,
	linux-arm-kernel, linux-gpio, linux-kernel

On Thu, 05 May 2022 15:55:01 +0100,
Linus Walleij <linus.walleij@linaro.org> wrote:
> 
> On Thu, Apr 28, 2022 at 1:16 PM Michael Walle <michael@walle.cc> wrote:
> 
> > Since recently, the kernel is nagging about mutable irq_chips:
> >
> > [    4.967050] gpio gpiochip1: (e2004190.gpio-input): not an immutable chip, please consider fixing it!
> >
> > Drop the unneeded copy, flag it as IRQCHIP_IMMUTABLE, add the new
> > helper functions and call the appropriate gpiolib functions.
> >
> > Signed-off-by: Michael Walle <michael@walle.cc>
> 
> Patch applied after pulling in Marc's immutable branch.
> 
> (Hm a bit confusing since it is a immutable branch with code
> for immutable GPIO chips ... I assume it is both.)

Both indeed. Immutable^2, or something like that.

	M.

-- 
Without deviation from the norm, progress is not possible.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-05-05 15:05 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-04-28 11:16 [PATCH] pinctrl: microchip-sgpio: make irq_chip immutable Michael Walle
2022-04-28 16:05 ` Marc Zyngier
2022-04-28 22:34 ` Linus Walleij
2022-05-05 14:55 ` Linus Walleij
2022-05-05 15:05   ` Marc Zyngier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).