mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Peng Fan (OSS)" <peng.fan@oss.nxp.com>
To: Ray Jui <rjui@broadcom.com>,
	 Broadcom internal kernel review list
	<bcm-kernel-feedback-list@broadcom.com>,
	 Linus Walleij <linus.walleij@linaro.org>,
	 Bartosz Golaszewski <brgl@bgdev.pl>,
	 Florian Fainelli <florian.fainelli@broadcom.com>,
	 Scott Branden <sbranden@broadcom.com>,
	Vladimir Zapolskiy <vz@mleia.com>,  Keerthy <j-keerthy@ti.com>,
	Robert Jarzmik <robert.jarzmik@free.fr>
Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
	 linux-arm-kernel@lists.infradead.org,
	Peng Fan <peng.fan@nxp.com>
Subject: [PATCH RFC 3/9] gpio: lpc18xx: Make irq_chip immutable
Date: Fri, 09 May 2025 12:45:34 +0800	[thread overview]
Message-ID: <20250509-gpio-v1-3-639377c98288@nxp.com> (raw)
In-Reply-To: <20250509-gpio-v1-0-639377c98288@nxp.com>

From: Peng Fan <peng.fan@nxp.com>

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

Constify lpc18xx_gpio_pin_ic, flag the irq_chip as IRQCHIP_IMMUTABLE,
add the new helper functions, and call the appropriate gpiolib functions.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/gpio/gpio-lpc18xx.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/gpio/gpio-lpc18xx.c b/drivers/gpio/gpio-lpc18xx.c
index ae6182cce7234166fe94ab0c8d5e07c11bb71101..a2e316d9350b736e8bb89c17845d70cc74481d1b 100644
--- a/drivers/gpio/gpio-lpc18xx.c
+++ b/drivers/gpio/gpio-lpc18xx.c
@@ -42,6 +42,7 @@ struct lpc18xx_gpio_pin_ic {
 	void __iomem *base;
 	struct irq_domain *domain;
 	struct raw_spinlock lock;
+	struct gpio_chip *gpio;
 };
 
 struct lpc18xx_gpio_chip {
@@ -74,6 +75,7 @@ static void lpc18xx_gpio_pin_ic_mask(struct irq_data *d)
 {
 	struct lpc18xx_gpio_pin_ic *ic = d->chip_data;
 	u32 type = irqd_get_trigger_type(d);
+	irq_hw_number_t hwirq = irqd_to_hwirq(d);
 
 	raw_spin_lock(&ic->lock);
 
@@ -88,12 +90,17 @@ static void lpc18xx_gpio_pin_ic_mask(struct irq_data *d)
 	raw_spin_unlock(&ic->lock);
 
 	irq_chip_mask_parent(d);
+
+	gpiochip_disable_irq(ic->gpio, hwirq);
 }
 
 static void lpc18xx_gpio_pin_ic_unmask(struct irq_data *d)
 {
 	struct lpc18xx_gpio_pin_ic *ic = d->chip_data;
 	u32 type = irqd_get_trigger_type(d);
+	irq_hw_number_t hwirq = irqd_to_hwirq(d);
+
+	gpiochip_enable_irq(ic->gpio, hwirq);
 
 	raw_spin_lock(&ic->lock);
 
@@ -149,13 +156,14 @@ static int lpc18xx_gpio_pin_ic_set_type(struct irq_data *d, unsigned int type)
 	return 0;
 }
 
-static struct irq_chip lpc18xx_gpio_pin_ic = {
+static const struct irq_chip lpc18xx_gpio_pin_ic = {
 	.name		= "LPC18xx GPIO pin",
 	.irq_mask	= lpc18xx_gpio_pin_ic_mask,
 	.irq_unmask	= lpc18xx_gpio_pin_ic_unmask,
 	.irq_eoi	= lpc18xx_gpio_pin_ic_eoi,
 	.irq_set_type	= lpc18xx_gpio_pin_ic_set_type,
-	.flags		= IRQCHIP_SET_TYPE_MASKED,
+	.flags		= IRQCHIP_IMMUTABLE | IRQCHIP_SET_TYPE_MASKED,
+	GPIOCHIP_IRQ_RESOURCE_HELPERS,
 };
 
 static int lpc18xx_gpio_pin_ic_domain_alloc(struct irq_domain *domain,
@@ -249,6 +257,7 @@ static int lpc18xx_gpio_pin_ic_probe(struct lpc18xx_gpio_chip *gc)
 		goto free_iomap;
 	}
 
+	ic->gpio = &gc->gpio;
 	gc->pin_ic = ic;
 
 	return 0;

-- 
2.37.1


  parent reply	other threads:[~2025-05-09  4:47 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-09  4:45 [PATCH RFC 0/9] gpio: make " Peng Fan (OSS)
2025-05-09  4:45 ` [PATCH RFC 1/9] gpio: bcm-kona: " Peng Fan (OSS)
2025-05-09  4:45 ` [PATCH RFC 2/9] gpio: grgpio: Make " Peng Fan (OSS)
2025-05-09  4:45 ` Peng Fan (OSS) [this message]
2025-05-09  4:45 ` [PATCH RFC 4/9] gpio: mpc8xxx: " Peng Fan (OSS)
2025-05-09  4:45 ` [PATCH RFC 5/9] gpio: davinci: Update irq chip data Peng Fan (OSS)
2025-05-09  4:45 ` [PATCH RFC 6/9] gpio: davinci: Make irq_chip immutable Peng Fan (OSS)
2025-05-09  4:45 ` [PATCH RFC 7/9] gpio: xgene-sb: " Peng Fan (OSS)
2025-05-09  4:45 ` [PATCH RFC 8/9] gpio: timberdale: " Peng Fan (OSS)
2025-05-10 18:26   ` Andy Shevchenko
2025-05-09  4:45 ` [PATCH RFC 9/9] gpio: pxa: " Peng Fan (OSS)
2025-05-10 18:29 ` [PATCH RFC 0/9] gpio: make " Andy Shevchenko
2025-05-13 13:13 ` Linus Walleij
2025-05-15 15:02 ` Bartosz Golaszewski
2025-05-19  3:56   ` Peng Fan
2025-05-19 11:11     ` Bartosz Golaszewski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250509-gpio-v1-3-639377c98288@nxp.com \
    --to=peng.fan@oss.nxp.com \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=brgl@bgdev.pl \
    --cc=florian.fainelli@broadcom.com \
    --cc=j-keerthy@ti.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peng.fan@nxp.com \
    --cc=rjui@broadcom.com \
    --cc=robert.jarzmik@free.fr \
    --cc=sbranden@broadcom.com \
    --cc=vz@mleia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®