linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V4 0/3] Make the irqchip immutable
@ 2022-12-29 14:55 Cixi Geng
  2022-12-29 14:55 ` [PATCH V4 1/3] gpio: eic-sprd: " Cixi Geng
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Cixi Geng @ 2022-12-29 14:55 UTC (permalink / raw)
  To: linus.walleij, brgl, orsonzhai, baolin.wang, zhang.lyra
  Cc: linux-gpio, linux-kernel, cixi.geng1

From: Cixi Geng <cixi.geng1@unisoc.com>

Kernel warns about mutable irq_chips:
    "not an immutable chip, please consider fixing!"

Make the struct irq_chip const, flag it as IRQCHIP_IMMUTABLE, add the
new helper functions, and call the appropriate gpiolib functions.

v2 changes:
Split the patch by each driver. and other comment by baolin in[1]

v3 changes:
Fix cocci warnings test by lkp[2].

v4 changes:
Change the irq name.
Keep the same coding style by using offset for irqd_to_hwirq(data)
Add Reviewed-by tag.

[1]:https://lore.kernel.org/all/97e244d4-6b5c-31c9-7329-b8deef615645@linux.alibaba.com/
[2]:https://lore.kernel.org/all/202212240406.9Nm190P8-lkp@intel.com/

Cixi Geng (3):
  gpio: eic-sprd: Make the irqchip immutable
  gpio: gpio-pmic-eic-sprd: Make the irqchip immutable
  gpio: gpio-sprd: Make the irqchip immutable

 drivers/gpio/gpio-eic-sprd.c      | 23 ++++++++++++++---------
 drivers/gpio/gpio-pmic-eic-sprd.c | 29 ++++++++++++++++++-----------
 drivers/gpio/gpio-sprd.c          |  9 ++++++---
 3 files changed, 38 insertions(+), 23 deletions(-)


base-commit: 1b929c02afd37871d5afb9d498426f83432e71c2
-- 
2.34.1


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

* [PATCH V4 1/3] gpio: eic-sprd: Make the irqchip immutable
  2022-12-29 14:55 [PATCH V4 0/3] Make the irqchip immutable Cixi Geng
@ 2022-12-29 14:55 ` Cixi Geng
  2022-12-29 14:55 ` [PATCH V4 2/3] gpio: gpio-pmic-eic-sprd: " Cixi Geng
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Cixi Geng @ 2022-12-29 14:55 UTC (permalink / raw)
  To: linus.walleij, brgl, orsonzhai, baolin.wang, zhang.lyra
  Cc: linux-gpio, linux-kernel, cixi.geng1

From: Cixi Geng <cixi.geng1@unisoc.com>

Remove the irq_chip from pmic_eic structure,
use the various calls by defining the statically
irq_chip structure.

Signed-off-by: Cixi Geng <cixi.geng1@unisoc.com>
Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>
---
 drivers/gpio/gpio-eic-sprd.c | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/drivers/gpio/gpio-eic-sprd.c b/drivers/gpio/gpio-eic-sprd.c
index 8d722e026e9c..84352a6f4973 100644
--- a/drivers/gpio/gpio-eic-sprd.c
+++ b/drivers/gpio/gpio-eic-sprd.c
@@ -91,7 +91,6 @@ enum sprd_eic_type {
 
 struct sprd_eic {
 	struct gpio_chip chip;
-	struct irq_chip intc;
 	void __iomem *base[SPRD_EIC_MAX_BANK];
 	enum sprd_eic_type type;
 	spinlock_t lock;
@@ -255,6 +254,8 @@ static void sprd_eic_irq_mask(struct irq_data *data)
 	default:
 		dev_err(chip->parent, "Unsupported EIC type.\n");
 	}
+
+	gpiochip_disable_irq(chip, offset);
 }
 
 static void sprd_eic_irq_unmask(struct irq_data *data)
@@ -263,6 +264,8 @@ static void sprd_eic_irq_unmask(struct irq_data *data)
 	struct sprd_eic *sprd_eic = gpiochip_get_data(chip);
 	u32 offset = irqd_to_hwirq(data);
 
+	gpiochip_enable_irq(chip, offset);
+
 	switch (sprd_eic->type) {
 	case SPRD_EIC_DEBOUNCE:
 		sprd_eic_update(chip, offset, SPRD_EIC_DBNC_IE, 1);
@@ -564,6 +567,15 @@ static void sprd_eic_irq_handler(struct irq_desc *desc)
 	chained_irq_exit(ic, desc);
 }
 
+static const struct irq_chip sprd_eic_irq = {
+	.name		= "sprd-eic",
+	.irq_ack	= sprd_eic_irq_ack,
+	.irq_mask	= sprd_eic_irq_mask,
+	.irq_unmask	= sprd_eic_irq_unmask,
+	.irq_set_type	= sprd_eic_irq_set_type,
+	.flags		= IRQCHIP_SKIP_SET_WAKE | IRQCHIP_IMMUTABLE,
+	GPIOCHIP_IRQ_RESOURCE_HELPERS,
+};
 static int sprd_eic_probe(struct platform_device *pdev)
 {
 	const struct sprd_eic_variant_data *pdata;
@@ -626,15 +638,8 @@ static int sprd_eic_probe(struct platform_device *pdev)
 		break;
 	}
 
-	sprd_eic->intc.name = dev_name(&pdev->dev);
-	sprd_eic->intc.irq_ack = sprd_eic_irq_ack;
-	sprd_eic->intc.irq_mask = sprd_eic_irq_mask;
-	sprd_eic->intc.irq_unmask = sprd_eic_irq_unmask;
-	sprd_eic->intc.irq_set_type = sprd_eic_irq_set_type;
-	sprd_eic->intc.flags = IRQCHIP_SKIP_SET_WAKE;
-
 	irq = &sprd_eic->chip.irq;
-	irq->chip = &sprd_eic->intc;
+	gpio_irq_chip_set_chip(irq, &sprd_eic_irq);
 	irq->handler = handle_bad_irq;
 	irq->default_type = IRQ_TYPE_NONE;
 	irq->parent_handler = sprd_eic_irq_handler;
-- 
2.34.1


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

* [PATCH V4 2/3] gpio: gpio-pmic-eic-sprd: Make the irqchip immutable
  2022-12-29 14:55 [PATCH V4 0/3] Make the irqchip immutable Cixi Geng
  2022-12-29 14:55 ` [PATCH V4 1/3] gpio: eic-sprd: " Cixi Geng
