All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] gpio: mt7621: Make the irqchip immutable
@ 2022-09-13 16:46 Sergio Paracuellos
  2022-09-13 16:46 ` [PATCH v2] gpio: mt7621: Switch to use platform_get_irq() function Sergio Paracuellos
  2022-09-14 12:19 ` [PATCH v2] gpio: mt7621: Make the irqchip immutable Bartosz Golaszewski
  0 siblings, 2 replies; 4+ messages in thread
From: Sergio Paracuellos @ 2022-09-13 16:46 UTC (permalink / raw)
  To: linux-gpio; +Cc: linus.walleij, brgl, arinc.unal, matthias.bgg, neil

Commit 6c846d026d49 ("gpio: Don't fiddle with irqchips marked as
immutable") added a warning to indicate if the gpiolib is altering the
internals of irqchips.  Following this change the following warnings
are now observed for the mt7621 driver:

gpio gpiochip0: (1e000600.gpio-bank0): not an immutable chip, please consider fixing it!
gpio gpiochip1: (1e000600.gpio-bank1): not an immutable chip, please consider fixing it!
gpio gpiochip2: (1e000600.gpio-bank2): not an immutable chip, please consider fixing it!

Fix this by making the irqchip in the mt7621 driver immutable.

Tested-by: Arınç ÜNAL <arinc.unal@arinc9.com>
Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
---
Changes in v2:
- Make independent PATCH since this must go to fixes branch.

 drivers/gpio/gpio-mt7621.c | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/drivers/gpio/gpio-mt7621.c b/drivers/gpio/gpio-mt7621.c
index d8a26e503ca5..f163f5ca857b 100644
--- a/drivers/gpio/gpio-mt7621.c
+++ b/drivers/gpio/gpio-mt7621.c
@@ -112,6 +112,8 @@ mediatek_gpio_irq_unmask(struct irq_data *d)
 	unsigned long flags;
 	u32 rise, fall, high, low;
 
+	gpiochip_enable_irq(gc, d->hwirq);
+
 	spin_lock_irqsave(&rg->lock, flags);
 	rise = mtk_gpio_r32(rg, GPIO_REG_REDGE);
 	fall = mtk_gpio_r32(rg, GPIO_REG_FEDGE);
@@ -143,6 +145,8 @@ mediatek_gpio_irq_mask(struct irq_data *d)
 	mtk_gpio_w32(rg, GPIO_REG_HLVL, high & ~BIT(pin));
 	mtk_gpio_w32(rg, GPIO_REG_LLVL, low & ~BIT(pin));
 	spin_unlock_irqrestore(&rg->lock, flags);
+
+	gpiochip_disable_irq(gc, d->hwirq);
 }
 
 static int
@@ -204,6 +208,16 @@ mediatek_gpio_xlate(struct gpio_chip *chip,
 	return gpio % MTK_BANK_WIDTH;
 }
 
