All of lore.kernel.org
 help / color / mirror / Atom feed
From: Linus Walleij <linus.walleij@linaro.org>
To: linux-gpio@vger.kernel.org, "Bartosz Golaszewski" <brgl@bgdev.pl>,
	"Manivannan Sadhasivam" <mani@kernel.org>,
	"Thorsten Scherer" <t.scherer@eckelmann.de>,
	"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
	"Pengutronix Kernel Team" <kernel@pengutronix.de>,
	"Maxime Coquelin" <mcoquelin.stm32@gmail.com>,
	"Alexandre Torgue" <alexandre.torgue@foss.st.com>,
	"Robert Richter" <rric@kernel.org>,
	"Nobuhiro Iwamatsu" <nobuhiro1.iwamatsu@toshiba.co.jp>,
	"Ray Jui" <rjui@broadcom.com>,
	"Scott Branden" <sbranden@broadcom.com>,
	"Broadcom internal kernel review list"
	<bcm-kernel-feedback-list@broadcom.com>,
	"Shubhrajyoti Datta" <shubhrajyoti.datta@xilinx.com>,
	"Srinivas Neeli" <srinivas.neeli@xilinx.com>,
	"Michal Simek" <michal.simek@xilinx.com>
Cc: linux-arm-kernel@lists.infradead.org,
	linux-unisoc@lists.infradead.org, linux-kernel@vger.kernel.org,
	linux-stm32@st-md-mailman.stormreply.com,
	Linus Walleij <linus.walleij@linaro.org>,
	Marc Zyngier <maz@kernel.org>
Subject: [PATCH 1/9] gpio: rda: Convert to immutable irq_chip
Date: Mon, 20 Mar 2023 10:55:08 +0100	[thread overview]
Message-ID: <20230316-immutable-chips-2-v1-1-053d6ede831b@linaro.org> (raw)
In-Reply-To: <20230316-immutable-chips-2-v1-0-053d6ede831b@linaro.org>

Convert the driver to immutable irq-chip with a bit of
intuition.

Cc: Marc Zyngier <maz@kernel.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/gpio/gpio-rda.c | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/drivers/gpio/gpio-rda.c b/drivers/gpio/gpio-rda.c
index 62ba18b3a602..dd568907d389 100644
--- a/drivers/gpio/gpio-rda.c
+++ b/drivers/gpio/gpio-rda.c
@@ -38,7 +38,6 @@ struct rda_gpio {
 	struct gpio_chip chip;
 	void __iomem *base;
 	spinlock_t lock;
-	struct irq_chip irq_chip;
 	int irq;
 };
 
@@ -74,6 +73,7 @@ static void rda_gpio_irq_mask(struct irq_data *data)
 	value |= BIT(offset) << RDA_GPIO_IRQ_FALL_SHIFT;
 
 	writel_relaxed(value, base + RDA_GPIO_INT_CTRL_CLR);
+	gpiochip_disable_irq(chip, offset);
 }
 
 static void rda_gpio_irq_ack(struct irq_data *data)
@@ -154,6 +154,7 @@ static void rda_gpio_irq_unmask(struct irq_data *data)
 	u32 offset = irqd_to_hwirq(data);
 	u32 trigger = irqd_get_trigger_type(data);
 
+	gpiochip_enable_irq(chip, offset);
 	rda_gpio_set_irq(chip, offset, trigger);
 }
 
@@ -195,6 +196,16 @@ static void rda_gpio_irq_handler(struct irq_desc *desc)
 	chained_irq_exit(ic, desc);
 }
 
+static const struct irq_chip rda_gpio_irq_chip = {
+	.name = "rda-gpio",
+	.irq_ack = rda_gpio_irq_ack,
+	.irq_mask = rda_gpio_irq_mask,
+	.irq_unmask = rda_gpio_irq_unmask,
+	.irq_set_type = rda_gpio_irq_set_type,
+	.flags = IRQCHIP_SKIP_SET_WAKE | IRQCHIP_IMMUTABLE,
+	GPIOCHIP_IRQ_RESOURCE_HELPERS,
+};
+
 static int rda_gpio_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
