linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Linus Walleij <linus.walleij@linaro.org>,
	Bartosz Golaszewski <bgolaszewski@baylibre.com>,
	linux-gpio@vger.kernel.org, Serge Semin <fancer.lancer@gmail.com>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Subject: [PATCH v1 02/13] gpio: dwapb: Refactor IRQ handler
Date: Thu,  9 Apr 2020 17:12:17 +0300	[thread overview]
Message-ID: <20200409141228.49561-3-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <20200409141228.49561-1-andriy.shevchenko@linux.intel.com>

Refactor IRQ handler in order to:
- enter and exit chained IRQ
- use for_each_set_bit() helper

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/gpio/gpio-dwapb.c | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/drivers/gpio/gpio-dwapb.c b/drivers/gpio/gpio-dwapb.c
index c1b6d4f7307e..f61139f787d9 100644
--- a/drivers/gpio/gpio-dwapb.c
+++ b/drivers/gpio/gpio-dwapb.c
@@ -193,22 +193,21 @@ static void dwapb_toggle_trigger(struct dwapb_gpio *gpio, unsigned int offs)
 
 static u32 dwapb_do_irq(struct dwapb_gpio *gpio)
 {
-	u32 irq_status = dwapb_read(gpio, GPIO_INTSTATUS);
-	u32 ret = irq_status;
+	unsigned long irq_status;
+	int hwirq;
 
-	while (irq_status) {
-		int hwirq = fls(irq_status) - 1;
+	irq_status = dwapb_read(gpio, GPIO_INTSTATUS);
+	for_each_set_bit(hwirq, &irq_status, 32) {
 		int gpio_irq = irq_find_mapping(gpio->domain, hwirq);
+		u32 irq_type = irq_get_trigger_type(gpio_irq);
 
 		generic_handle_irq(gpio_irq);
-		irq_status &= ~BIT(hwirq);
 
-		if ((irq_get_trigger_type(gpio_irq) & IRQ_TYPE_SENSE_MASK)
-			== IRQ_TYPE_EDGE_BOTH)
+		if ((irq_type & IRQ_TYPE_SENSE_MASK) == IRQ_TYPE_EDGE_BOTH)
 			dwapb_toggle_trigger(gpio, hwirq);
 	}
 
-	return ret;
+	return irq_status;
 }
 
 static void dwapb_irq_handler(struct irq_desc *desc)
@@ -216,10 +215,9 @@ static void dwapb_irq_handler(struct irq_desc *desc)
 	struct dwapb_gpio *gpio = irq_desc_get_handler_data(desc);
 	struct irq_chip *chip = irq_desc_get_chip(desc);
 
+	chained_irq_enter(chip, desc);
 	dwapb_do_irq(gpio);
-
-	if (chip->irq_eoi)
-		chip->irq_eoi(irq_desc_get_irq_data(desc));
+	chained_irq_exit(chip, desc);
 }
 
 static void dwapb_irq_enable(struct irq_data *d)
-- 
2.25.1


  parent reply	other threads:[~2020-04-09 14:12 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-09 14:12 [PATCH v1 00/13] gpio: dwapb: Clean up the driver and a fix Andy Shevchenko
2020-04-09 14:12 ` [PATCH v1 01/13] gpio: dwapb: Append MODULE_ALIAS for platform driver Andy Shevchenko
2020-04-15 11:58   ` Serge Semin
2020-04-09 14:12 ` Andy Shevchenko [this message]
2020-04-15 12:04   ` [PATCH v1 02/13] gpio: dwapb: Refactor IRQ handler Serge Semin
2020-04-15 12:35     ` Andy Shevchenko
2020-04-09 14:12 ` [PATCH v1 03/13] gpio: dwapb: set default handler to be handle_bad_irq() Andy Shevchenko
2020-04-15 12:22   ` Serge Semin
2020-04-15 12:33     ` Andy Shevchenko
2020-04-09 14:12 ` [PATCH v1 04/13] gpio: dwapb: Deduplicate IRQ resource management Andy Shevchenko
2020-04-15 12:28   ` Serge Semin
2020-04-09 14:12 ` [PATCH v1 05/13] gpio: dwapb: Convert to use irqd_to_hwirq() Andy Shevchenko
2020-04-15 12:42   ` Serge Semin
2020-04-15 13:16     ` Andy Shevchenko
2020-04-09 14:12 ` [PATCH v1 06/13] gpio: dwapb: Use device_get_match_data() to simplify code Andy Shevchenko
2020-04-15 12:46   ` Serge Semin
2020-04-09 14:12 ` [PATCH v1 07/13] gpio: dwapb: Convert to use IRQ core provided macros Andy Shevchenko
2020-04-15 12:57   ` Serge Semin
2020-04-09 14:12 ` [PATCH v1 08/13] gpio: dwapb: Switch to more usual pattern of RMW in dwapb_gpio_set_debounce() Andy Shevchenko
2020-04-15 13:00   ` Serge Semin
2020-04-09 14:12 ` [PATCH v1 09/13] gpio: dwapb: Drop bogus BUG_ON()s Andy Shevchenko
2020-04-15 13:05   ` Serge Semin
2020-04-09 14:12 ` [PATCH v1 10/13] gpio: dwapb: Drop of_match_ptr() & ACPI_PTR() calls Andy Shevchenko
2020-04-15 13:07   ` Serge Semin
2020-04-09 14:12 ` [PATCH v1 11/13] gpio: dwapb: Split out dwapb_get_irq() helper Andy Shevchenko
2020-04-15 13:13   ` Serge Semin
2020-04-09 14:12 ` [PATCH v1 12/13] gpio: dwapb: Use positive conditional in dwapb_configure_irqs() Andy Shevchenko
2020-04-09 14:12 ` [PATCH v1 13/13] gpio: dwapb: Amend indentation in some cases Andy Shevchenko
2020-04-09 14:28 ` [PATCH v1 00/13] gpio: dwapb: Clean up the driver and a fix Serge Semin
2020-04-15 11:55 ` Serge Semin
2020-04-15 12:06   ` Andy Shevchenko

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=20200409141228.49561-3-andriy.shevchenko@linux.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=bgolaszewski@baylibre.com \
    --cc=fancer.lancer@gmail.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).