Skip to contentSkip to conversation

gpio: langwell: convert to use irq_domain

PATCH Applied Mika Westerberg 2 participants 3 messages May 2, 2012 – May 9, 2012 GPIO

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 gpio: langwell: convert to use irq_domain

irq_domain already provides a facility to translate from hardware IRQ numbers to Linux IRQ numbers so use that instead of open-coding the logic in the driver.

---
Changes to v2:
- use irq_find_mapping() instead of gpio_to_irq()
- remove irq_base as it is not used anymore

Changes to v1:
- use linear mapping instead of legacy as suggested by Grant

 drivers/gpio/Kconfig         |    1 +
 drivers/gpio/gpio-langwell.c |   50 ++++++++++++++++++++++++-----------------
 2 files changed, 30 insertions(+), 21 deletions(-)
drivers/gpio/Kconfig +1 -0
index e03653d..0a85d95 100644
@@ -399,6 +399,7 @@ config GPIO_BT8XX
 config GPIO_LANGWELL
 	bool "Intel Langwell/Penwell GPIO support"
 	depends on PCI && X86
+	select IRQ_DOMAIN
 	help
 	  Say Y here to support Intel Langwell/Penwell GPIO.
 
drivers/gpio/gpio-langwell.c +29 -21

131 lines not on this page · raw message

Signature · 1 line
1.7.9.1
Applied
#1 lore raw
Quoted 5 lines · Mika Westerberg

irq_domain already provides a facility to translate from hardware IRQ numbers to Linux IRQ numbers so use that instead of open-coding the logic in the driver.

Applied, thanks.

BTW, I noticed a bug below (unrelated to this patch)...

Quoted 10 lines

---
static int lnw_irq_type(struct irq_data *d, unsigned type) {

drivers/gpio/gpio-langwell.c +1 -1
 	struct lnw_gpio *lnw = irq_data_get_irq_chip_data(d);
-	u32 gpio = d->irq - lnw->irq_base;
+	u32 gpio = irqd_to_hwirq(d);
 	unsigned long flags;
 	u32 value;
 	void __iomem *grer = gpio_reg(&lnw->chip, gpio, GRER);

drivers/gpio/gpio-langwell.c static void lnw_irq_handler(unsigned irq, struct irq_desc *desc) · line 263

Quoted 8 lines
drivers/gpio/gpio-langwell.c +2 -1
@@ -256,7 +257,8 @@ static void lnw_irq_handler(unsigned irq, struct irq_desc *desc)
 			pending &= ~mask;
 			/* Clear before handling so we can't lose an edge */
 			writel(mask, gedr);
-			generic_handle_irq(lnw->irq_base + base + gpio);
+			generic_handle_irq(irq_find_mapping(lnw->domain,
+							    base + gpio));
 		}
 	}

This while loop is actually buggy. After handling each pending irq bit the status register should be re-read. Otherwise if the same irq gets raised again after it is handled, then this loop will ignore it.

It's not a major issue, but it would mean unnecessary exiting and reentering the handler function.

g.

#2 lore raw
Quoted 8 lines · Grant Likely
Quoted 5 lines · Mika Westerberg

irq_domain already provides a facility to translate from hardware IRQ numbers to Linux IRQ numbers so use that instead of open-coding the logic in the driver.

Applied, thanks.

Thanks.

Quoted 25 lines

BTW, I noticed a bug below (unrelated to this patch)...

Quoted 10 lines

---
static int lnw_irq_type(struct irq_data *d, unsigned type) {

drivers/gpio/gpio-langwell.c +1 -1
 	struct lnw_gpio *lnw = irq_data_get_irq_chip_data(d);
-	u32 gpio = d->irq - lnw->irq_base;
+	u32 gpio = irqd_to_hwirq(d);
 	unsigned long flags;
 	u32 value;
 	void __iomem *grer = gpio_reg(&lnw->chip, gpio, GRER);

drivers/gpio/gpio-langwell.c static void lnw_irq_handler(unsigned irq, struct irq_desc *desc) · line 263

Quoted 8 lines
drivers/gpio/gpio-langwell.c +2 -1
@@ -256,7 +257,8 @@ static void lnw_irq_handler(unsigned irq, struct irq_desc *desc)
 			pending &= ~mask;
 			/* Clear before handling so we can't lose an edge */
 			writel(mask, gedr);
-			generic_handle_irq(lnw->irq_base + base + gpio);
+			generic_handle_irq(irq_find_mapping(lnw->domain,
+							    base + gpio));
 		}
 	}

This while loop is actually buggy. After handling each pending irq bit the status register should be re-read. Otherwise if the same irq gets raised again after it is handled, then this loop will ignore it.

Quoted 2 lines

It's not a major issue, but it would mean unnecessary exiting and reentering the handler function.

Indeed. I'll take a look.