@ 2022-12-29 14:55 ` Cixi Geng
  2022-12-29 14:55 ` [PATCH V4 3/3] gpio: gpio-sprd: " Cixi Geng
  2022-12-30 15:59 ` [PATCH V4 0/3] " Bartosz Golaszewski
  3 siblings, 0 replies; 5+ messages in thread
From: Cixi Geng @ 2022-12-29 14:55 UTC (permalink / raw)
  To: linus.walleij, brgl, orsonzhai, baolin.wang, zhang.lyra
  Cc: linux-gpio, linux-kernel, cixi.geng1

From: Cixi Geng <cixi.geng1@unisoc.com>

Remove the irq_chip from pmic_eic structure,
use the various calls by defining the statically
irq_chip structure.

Signed-off-by: Cixi Geng <cixi.geng1@unisoc.com>
Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>
---
 drivers/gpio/gpio-pmic-eic-sprd.c | 29 ++++++++++++++++++-----------
 1 file changed, 18 insertions(+), 11 deletions(-)

diff --git a/drivers/gpio/gpio-pmic-eic-sprd.c b/drivers/gpio/gpio-pmic-eic-sprd.c
index e518490c4b68..c3e4d90f6b18 100644
--- a/drivers/gpio/gpio-pmic-eic-sprd.c
+++ b/drivers/gpio/gpio-pmic-eic-sprd.c
@@ -47,7 +47,6 @@ enum {
 /**
  * struct sprd_pmic_eic - PMIC EIC controller
  * @chip: the gpio_chip structure.
- * @intc: the irq_chip structure.
  * @map:  the regmap from the parent device.
  * @offset: the EIC controller's offset address of the PMIC.
  * @reg: the array to cache the EIC registers.
@@ -56,7 +55,6 @@ enum {
  */
 struct sprd_pmic_eic {
 	struct gpio_chip chip;
-	struct irq_chip intc;
 	struct regmap *map;
 	u32 offset;
 	u8 reg[CACHE_NR_REGS];
@@ -151,15 +149,21 @@ static void sprd_pmic_eic_irq_mask(struct irq_data *data)
 {
 	struct gpio_chip *chip = irq_data_get_irq_chip_data(data);
 	struct sprd_pmic_eic *pmic_eic = gpiochip_get_data(chip);
+	u32 offset = irqd_to_hwirq(data);
 
 	pmic_eic->reg[REG_IE] = 0;
 	pmic_eic->reg[REG_TRIG] = 0;
+
+	gpiochip_disable_irq(chip, offset);
 }
 
 static void sprd_pmic_eic_irq_unmask(struct irq_data *data)
 {
 	struct gpio_chip *chip = irq_data_get_irq_chip_data(data);
 	struct sprd_pmic_eic *pmic_eic = gpiochip_get_data(chip);
+	u32 offset = irqd_to_hwirq(data);
+
+	gpiochip_enable_irq(chip, offset);
 
 	pmic_eic->reg[REG_IE] = 1;
 	pmic_eic->reg[REG_TRIG] = 1;
@@ -292,6 +296,17 @@ static irqreturn_t sprd_pmic_eic_irq_handler(int irq, void *data)
 	return IRQ_HANDLED;
 }
 
+static const struct irq_chip pmic_eic_irq_chip = {
+	.name			= "sprd-pmic-eic",
+	.irq_mask		= sprd_pmic_eic_irq_mask,
+	.irq_unmask		= sprd_pmic_eic_irq_unmask,
+	.irq_set_type		= sprd_pmic_eic_irq_set_type,
+	.irq_bus_lock		= sprd_pmic_eic_bus_lock,
+	.irq_bus_sync_unlock	= sprd_pmic_eic_bus_sync_unlock,
+	.flags			= IRQCHIP_SKIP_SET_WAKE | IRQCHIP_IMMUTABLE,
+	GPIOCHIP_IRQ_RESOURCE_HELPERS,
+};
+
 static int sprd_pmic_eic_probe(struct platform_device *pdev)
 {
 	struct gpio_irq_chip *irq;
@@ -338,16 +353,8 @@ static int sprd_pmic_eic_probe(struct platform_device *pdev)
 	pmic_eic->chip.set = sprd_pmic_eic_set;
 	pmic_eic->chip.get = sprd_pmic_eic_get;
 
-	pmic_eic->intc.name = dev_name(&pdev->dev);
-	pmic_eic->intc.irq_mask = sprd_pmic_eic_irq_mask;
-	pmic_eic->intc.irq_unmask = sprd_pmic_eic_irq_unmask;
-	pmic_eic->intc.irq_set_type = sprd_pmic_eic_irq_set_type;
-	pmic_eic->intc.irq_bus_lock = sprd_pmic_eic_bus_lock;
-	pmic_eic->intc.irq_bus_sync_unlock = sprd_pmic_eic_bus_sync_unlock;
-	pmic_eic->intc.flags = IRQCHIP_SKIP_SET_WAKE;
-
 	irq = &pmic_eic->chip.irq;
-	irq->chip = &pmic_eic->intc;
+	gpio_irq_chip_set_chip(irq, &pmic_eic_irq_chip);
 	irq->threaded = true;
 
 	ret = devm_gpiochip_add_data(&pdev->dev, &pmic_eic->chip, pmic_eic);
-- 
2.34.1


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

* [PATCH V4 3/3] gpio: gpio-sprd: Make the irqchip immutable
  2022-12-29 14:55 [PATCH V4 0/3] Make the irqchip immutable Cixi Geng
  2022-12-29 14:55 ` [PATCH V4 1/3] gpio: eic-sprd: " Cixi Geng
  2022-12-29 14:55 ` [PATCH V4 2/3] gpio: gpio-pmic-eic-sprd: " Cixi Geng
@ 2022-12-29 14:55 ` Cixi Geng
  2022-12-30 15:59 ` [PATCH V4 0/3] " Bartosz Golaszewski
  3 siblings, 0 replies; 5+ messages in thread
From: Cixi Geng @ 2022-12-29 14:55 UTC (permalink / raw)
  To: linus.walleij, brgl, orsonzhai, baolin.wang, zhang.lyra
  Cc: linux-gpio, linux-kernel, cixi.geng1

From: Cixi Geng <cixi.geng1@unisoc.com>

Make the struct irq_chip const, flag it as IRQCHIP_IMMUTABLE, add the
new helper functions, and call the appropriate gpiolib functions.

Signed-off-by: Cixi Geng <cixi.geng1@unisoc.com>
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Julia Lawall <julia.lawall@lip6.fr>
Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>
---
 drivers/gpio/gpio-sprd.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/gpio/gpio-sprd.c b/drivers/gpio/gpio-sprd.c
index 9bff63990eee..072b4e653216 100644
--- a/drivers/gpio/gpio-sprd.c
+++ b/drivers/gpio/gpio-sprd.c
@@ -120,6 +120,7 @@ static void sprd_gpio_irq_mask(struct irq_data *data)
 	u32 offset = irqd_to_hwirq(data);
 
 	sprd_gpio_update(chip, offset, SPRD_GPIO_IE, 0);
+	gpiochip_disable_irq(chip, offset);
 }
 
 static void sprd_gpio_irq_ack(struct irq_data *data)
@@ -136,6 +137,7 @@ static void sprd_gpio_irq_unmask(struct irq_data *data)
 	u32 offset = irqd_to_hwirq(data);
 
 	sprd_gpio_update(chip, offset, SPRD_GPIO_IE, 1);
+	gpiochip_enable_irq(chip, offset);
 }
 
 static int sprd_gpio_irq_set_type(struct irq_data *data,
@@ -205,13 +207,14 @@ static void sprd_gpio_irq_handler(struct irq_desc *desc)
 	chained_irq_exit(ic, desc);
 }
 
-static struct irq_chip sprd_gpio_irqchip = {
+static const struct irq_chip sprd_gpio_irqchip = {
 	.name = "sprd-gpio",
 	.irq_ack = sprd_gpio_irq_ack,
 	.irq_mask = sprd_gpio_irq_mask,
 	.irq_unmask = sprd_gpio_irq_unmask,
 	.irq_set_type = sprd_gpio_irq_set_type,
-	.flags = IRQCHIP_SKIP_SET_WAKE,
+	.flags = IRQCHIP_SKIP_SET_WAKE | IRQCHIP_IMMUTABLE,
+	GPIOCHIP_IRQ_RESOURCE_HELPERS,
 };
 
 static int sprd_gpio_probe(struct platform_device *pdev)
@@ -245,7 +248,7 @@ static int sprd_gpio_probe(struct platform_device *pdev)
 	sprd_gpio->chip.direction_output = sprd_gpio_direction_output;
 
 	irq = &sprd_gpio->chip.irq;
-	irq->chip = &sprd_gpio_irqchip;
+	gpio_irq_chip_set_chip(irq, &sprd_gpio_irqchip);
 	irq->handler = handle_bad_irq;
 	irq->default_type = IRQ_TYPE_NONE;
 	irq->parent_handler = sprd_gpio_irq_handler;
-- 
2.34.1


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

* Re: [PATCH V4 0/3] Make the irqchip immutable
  2022-12-29 14:55 [PATCH V4 0/3] Make the irqchip immutable Cixi Geng
                   ` (2 preceding siblings ...)
  2022-12-29 14:55 ` [PATCH V4 3/3] gpio: gpio-sprd: " Cixi Geng
@ 2022-12-30 15:59 ` Bartosz Golaszewski
  3 siblings, 0 replies; 5+ messages in thread