@@ -241,15 +252,8 @@ static int rda_gpio_probe(struct platform_device *pdev)
 	rda_gpio->chip.base = -1;
 
 	if (rda_gpio->irq >= 0) {
-		rda_gpio->irq_chip.name = "rda-gpio",
-		rda_gpio->irq_chip.irq_ack = rda_gpio_irq_ack,
-		rda_gpio->irq_chip.irq_mask = rda_gpio_irq_mask,
-		rda_gpio->irq_chip.irq_unmask = rda_gpio_irq_unmask,
-		rda_gpio->irq_chip.irq_set_type = rda_gpio_irq_set_type,
-		rda_gpio->irq_chip.flags = IRQCHIP_SKIP_SET_WAKE,
-
 		girq = &rda_gpio->chip.irq;
-		girq->chip = &rda_gpio->irq_chip;
+		gpio_irq_chip_set_chip(girq, &rda_gpio_irq_chip);
 		girq->handler = handle_bad_irq;
 		girq->default_type = IRQ_TYPE_NONE;
 		girq->parent_handler = rda_gpio_irq_handler;

-- 
2.34.1


WARNING: multiple messages have this Message-ID (diff)
From: Linus Walleij <linus.walleij@linaro.org>
To: linux-gpio@vger.kernel.org, "Bartosz Golaszewski" <brgl@bgdev.pl>,
	"Manivannan Sadhasivam" <mani@kernel.org>,
	"Thorsten Scherer" <t.scherer@eckelmann.de>,
	"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
	"Pengutronix Kernel Team" <kernel@pengutronix.de>,
	"Maxime Coquelin" <mcoquelin.stm32@gmail.com>,
	"Alexandre Torgue" <alexandre.torgue@foss.st.com>,
	"Robert Richter" <rric@kernel.org>,
	"Nobuhiro Iwamatsu" <nobuhiro1.iwamatsu@toshiba.co.jp>,
	"Ray Jui" <rjui@broadcom.com>,
	"Scott Branden" <sbranden@broadcom.com>,
	"Broadcom internal kernel review list"
	<bcm-kernel-feedback-list@broadcom.com>,
	"Shubhrajyoti Datta" <shubhrajyoti.datta@xilinx.com>,
	"Srinivas Neeli" <srinivas.neeli@xilinx.com>,
	"Michal Simek" <michal.simek@xilinx.com>
Cc: linux-arm-kernel@lists.infradead.org,
	linux-unisoc@lists.infradead.org,  linux-kernel@vger.kernel.org,
	linux-stm32@st-md-mailman.stormreply.com,
	 Linus Walleij <linus.walleij@linaro.org>,
	Marc Zyngier <maz@kernel.org>
Subject: [PATCH 1/9] gpio: rda: Convert to immutable irq_chip
Date: Mon, 20 Mar 2023 10:55:08 +0100	[thread overview]
Message-ID: <20230316-immutable-chips-2-v1-1-053d6ede831b@linaro.org> (raw)
In-Reply-To: <20230316-immutable-chips-2-v1-0-053d6ede831b@linaro.org>

Convert the driver to immutable irq-chip with a bit of
intuition.

Cc: Marc Zyngier <maz@kernel.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/gpio/gpio-rda.c | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/drivers/gpio/gpio-rda.c b/drivers/gpio/gpio-rda.c
index 62ba18b3a602..dd568907d389 100644
--- a/drivers/gpio/gpio-rda.c
+++ b/drivers/gpio/gpio-rda.c
@@ -38,7 +38,6 @@ struct rda_gpio {
 	struct gpio_chip chip;
 	void __iomem *base;
 	spinlock_t lock;
-	struct irq_chip irq_chip;
 	int irq;
 };
 
@@ -74,6 +73,7 @@ static void rda_gpio_irq_mask(struct irq_data *data)
 	value |= BIT(offset) << RDA_GPIO_IRQ_FALL_SHIFT;
 
 	writel_relaxed(value, base + RDA_GPIO_INT_CTRL_CLR);
+	gpiochip_disable_irq(chip, offset);
 }
 
 static void rda_gpio_irq_ack(struct irq_data *data)
@@ -154,6 +154,7 @@ static void rda_gpio_irq_unmask(struct irq_data *data)
 	u32 offset = irqd_to_hwirq(data);
 	u32 trigger = irqd_get_trigger_type(data);
 
+	gpiochip_enable_irq(chip, offset);
 	rda_gpio_set_irq(chip, offset, trigger);
 }
 
@@ -195,6 +196,16 @@ static void rda_gpio_irq_handler(struct irq_desc *desc)
 	chained_irq_exit(ic, desc);
 }
 