+static const struct irq_chip mt7621_irq_chip = {
+	.name		= "mt7621-gpio",
+	.irq_mask_ack	= mediatek_gpio_irq_mask,
+	.irq_mask	= mediatek_gpio_irq_mask,
+	.irq_unmask	= mediatek_gpio_irq_unmask,
+	.irq_set_type	= mediatek_gpio_irq_type,
+	.flags		= IRQCHIP_IMMUTABLE,
+	GPIOCHIP_IRQ_RESOURCE_HELPERS,
+};
+
 static int
 mediatek_gpio_bank_probe(struct device *dev, int bank)
 {
@@ -238,11 +252,6 @@ mediatek_gpio_bank_probe(struct device *dev, int bank)
 		return -ENOMEM;
 
 	rg->chip.offset = bank * MTK_BANK_WIDTH;
-	rg->irq_chip.name = dev_name(dev);
-	rg->irq_chip.irq_unmask = mediatek_gpio_irq_unmask;
-	rg->irq_chip.irq_mask = mediatek_gpio_irq_mask;
-	rg->irq_chip.irq_mask_ack = mediatek_gpio_irq_mask;
-	rg->irq_chip.irq_set_type = mediatek_gpio_irq_type;
 
 	if (mtk->gpio_irq) {
 		struct gpio_irq_chip *girq;
@@ -262,7 +271,7 @@ mediatek_gpio_bank_probe(struct device *dev, int bank)
 		}
 
 		girq = &rg->chip.irq;
-		girq->chip = &rg->irq_chip;
+		gpio_irq_chip_set_chip(girq, &mt7621_irq_chip);
 		/* This will let us handle the parent IRQ in the driver */
 		girq->parent_handler = NULL;
 		girq->num_parents = 0;
-- 
2.25.1


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

* [PATCH v2] gpio: mt7621: Switch to use platform_get_irq() function
  2022-09-13 16:46 [PATCH v2] gpio: mt7621: Make the irqchip immutable Sergio Paracuellos
@ 2022-09-13 16:46 ` Sergio Paracuellos
  2022-09-14 12:24   ` Bartosz Golaszewski
  2022-09-14 12:19 ` [PATCH v2] gpio: mt7621: Make the irqchip immutable Bartosz Golaszewski
  1 sibling, 1 reply; 4+ messages in thread
From: Sergio Paracuellos @ 2022-09-13 16:46 UTC (permalink / raw)
  To: linux-gpio; +Cc: linus.walleij, brgl, arinc.unal, matthias.bgg, neil

Mt7621 SoC GPIO driver is a platform driver so we can directly use
'platform_get_irq' instead of 'irq_of_parse_and_map'.

Tested-by: Arınç ÜNAL <arinc.unal@arinc9.com>
Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
---
Change in v2:
- Make independent PATCH since this must go to next branch.

 drivers/gpio/gpio-mt7621.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/gpio/gpio-mt7621.c b/drivers/gpio/gpio-mt7621.c
index f163f5ca857b..93facbebb80e 100644
--- a/drivers/gpio/gpio-mt7621.c
+++ b/drivers/gpio/gpio-mt7621.c
@@ -9,7 +9,6 @@
 #include <linux/interrupt.h>
 #include <linux/io.h>
 #include <linux/module.h>
-#include <linux/of_irq.h>
 #include <linux/platform_device.h>
 #include <linux/spinlock.h>
 
@@ -299,7 +298,6 @@ static int
 mediatek_gpio_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
-	struct device_node *np = dev->of_node;
 	struct mtk *mtk;
 	int i;
 	int ret;
@@ -312,7 +310,10 @@ mediatek_gpio_probe(struct platform_device *pdev)
 	if (IS_ERR(mtk->base))
 		return PTR_ERR(mtk->base);
 
-	mtk->gpio_irq = irq_of_parse_and_map(np, 0);
+	mtk->gpio_irq = platform_get_irq(pdev, 0);
+	if (mtk->gpio_irq < 0)
+		return mtk->gpio_irq;
+
 	mtk->dev = dev;
 	platform_set_drvdata(pdev, mtk);
 
-- 
2.25.1


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

* Re: [PATCH v2] gpio: mt7621: Make the irqchip immutable
  2022-09-13 16:46 [PATCH v2] gpio: mt7621: Make the irqchip immutable Sergio Paracuellos
  2022-09-13 16:46 ` [PATCH v2] gpio: mt7621: Switch to use platform_get_irq() function Sergio Paracuellos
@ 2022-09-14 12:19 ` Bartosz Golaszewski
  1 sibling, 0 replies; 4+ messages in thread
From: Bartosz Golaszewski @ 2022-09-14 12:19 UTC (permalink / raw)
  To: Sergio Paracuellos
  Cc: linux-gpio, linus.walleij, arinc.unal, matthias.bgg, neil

On Tue, Sep 13, 2022 at 6:46 PM Sergio Paracuellos
<sergio.paracuellos@gmail.com> wrote:
>
> Commit 6c846d026d49 ("gpio: Don't fiddle with irqchips marked as
> immutable") added a warning to indicate if the gpiolib is altering the
> internals of irqchips.  Following this change the following warnings
> are now observed for the mt7621 driver:
>
> gpio gpiochip0: (1e000600.gpio-bank0): not an immutable chip, please consider fixing it!
> gpio gpiochip1: (1e000600.gpio-bank1): not an immutable chip, please consider fixing it!
> gpio gpiochip2: (1e000600.gpio-bank2): not an immutable chip, please consider fixing it!
>
> Fix this by making the irqchip in the mt7621 driver immutable.
>
> Tested-by: Arınç ÜNAL <arinc.unal@arinc9.com>
> Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
> ---

Queued for fixes.

Bart

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

* Re: [PATCH v2] gpio: mt7621: Switch to use platform_get_irq() function
  2022-09-13 16:46 ` [PATCH v2] gpio: mt7621: Switch to use platform_get_irq() function Sergio Paracuellos
@ 2022-09-14 12:24   ` Bartosz Golaszewski
  0 siblings, 0 replies; 4+ messages in thread
From: Bartosz Golaszewski @ 2022-09-14 12:24 UTC (permalink / raw)
  To: Sergio Paracuellos
  Cc: linux-gpio, linus.walleij, arinc.unal, matthias.bgg, neil

On Tue, Sep 13, 2022 at 6:46 PM Sergio Paracuellos
<sergio.paracuellos@gmail.com> wrote:
>
> Mt7621 SoC GPIO driver is a platform driver so we can directly use
> 'platform_get_irq' instead of 'irq_of_parse_and_map'.
>
> Tested-by: Arınç ÜNAL <arinc.unal@arinc9.com>
> Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
> ---
> Change in v2:
> - Make independent PATCH since this must go to next branch.
>
>  drivers/gpio/gpio-mt7621.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpio/gpio-mt7621.c b/drivers/gpio/gpio-mt7621.c
> index f163f5ca857b..93facbebb80e 100644
> --- a/drivers/gpio/gpio-mt7621.c
> +++ b/drivers/gpio/gpio-mt7621.c
> @@ -9,7 +9,6 @@
>  #include <linux/interrupt.h>
>  #include <linux/io.h>
>  #include <linux/module.h>
> -#include <linux/of_irq.h>
>  #include <linux/platform_device.h>
>  #include <linux/spinlock.h>
>
> @@ -299,7 +298,6 @@ static int
>  mediatek_gpio_probe(struct platform_device *pdev)
>  {
>         struct device *dev = &pdev->dev;
> -       struct device_node *np = dev->of_node;
>         struct mtk *mtk;
>         int i;
>         int ret;
> @@ -312,7 +310,10 @@ mediatek_gpio_probe(struct platform_device *pdev)
>         if (IS_ERR(mtk->base))
>                 return PTR_ERR(mtk->base);
>
> -       mtk->gpio_irq = irq_of_parse_and_map(np, 0);
> +       mtk->gpio_irq = platform_get_irq(pdev, 0);
> +       if (mtk->gpio_irq < 0)
> +               return mtk->gpio_irq;
> +
>         mtk->dev = dev;
>         platform_set_drvdata(pdev, mtk);
>
> --
> 2.25.1
>

Applied, thanks!

Bart

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

end of thread, other threads:[~2022-09-14 12:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-13 16:46 [PATCH v2] gpio: mt7621: Make the irqchip immutable Sergio Paracuellos
2022-09-13 16:46 ` [PATCH v2] gpio: mt7621: Switch to use platform_get_irq() function Sergio Paracuellos
2022-09-14 12:24   ` Bartosz Golaszewski
2022-09-14 12:19 ` [PATCH v2] gpio: mt7621: Make the irqchip immutable Bartosz Golaszewski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.