From: Bartosz Golaszewski @ 2022-12-30 15:59 UTC (permalink / raw)
  To: Cixi Geng
  Cc: linus.walleij, orsonzhai, baolin.wang, zhang.lyra, linux-gpio,
	linux-kernel, cixi.geng1

On Thu, Dec 29, 2022 at 3:56 PM Cixi Geng <cixi.geng@linux.dev> wrote:
>
> From: Cixi Geng <cixi.geng1@unisoc.com>
>
> Kernel warns about mutable irq_chips:
>     "not an immutable chip, please consider fixing!"
>
> Make the struct irq_chip const, flag it as IRQCHIP_IMMUTABLE, add the
> new helper functions, and call the appropriate gpiolib functions.
>
> v2 changes:
> Split the patch by each driver. and other comment by baolin in[1]
>
> v3 changes:
> Fix cocci warnings test by lkp[2].
>
> v4 changes:
> Change the irq name.
> Keep the same coding style by using offset for irqd_to_hwirq(data)
> Add Reviewed-by tag.
>
> [1]:https://lore.kernel.org/all/97e244d4-6b5c-31c9-7329-b8deef615645@linux.alibaba.com/
> [2]:https://lore.kernel.org/all/202212240406.9Nm190P8-lkp@intel.com/
>
> Cixi Geng (3):
>   gpio: eic-sprd: Make the irqchip immutable
>   gpio: gpio-pmic-eic-sprd: Make the irqchip immutable
>   gpio: gpio-sprd: Make the irqchip immutable
>
>  drivers/gpio/gpio-eic-sprd.c      | 23 ++++++++++++++---------
>  drivers/gpio/gpio-pmic-eic-sprd.c | 29 ++++++++++++++++++-----------
>  drivers/gpio/gpio-sprd.c          |  9 ++++++---
>  3 files changed, 38 insertions(+), 23 deletions(-)
>
>
> base-commit: 1b929c02afd37871d5afb9d498426f83432e71c2
> --
> 2.34.1
>

Series queued for fixes, thanks!

Bart

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

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

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-29 14:55 [PATCH V4 0/3] Make the irqchip immutable Cixi Geng
2022-12-29 14:55 ` [PATCH V4 1/3] gpio: eic-sprd: " Cixi Geng
2022-12-29 14:55 ` [PATCH V4 2/3] gpio: gpio-pmic-eic-sprd: " Cixi Geng
2022-12-29 14:55 ` [PATCH V4 3/3] gpio: gpio-sprd: " Cixi Geng
2022-12-30 15:59 ` [PATCH V4 0/3] " Bartosz Golaszewski

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).