+static const struct irq_chip rda_gpio_irq_chip = {
+	.name = "rda-gpio",
+	.irq_ack = rda_gpio_irq_ack,
+	.irq_mask = rda_gpio_irq_mask,
+	.irq_unmask = rda_gpio_irq_unmask,
+	.irq_set_type = rda_gpio_irq_set_type,
+	.flags = IRQCHIP_SKIP_SET_WAKE | IRQCHIP_IMMUTABLE,
+	GPIOCHIP_IRQ_RESOURCE_HELPERS,
+};
+
 static int rda_gpio_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
@@ -241,15 +252,8 @@ static int rda_gpio_probe(struct platform_device *pdev)
 	rda_gpio->chip.base = -1;
 
 	if (rda_gpio->irq >= 0) {
-		rda_gpio->irq_chip.name = "rda-gpio",
-		rda_gpio->irq_chip.irq_ack = rda_gpio_irq_ack,
-		rda_gpio->irq_chip.irq_mask = rda_gpio_irq_mask,
-		rda_gpio->irq_chip.irq_unmask = rda_gpio_irq_unmask,
-		rda_gpio->irq_chip.irq_set_type = rda_gpio_irq_set_type,
-		rda_gpio->irq_chip.flags = IRQCHIP_SKIP_SET_WAKE,
-
 		girq = &rda_gpio->chip.irq;
-		girq->chip = &rda_gpio->irq_chip;
+		gpio_irq_chip_set_chip(girq, &rda_gpio_irq_chip);
 		girq->handler = handle_bad_irq;
 		girq->default_type = IRQ_TYPE_NONE;
 		girq->parent_handler = rda_gpio_irq_handler;

-- 
2.34.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2023-03-20  9:55 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-20  9:55 [PATCH 0/9] Mass convert GPIO IRQ chips to be immutable part 2 Linus Walleij
2023-03-20  9:55 ` Linus Walleij
2023-03-20  9:55 ` Linus Walleij [this message]
2023-03-20  9:55   ` [PATCH 1/9] gpio: rda: Convert to immutable irq_chip Linus Walleij
2023-03-20 10:34   ` Manivannan Sadhasivam
2023-03-20 10:34     ` Manivannan Sadhasivam
2023-03-20  9:55 ` [PATCH 2/9] gpio: siox: " Linus Walleij
2023-03-20  9:55   ` Linus Walleij
2023-03-20  9:55 ` [PATCH 3/9] gpio: stmpe: " Linus Walleij
2023-03-20  9:55   ` Linus Walleij
2023-03-20  9:55 ` [PATCH 4/9] gpio: thunderx: " Linus Walleij
2023-03-20  9:55   ` Linus Walleij
2023-03-20  9:55 ` [PATCH 5/9] gpio: tqmx86: " Linus Walleij
2023-03-20  9:55   ` Linus Walleij
2023-03-20  9:55 ` [PATCH 6/9] gpio: visconti: " Linus Walleij
2023-03-20  9:55   ` Linus Walleij
2023-03-20  9:55 ` [PATCH 7/9] gpio: xgs-iproc: " Linus Walleij
2023-03-20  9:55   ` Linus Walleij
2023-03-20  9:55 ` [PATCH 8/9] gpio: xilinx: " Linus Walleij
2023-03-20  9:55   ` Linus Walleij
2023-03-20  9:55 ` [PATCH 9/9] gpio: xlp: " Linus Walleij
2023-03-20  9:55   ` Linus Walleij
2023-03-20 11:10 ` [PATCH 0/9] Mass convert GPIO IRQ chips to be immutable part 2 Marc Zyngier
2023-03-20 11:10   ` Marc Zyngier
2023-03-22 16:52 ` Bartosz Golaszewski
2023-03-22 16:52   ` 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=20230316-immutable-chips-2-v1-1-053d6ede831b@linaro.org \
    --to=linus.walleij@linaro.org \
    --cc=alexandre.torgue@foss.st.com \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=brgl@bgdev.pl \
    --cc=kernel@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=linux-unisoc@lists.infradead.org \
    --cc=mani@kernel.org \
    --cc=maz@kernel.org \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=michal.simek@xilinx.com \
    --cc=nobuhiro1.iwamatsu@toshiba.co.jp \
    --cc=rjui@broadcom.com \
    --cc=rric@kernel.org \
    --cc=sbranden@broadcom.com \
    --cc=shubhrajyoti.datta@xilinx.com \
    --cc=srinivas.neeli@xilinx.com \
    --cc=t.scherer@eckelmann.de \
    --cc=u.kleine-koenig@pengutronix.de \
    /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 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.