Skip to contentSkip to conversation

gpio: Interrupt cleanups and API change preparation

PATCH In review Thomas Gleixner 3 participants 26 messages Jul 13, 2015 – Jul 17, 2015 1 message not in the archive

Subsystems (11)
lore
Share & tools
lore
#0 lore raw

cover gpio: Interrupt cleanups and API change preparation

The following patch series contains the following changes:

- Consolidation of chained interrupt handler setup/removal

- Switch to functions which avoid a redundant interrupt descriptor lookup

- Preparation of interrupt flow handlers for the 'irq' argument removal

The series has no dependencies and is also available as a git branch for your convenience:

git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git irq/gpio

If you want me to carry the patches in the irq/core branch of tip, please let me know.

Thanks,

tglx

#1 lore raw

PATCH 1/19 gpio/mpc8xxx: Consolidate chained IRQ handler install/remove

Chained irq handlers usually set up handler data as well. We now have a function to set both under irq_desc->lock. Replace the two calls with one.

Search and conversion was done with coccinelle:

---
 drivers/gpio/gpio-mpc8xxx.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/gpio/gpio-mpc8xxx.c +3 -4
index a65b75161aa4..6822520f6cf3 100644
@@ -396,8 +396,8 @@ static int mpc8xxx_probe(struct platform_device *pdev)
 	out_be32(mm_gc->regs + GPIO_IER, 0xffffffff);
 	out_be32(mm_gc->regs + GPIO_IMR, 0);
 
-	irq_set_handler_data(mpc8xxx_gc->irqn, mpc8xxx_gc);
-	irq_set_chained_handler(mpc8xxx_gc->irqn, mpc8xxx_gpio_irq_cascade);
+	irq_set_chained_handler_and_data(mpc8xxx_gc->irqn,
+					 mpc8xxx_gpio_irq_cascade, mpc8xxx_gc);
 
 	return 0;
 }
@@ -407,8 +407,7 @@ static int mpc8xxx_remove(struct platform_device *pdev)
 	struct mpc8xxx_gpio_chip *mpc8xxx_gc = platform_get_drvdata(pdev);
 
 	if (mpc8xxx_gc->irq) {
-		irq_set_handler_data(mpc8xxx_gc->irqn, NULL);
-		irq_set_chained_handler(mpc8xxx_gc->irqn, NULL);
+		irq_set_chained_handler_and_data(mpc8xxx_gc->irqn, NULL, NULL);
 		irq_domain_remove(mpc8xxx_gc->irq);
 	}
 
Signature · 1 line
2.1.4
#2 lore raw

PATCH 2/19 gpio/mvebu: Consolidate chained IRQ handler install/remove

In reply to Thomas Gleixner

Chained irq handlers usually set up handler data as well. We now have a function to set both under irq_desc->lock. Replace the two calls with one.

Search and conversion was done with coccinelle:

---
 drivers/gpio/gpio-mvebu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpio/gpio-mvebu.c +2 -2
index 1a54205860f5..ab660e44a672 100644
@@ -787,8 +787,8 @@ static int mvebu_gpio_probe(struct platform_device *pdev)
 
 		if (irq < 0)
 			continue;
-		irq_set_handler_data(irq, mvchip);
-		irq_set_chained_handler(irq, mvebu_gpio_irq_handler);
+		irq_set_chained_handler_and_data(irq, mvebu_gpio_irq_handler,
+						 mvchip);
 	}
 
 	mvchip->irqbase = irq_alloc_descs(-1, 0, ngpios, -1);
Signature · 1 line
2.1.4
#3 lore raw

PATCH 3/19 gpio/timberdale: Consolidate chained IRQ handler install/remove

In reply to Thomas Gleixner

Chained irq handlers usually set up handler data as well. We now have a function to set both under irq_desc->lock. Replace the two calls with one.

Search and conversion was done with coccinelle:

---
 drivers/gpio/gpio-timberdale.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpio/gpio-timberdale.c +1 -2
index e8f97e03c9bb..fd1970ed15e6 100644
@@ -299,8 +299,7 @@ static int timbgpio_probe(struct platform_device *pdev)
 #endif
 	}
 
-	irq_set_handler_data(irq, tgpio);
-	irq_set_chained_handler(irq, timbgpio_irq);
+	irq_set_chained_handler_and_data(irq, timbgpio_irq, tgpio);
 
 	return 0;
 }
Signature · 1 line
2.1.4
#4 lore raw

PATCH 4/19 gpio/tz1090: Consolidate chained IRQ handler install/remove

In reply to Thomas Gleixner

Chained irq handlers usually set up handler data as well. We now have a function to set both under irq_desc->lock. Replace the two calls with one.

Search and conversion was done with coccinelle:

---
 drivers/gpio/gpio-tz1090.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpio/gpio-tz1090.c +2 -2
index 445660adc898..bbac92ae4c32 100644
@@ -510,8 +510,8 @@ static int tz1090_gpio_bank_probe(struct tz1090_gpio_bank_info *info)
 	gc->chip_types[1].chip.flags		= IRQCHIP_MASK_ON_SUSPEND;
 
 	/* Setup chained handler for this GPIO bank */
-	irq_set_handler_data(bank->irq, bank);
-	irq_set_chained_handler(bank->irq, tz1090_gpio_irq_handler);
+	irq_set_chained_handler_and_data(bank->irq, tz1090_gpio_irq_handler,
+					 bank);
 
 	return 0;
 }
Signature · 1 line
2.1.4
#5 lore raw

PATCH 5/19 gpiolib: Consolidate chained IRQ handler install/remove

In reply to Thomas Gleixner

Chained irq handlers usually set up handler data as well. We now have a function to set both under irq_desc->lock. Replace the two calls with one.

Search and conversion was done with coccinelle:

---
 drivers/gpio/gpiolib.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpio/gpiolib.c +2 -2
Index: tip/drivers/gpio/gpiolib.c
===================================================================
@@ -443,8 +443,8 @@ void gpiochip_set_chained_irqchip(struct
 		 * The parent irqchip is already using the chip_data for this
 		 * irqchip, so our callbacks simply use the handler_data.
 		 */
-		irq_set_handler_data(parent_irq, gpiochip);
-		irq_set_chained_handler(parent_irq, parent_handler);
+		irq_set_chained_handler_and_data(parent_irq, parent_handler,
+						 gpiochip);
 
 		gpiochip->irq_parent = parent_irq;
 	}
#6 lore raw

PATCH 6/19 gpio/zynq: Use irq_set_chip_handler_name_locked()

In reply to Thomas Gleixner

Hand in irq_data and avoid the redundant lookup of irq_desc.

Originally-from: Jiang Liu <[email protected]>

---
 drivers/gpio/gpio-zynq.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpio/gpio-zynq.c +2 -2
index 184c4b1b2558..8162f7952073 100644
@@ -423,10 +423,10 @@ static int zynq_gpio_set_irq_type(struct irq_data *irq_data, unsigned int type)
 		       gpio->base_addr + ZYNQ_GPIO_INTANY_OFFSET(bank_num));
 
 	if (type & IRQ_TYPE_LEVEL_MASK) {
-		__irq_set_chip_handler_name_locked(irq_data->irq,
+		irq_set_chip_handler_name_locked(irq_data,
 			&zynq_gpio_level_irqchip, handle_fasteoi_irq, NULL);
 	} else {
-		__irq_set_chip_handler_name_locked(irq_data->irq,
+		irq_set_chip_handler_name_locked(irq_data,
 			&zynq_gpio_edge_irqchip, handle_level_irq, NULL);
 	}
 
Signature · 1 line
2.1.4
#7 lore raw

PATCH 7/19 gpio/ep93xx: Use irq_set_handler_locked()

In reply to Thomas Gleixner

Use irq_set_handler_locked() as it avoids a redundant lookup of the irq descriptor.

Search and replacement was done with coccinelle:

@@
struct irq_data *d;
expression E1;
@@

-__irq_set_handler_locked(d->irq, E1);
+irq_set_handler_locked(d, E1);

Cc Jiang Liu <[email protected]>
Cc Julia Lawall <[email protected]>
Cc Linus Walleij <[email protected]>
Cc Alexandre Courbot <[email protected]>
---
 drivers/gpio/gpio-ep93xx.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpio-ep93xx.c +1 -1
Index: tip/drivers/gpio/gpio-ep93xx.c
===================================================================
@@ -208,7 +208,7 @@ static int ep93xx_gpio_irq_type(struct i
 		return -EINVAL;
 	}
 
-	__irq_set_handler_locked(d->irq, handler);
+	irq_set_handler_locked(d, handler);
 
 	gpio_int_enabled[port] |= port_mask;
 
#8 lore raw

PATCH 8/19 gpio/msm-v2: Use irq_set_handler_locked()

In reply to Thomas Gleixner

Use irq_set_handler_locked() as it avoids a redundant lookup of the irq descriptor.

Search and replacement was done with coccinelle:

Cc Jiang Liu <[email protected]>
Cc Julia Lawall <[email protected]>
Cc Linus Walleij <[email protected]>
Cc Alexandre Courbot <[email protected]>
---
 drivers/gpio/gpio-msm-v2.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpio/gpio-msm-v2.c +2 -2
Index: tip/drivers/gpio/gpio-msm-v2.c
===================================================================
@@ -281,14 +281,14 @@ static int msm_gpio_irq_set_type(struct
 
 	if (flow_type & IRQ_TYPE_EDGE_BOTH) {
 		bits |= BIT(INTR_DECT_CTL);
-		__irq_set_handler_locked(d->irq, handle_edge_irq);
+		irq_set_handler_locked(d, handle_edge_irq);
 		if ((flow_type & IRQ_TYPE_EDGE_BOTH) == IRQ_TYPE_EDGE_BOTH)
 			__set_bit(gpio, msm_gpio.dual_edge_irqs);
 		else
 			__clear_bit(gpio, msm_gpio.dual_edge_irqs);
 	} else {
 		bits &= ~BIT(INTR_DECT_CTL);
-		__irq_set_handler_locked(d->irq, handle_level_irq);
+		irq_set_handler_locked(d, handle_level_irq);
 		__clear_bit(gpio, msm_gpio.dual_edge_irqs);
 	}
 
#9 lore raw

PATCH 9/19 gpio/omap: Use irq_set_handler_locked()

In reply to Thomas Gleixner

Use irq_set_handler_locked() as it avoids a redundant lookup of the irq descriptor.

Search and replacement was done with coccinelle:

Cc Jiang Liu <[email protected]>
Cc Julia Lawall <[email protected]>
Cc Kevin Hilman <[email protected]>
Cc Linus Walleij <[email protected]>
Cc Alexandre Courbot <[email protected]>
---
 drivers/gpio/gpio-omap.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpio/gpio-omap.c +2 -2
Index: tip/drivers/gpio/gpio-omap.c
===================================================================
@@ -511,9 +511,9 @@ static int omap_gpio_irq_type(struct irq
 	spin_unlock_irqrestore(&bank->lock, flags);
 
 	if (type & (IRQ_TYPE_LEVEL_LOW | IRQ_TYPE_LEVEL_HIGH))
-		__irq_set_handler_locked(d->irq, handle_level_irq);
+		irq_set_handler_locked(d, handle_level_irq);
 	else if (type & (IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING))
-		__irq_set_handler_locked(d->irq, handle_edge_irq);
+		irq_set_handler_locked(d, handle_edge_irq);
 
 	return 0;
 
#10 lore raw

PATCH 10/19 gpio/pch: Use irq_set_handler_locked()

In reply to Thomas Gleixner

Use irq_set_handler_locked() as it avoids a redundant lookup of the irq descriptor.

Search and replacement was done with coccinelle:

Cc Jiang Liu <[email protected]>
Cc Julia Lawall <[email protected]>
Cc Linus Walleij <[email protected]>
Cc Alexandre Courbot <[email protected]>
---
 drivers/gpio/gpio-pch.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpio/gpio-pch.c +2 -2
Index: tip/drivers/gpio/gpio-pch.c
===================================================================
@@ -281,9 +281,9 @@ static int pch_irq_type(struct irq_data
 
 	/* And the handler */
 	if (type & (IRQ_TYPE_LEVEL_LOW | IRQ_TYPE_LEVEL_HIGH))
-		__irq_set_handler_locked(d->irq, handle_level_irq);
+		irq_set_handler_locked(d, handle_level_irq);
 	else if (type & (IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING))
-		__irq_set_handler_locked(d->irq, handle_edge_irq);
+		irq_set_handler_locked(d, handle_edge_irq);
 
 unlock:
 	spin_unlock_irqrestore(&chip->spinlock, flags);
#11 lore raw

PATCH 11/19 gpio/gpio-tegra: Use irq_set_handler_locked()

In reply to Thomas Gleixner

Use irq_set_handler_locked() as it avoids a redundant lookup of the irq descriptor.

Search and replacement was done with coccinelle:

Cc Jiang Liu <[email protected]>
Cc Julia Lawall <[email protected]>
Cc Linus Walleij <[email protected]>
Cc Alexandre Courbot <[email protected]>
Cc Stephen Warren <[email protected]>
Cc Thierry Reding <[email protected]>
---
 drivers/gpio/gpio-tegra.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpio/gpio-tegra.c +2 -2
Index: tip/drivers/gpio/gpio-tegra.c
===================================================================
@@ -252,9 +252,9 @@ static int tegra_gpio_irq_set_type(struc
 	tegra_gpio_enable(gpio);
 
 	if (type & (IRQ_TYPE_LEVEL_LOW | IRQ_TYPE_LEVEL_HIGH))
-		__irq_set_handler_locked(d->irq, handle_level_irq);
+		irq_set_handler_locked(d, handle_level_irq);
 	else if (type & (IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING))
-		__irq_set_handler_locked(d->irq, handle_edge_irq);
+		irq_set_handler_locked(d, handle_edge_irq);
 
 	return 0;
 }
#12 lore raw

PATCH 12/19 gpio/davinci: Use accessor function irq_data_get_irq_handler_data()

In reply to Thomas Gleixner

From: Jiang Liu <[email protected]>

This is a preparatory patch for moving irq_data struct members.

Cc Linus Walleij <[email protected]>
Cc Alexandre Courbot <[email protected]>
---
 drivers/gpio/gpio-davinci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpio-davinci.c +1 -1
index c5e05c82d67c..477d5b8616ab 100644
@@ -396,7 +396,7 @@ static int gpio_irq_type_unbanked(struct irq_data *data, unsigned trigger)
 	struct davinci_gpio_regs __iomem *g;
 	u32 mask;
 
-	d = (struct davinci_gpio_controller *)data->handler_data;
+	d = (struct davinci_gpio_controller *)irq_data_get_irq_handler_data(data);
 	g = (struct davinci_gpio_regs __iomem *)d->regs;
 	mask = __gpio_mask(data->irq - d->gpio_irq);
 
Signature · 1 line
2.1.4
#13 lore raw

PATCH 13/19 gpio: Use irq_desc_get_xxx() to avoid redundant lookup of irq_desc

In reply to Thomas Gleixner

From: Jiang Liu <[email protected]>

Use irq_desc_get_xxx() to avoid redundant lookup of irq_desc while we already have a pointer to corresponding irq_desc.

Preparatory patch for the removal of the 'irq' argument from irq flow handlers.

---
 drivers/gpio/gpio-bcm-kona.c   |    2 +-
 drivers/gpio/gpio-dwapb.c      |    2 +-
 drivers/gpio/gpio-mvebu.c      |    2 +-
 drivers/gpio/gpio-mxc.c        |    6 +++---
 drivers/gpio/gpio-mxs.c        |    2 +-
 drivers/gpio/gpio-omap.c       |    2 +-
 drivers/gpio/gpio-tegra.c      |    4 +---
 drivers/gpio/gpio-timberdale.c |    5 +++--
 drivers/gpio/gpio-vf610.c      |    2 +-
 drivers/gpio/gpio-zynq.c       |    2 +-
 10 files changed, 14 insertions(+), 15 deletions(-)
drivers/gpio/gpio-bcm-kona.c +1 -1
Index: tip/drivers/gpio/gpio-bcm-kona.c
===================================================================
@@ -438,7 +438,7 @@ static void bcm_kona_gpio_irq_handler(un
 	void __iomem *reg_base;
 	int bit, bank_id;
 	unsigned long sta;
-	struct bcm_kona_gpio_bank *bank = irq_get_handler_data(irq);
+	struct bcm_kona_gpio_bank *bank = irq_desc_get_handler_data(desc);
 	struct irq_chip *chip = irq_desc_get_chip(desc);
 
 	chained_irq_enter(chip, desc);
drivers/gpio/gpio-dwapb.c +1 -1
Index: tip/drivers/gpio/gpio-dwapb.c
===================================================================
@@ -149,7 +149,7 @@ static u32 dwapb_do_irq(struct dwapb_gpi
 
 static void dwapb_irq_handler(u32 irq, struct irq_desc *desc)
 {
-	struct dwapb_gpio *gpio = irq_get_handler_data(irq);
+	struct dwapb_gpio *gpio = irq_desc_get_handler_data(desc);
 	struct irq_chip *chip = irq_desc_get_chip(desc);
 
 	dwapb_do_irq(gpio);
drivers/gpio/gpio-mvebu.c +1 -1
Index: tip/drivers/gpio/gpio-mvebu.c
===================================================================
@@ -460,7 +460,7 @@ static int mvebu_gpio_irq_set_type(struc
 
 static void mvebu_gpio_irq_handler(unsigned int irq, struct irq_desc *desc)
 {
-	struct mvebu_gpio_chip *mvchip = irq_get_handler_data(irq);
+	struct mvebu_gpio_chip *mvchip = irq_desc_get_handler_data(desc);
 	struct irq_chip *chip = irq_desc_get_chip(desc);
 	u32 cause, type;
 	int i;
drivers/gpio/gpio-mxc.c +3 -3
Index: tip/drivers/gpio/gpio-mxc.c
===================================================================
@@ -275,8 +275,8 @@ static void mxc_gpio_irq_handler(struct
 static void mx3_gpio_irq_handler(u32 irq, struct irq_desc *desc)
 {
 	u32 irq_stat;
-	struct mxc_gpio_port *port = irq_get_handler_data(irq);
-	struct irq_chip *chip = irq_get_chip(irq);
+	struct mxc_gpio_port *port = irq_desc_get_handler_data(desc);
+	struct irq_chip *chip = irq_desc_get_chip(desc);
 
 	chained_irq_enter(chip, desc);
 
@@ -292,7 +292,7 @@ static void mx2_gpio_irq_handler(u32 irq
 {
 	u32 irq_msk, irq_stat;
 	struct mxc_gpio_port *port;
-	struct irq_chip *chip = irq_get_chip(irq);
+	struct irq_chip *chip = irq_desc_get_chip(desc);
 
 	chained_irq_enter(chip, desc);
 
drivers/gpio/gpio-mxs.c +1 -1
Index: tip/drivers/gpio/gpio-mxs.c
===================================================================
@@ -157,7 +157,7 @@ static void mxs_flip_edge(struct mxs_gpi
 static void mxs_gpio_irq_handler(u32 irq, struct irq_desc *desc)
 {
 	u32 irq_stat;
-	struct mxs_gpio_port *port = irq_get_handler_data(irq);
+	struct mxs_gpio_port *port = irq_desc_get_handler_data(desc);
 
 	desc->irq_data.chip->irq_ack(&desc->irq_data);
 
drivers/gpio/gpio-omap.c +1 -1
Index: tip/drivers/gpio/gpio-omap.c
===================================================================
@@ -714,7 +714,7 @@ static void omap_gpio_irq_handler(unsign
 	struct gpio_bank *bank;
 	int unmasked = 0;
 	struct irq_chip *irqchip = irq_desc_get_chip(desc);
-	struct gpio_chip *chip = irq_get_handler_data(irq);
+	struct gpio_chip *chip = irq_desc_get_handler_data(desc);
 
 	chained_irq_enter(irqchip, desc);
 
drivers/gpio/gpio-tegra.c +1 -3
Index: tip/drivers/gpio/gpio-tegra.c
===================================================================
@@ -268,16 +268,14 @@ static void tegra_gpio_irq_shutdown(stru
 
 static void tegra_gpio_irq_handler(unsigned int irq, struct irq_desc *desc)
 {
-	struct tegra_gpio_bank *bank;
 	int port;
 	int pin;
 	int unmasked = 0;
 	struct irq_chip *chip = irq_desc_get_chip(desc);
+	struct tegra_gpio_bank *bank = irq_desc_get_handler_data(desc);
 
 	chained_irq_enter(chip, desc);
 
-	bank = irq_get_handler_data(irq);
-
 	for (port = 0; port < 4; port++) {
 		int gpio = tegra_gpio_compose(bank->bank, port, 0);
 		unsigned long sta = tegra_gpio_readl(GPIO_INT_STA(gpio)) &
drivers/gpio/gpio-timberdale.c +3 -2
Index: tip/drivers/gpio/gpio-timberdale.c
===================================================================
@@ -194,11 +194,12 @@ out:
 
 static void timbgpio_irq(unsigned int irq, struct irq_desc *desc)
 {
-	struct timbgpio *tgpio = irq_get_handler_data(irq);
+	struct timbgpio *tgpio = irq_desc_get_handler_data(desc);
+	struct irq_data *data = irq_desc_get_irq_data(desc);
 	unsigned long ipr;
 	int offset;
 
-	desc->irq_data.chip->irq_ack(irq_get_irq_data(irq));
+	data->chip->irq_ack(data);
 	ipr = ioread32(tgpio->membase + TGPIO_IPR);
 	iowrite32(ipr, tgpio->membase + TGPIO_ICR);
 
drivers/gpio/gpio-vf610.c +1 -1
Index: tip/drivers/gpio/gpio-vf610.c
===================================================================
@@ -120,7 +120,7 @@ static int vf610_gpio_direction_output(s
 
 static void vf610_gpio_irq_handler(u32 irq, struct irq_desc *desc)
 {
-	struct vf610_gpio_port *port = irq_get_handler_data(irq);
+	struct vf610_gpio_port *port = irq_desc_get_handler_data(desc);
 	struct irq_chip *chip = irq_desc_get_chip(desc);
 	int pin;
 	unsigned long irq_isfr;
drivers/gpio/gpio-zynq.c +1 -1
Index: tip/drivers/gpio/gpio-zynq.c
===================================================================
@@ -518,7 +518,7 @@ static void zynq_gpio_irqhandler(unsigne
 {
 	u32 int_sts, int_enb;
 	unsigned int bank_num;
-	struct zynq_gpio *gpio = irq_get_handler_data(irq);
+	struct zynq_gpio *gpio = irq_desc_get_handler_data(desc);
 	struct irq_chip *irqchip = irq_desc_get_chip(desc);
 
 	chained_irq_enter(irqchip, desc);
#14 lore raw

PATCH 14/19 gpio/davinci: Prepare gpio_irq_handler for irq argument removal

In reply to Thomas Gleixner

The irq argument of most interrupt flow handlers is unused or merily used instead of a local variable. The handlers which need the irq argument can retrieve the irq number from the irq descriptor.

Search and update was done with coccinelle and the invaluable help of Julia Lawall.

Cc Julia Lawall <[email protected]>
Cc Jiang Liu <[email protected]>
Cc Linus Walleij <[email protected]>
Cc Alexandre Courbot <[email protected]>
---
 drivers/gpio/gpio-davinci.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpio/gpio-davinci.c +2 -1
Index: tip/drivers/gpio/gpio-davinci.c
===================================================================
@@ -327,8 +327,9 @@ static struct irq_chip gpio_irqchip = {
 };
 
 static void
-gpio_irq_handler(unsigned irq, struct irq_desc *desc)
+gpio_irq_handler(unsigned __irq, struct irq_desc *desc)
 {
+	unsigned int irq = irq_desc_get_irq(desc);
 	struct davinci_gpio_regs __iomem *g;
 	u32 mask = 0xffff;
 	struct davinci_gpio_controller *d;
#15 lore raw

PATCH 15/19 gpio/ep93xx: Prepare ep93xx_gpio_f_irq_handler for irq argument removal

In reply to Thomas Gleixner

The irq argument of most interrupt flow handlers is unused or merily used instead of a local variable. The handlers which need the irq argument can retrieve the irq number from the irq descriptor.

Search and update was done with coccinelle and the invaluable help of Julia Lawall.

Cc Julia Lawall <[email protected]>
Cc Jiang Liu <[email protected]>
Cc Linus Walleij <[email protected]>
Cc Alexandre Courbot <[email protected]>
---
 drivers/gpio/gpio-ep93xx.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpio/gpio-ep93xx.c +3 -1
Index: tip/drivers/gpio/gpio-ep93xx.c
===================================================================
@@ -100,13 +100,15 @@ static void ep93xx_gpio_ab_irq_handler(u
 	}
 }
 
-static void ep93xx_gpio_f_irq_handler(unsigned int irq, struct irq_desc *desc)
+static void ep93xx_gpio_f_irq_handler(unsigned int __irq,
+				      struct irq_desc *desc)
 {
 	/*
 	 * map discontiguous hw irq range to continuous sw irq range:
 	 *
 	 *  IRQ_EP93XX_GPIO{0..7}MUX -> gpio_to_irq(EP93XX_GPIO_LINE_F({0..7})
 	 */
+	unsigned int irq = irq_desc_get_irq(desc);
 	int port_f_idx = ((irq + 1) & 7) ^ 4; /* {19..22,47..50} -> {0..7} */
 	int gpio_irq = gpio_to_irq(EP93XX_GPIO_LINE_F(0)) + port_f_idx;
 
#16 lore raw

PATCH 16/19 gpio/mvebu: Prepare mvebu_gpio_irq_handler for irq argument removal

In reply to Thomas Gleixner

The irq argument of most interrupt flow handlers is unused or merily used instead of a local variable. The handlers which need the irq argument can retrieve the irq number from the irq descriptor.

Search and update was done with coccinelle and the invaluable help of Julia Lawall.

Cc Julia Lawall <[email protected]>
Cc Jiang Liu <[email protected]>
Cc Linus Walleij <[email protected]>
Cc Alexandre Courbot <[email protected]>
---
 drivers/gpio/gpio-mvebu.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpio-mvebu.c +1 -1
Index: tip/drivers/gpio/gpio-mvebu.c
===================================================================
@@ -458,7 +458,7 @@ static int mvebu_gpio_irq_set_type(struc
 	return 0;
 }
 
-static void mvebu_gpio_irq_handler(unsigned int irq, struct irq_desc *desc)
+static void mvebu_gpio_irq_handler(unsigned int __irq, struct irq_desc *desc)
 {
 	struct mvebu_gpio_chip *mvchip = irq_desc_get_handler_data(desc);
 	struct irq_chip *chip = irq_desc_get_chip(desc);
#17 lore raw

PATCH 17/19 gpio/sa1100: Prepare sa1100_gpio_handler for irq argument removal

In reply to Thomas Gleixner

The irq argument of most interrupt flow handlers is unused or merily used instead of a local variable. The handlers which need the irq argument can retrieve the irq number from the irq descriptor.

Search and update was done with coccinelle and the invaluable help of Julia Lawall.

Cc Julia Lawall <[email protected]>
Cc Jiang Liu <[email protected]>
Cc Linus Walleij <[email protected]>
Cc Alexandre Courbot <[email protected]>
---
 drivers/gpio/gpio-sa1100.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpio/gpio-sa1100.c +2 -2
Index: tip/drivers/gpio/gpio-sa1100.c
===================================================================
@@ -173,9 +173,9 @@ static struct irq_domain *sa1100_gpio_ir
  * and call the handler.
  */
 static void
-sa1100_gpio_handler(unsigned int irq, struct irq_desc *desc)
+sa1100_gpio_handler(unsigned int __irq, struct irq_desc *desc)
 {
-	unsigned int mask;
+	unsigned int irq, mask;
 
 	mask = GEDR;
 	do {
#18 lore raw

PATCH 18/19 gpio/msm-v2: Avoid redundant lookup of irq_data

In reply to Thomas Gleixner

It's pretty silly to do

     irq_data *d = irq_get_irq_data(irq_data->irq);

because that results in d = irq_data, but goes through a lookup of the irq_data. Use irq_data directly.

Cc Linus Walleij <[email protected]>
Cc Alexandre Courbot <[email protected]>
Cc Jiang Liu <[email protected]>
---
 drivers/gpio/gpio-msm-v2.c |   18 +++++-------------
 1 file changed, 5 insertions(+), 13 deletions(-)
drivers/gpio/gpio-msm-v2.c +5 -13
Index: tip/drivers/gpio/gpio-msm-v2.c
===================================================================
@@ -187,14 +187,6 @@ static int msm_gpio_to_irq(struct gpio_c
 	return irq_create_mapping(domain, offset);
 }
 
-static inline int msm_irq_to_gpio(struct gpio_chip *chip, unsigned irq)
-{
-	struct irq_data *irq_data = irq_get_irq_data(irq);
-
-	return irq_data->hwirq;
-}
-
-
 /* For dual-edge interrupts in software, since the hardware has no
  * such support:
  *
@@ -238,7 +230,7 @@ static void msm_gpio_update_dual_edge_po
 
 static void msm_gpio_irq_ack(struct irq_data *d)
 {
-	int gpio = msm_irq_to_gpio(&msm_gpio.gpio_chip, d->irq);
+	int gpio = d->hw_irq;
 
 	writel(BIT(INTR_STATUS), GPIO_INTR_STATUS(gpio));
 	if (test_bit(gpio, msm_gpio.dual_edge_irqs))
@@ -247,8 +239,8 @@ static void msm_gpio_irq_ack(struct irq_
 
 static void msm_gpio_irq_mask(struct irq_data *d)
 {
-	int gpio = msm_irq_to_gpio(&msm_gpio.gpio_chip, d->irq);
 	unsigned long irq_flags;
+	int gpio = d->hw_irq;
 
 	spin_lock_irqsave(&tlmm_lock, irq_flags);
 	writel(TARGET_PROC_NONE, GPIO_INTR_CFG_SU(gpio));
@@ -259,8 +251,8 @@ static void msm_gpio_irq_mask(struct irq
 
 static void msm_gpio_irq_unmask(struct irq_data *d)
 {
-	int gpio = msm_irq_to_gpio(&msm_gpio.gpio_chip, d->irq);
 	unsigned long irq_flags;
+	int gpio = d->hw_irq;
 
 	spin_lock_irqsave(&tlmm_lock, irq_flags);
 	__set_bit(gpio, msm_gpio.enabled_irqs);
@@ -271,8 +263,8 @@ static void msm_gpio_irq_unmask(struct i
 
 static int msm_gpio_irq_set_type(struct irq_data *d, unsigned int flow_type)
 {
-	int gpio = msm_irq_to_gpio(&msm_gpio.gpio_chip, d->irq);
 	unsigned long irq_flags;
+	int gpio = d->hw_irq;
 	uint32_t bits;
 
 	spin_lock_irqsave(&tlmm_lock, irq_flags);
@@ -331,7 +323,7 @@ static void msm_summary_irq_handler(unsi
 
 static int msm_gpio_irq_set_wake(struct irq_data *d, unsigned int on)
 {
-	int gpio = msm_irq_to_gpio(&msm_gpio.gpio_chip, d->irq);
+	int gpio = d->hw_irq;
 
 	if (on) {
 		if (bitmap_empty(msm_gpio.wake_irqs, MAX_NR_GPIO))

A message that is not in the archive (sent off-list or not yet received): CAKb7UviaGO2a=B7_4CbirQU=JLS5D_bNAe-PWzL-8Sp621rkYQ@mail.gmail.com

#20 lore raw

Re: [patch 18/19] gpio/msm-v2: Avoid redundant lookup of irq_data

Quoted 42 lines · Ilia Mirkin
Quoted 9 lines · On Jul 13, 2015 4:42 PM, "Thomas Gleixner" <[email protected]…

It's pretty silly to do

     irq_data *d = irq_get_irq_data(irq_data->irq);

because that results in d = irq_data, but goes through a lookup of the irq_data. Use irq_data directly.

<mailto:[email protected]>>

Quoted 1 line
Cc Linus Walleij <[email protected]

<mailto:[email protected]>>

Quoted 2 lines
Cc Alexandre Courbot <[email protected] <mailto:[email protected]>>
Cc Jiang Liu <[email protected]

<mailto:[email protected]>>

Quoted 24 lines
---
 drivers/gpio/gpio-msm-v2.c |   18 +++++-------------
 1 file changed, 5 insertions(+), 13 deletions(-)

Index: tip/drivers/gpio/gpio-msm-v2.c
===================================================================

drivers/gpio/gpio-msm-v2.c +0 -8
@@ -187,14 +187,6 @@ static int msm_gpio_to_irq(struct gpio_c
        return irq_create_mapping(domain, offset);
 }
 
-static inline int msm_irq_to_gpio(struct gpio_chip *chip, unsigned irq)
-{
-       struct irq_data *irq_data = irq_get_irq_data(irq);
-
-       return irq_data->hwirq;
-}
-
-
 /* For dual-edge interrupts in software, since the hardware has no
  * such support:
  *
Quoted 8 lines

drivers/gpio/gpio-msm-v2.c

Quoted 6 lines
drivers/gpio/gpio-msm-v2.c +0 -0
@@ -238,7 +230,7 @@ static void msm_gpio_update_dual_edge_po

w
static void msm_gpio_irq_ack(struct irq_data *d)
{

drivers/gpio/gpio-msm-v2.c +1 -1
-       int gpio = msm_irq_to_gpio(&msm_gpio.gpio_chip, d->irq);
+       int gpio = d->hw_irq;

Does this build? It was hwirq above, not hw_irq.

Yeah, should be hwirq.

#21 lore raw

Re: [patch 18/19] gpio/msm-v2: Avoid redundant lookup of irq_data

In reply to a message not in the archive
Quoted 6 lines · Ilia Mirkin

Review

Quoted 4 lines

static void msm_gpio_irq_ack(struct irq_data *d)
{

(quoted diff) +1 -1
-       int gpio = msm_irq_to_gpio(&msm_gpio.gpio_chip, d->irq);
+       int gpio = d->hw_irq;

Does this build? It was hwirq above, not hw_irq.

Indeed. Updated patch below.

Thanks,

tglx
---
Subject: gpio/msm-v2: Avoid redundant lookup of irq_data
From: Thomas Gleixner <[email protected]>
Date: Mon, 13 Jul 2015 01:07:01 +0200

It's pretty silly to do

     irq_data *d = irq_get_irq_data(irq_data->irq);

because that results in d = irq_data, but goes through a lookup of the irq_data. Use irq_data directly.

Cc Linus Walleij <[email protected]>
Cc Alexandre Courbot <[email protected]>
Cc Jiang Liu <[email protected]>
---
 drivers/gpio/gpio-msm-v2.c |   18 +++++-------------
 1 file changed, 5 insertions(+), 13 deletions(-)
drivers/gpio/gpio-msm-v2.c +5 -13
Index: tip/drivers/gpio/gpio-msm-v2.c
===================================================================
@@ -187,14 +187,6 @@ static int msm_gpio_to_irq(struct gpio_c
 	return irq_create_mapping(domain, offset);
 }
 
-static inline int msm_irq_to_gpio(struct gpio_chip *chip, unsigned irq)
-{
-	struct irq_data *irq_data = irq_get_irq_data(irq);
-
-	return irq_data->hwirq;
-}
-
-
 /* For dual-edge interrupts in software, since the hardware has no
  * such support:
  *
@@ -238,7 +230,7 @@ static void msm_gpio_update_dual_edge_po
 
 static void msm_gpio_irq_ack(struct irq_data *d)
 {
-	int gpio = msm_irq_to_gpio(&msm_gpio.gpio_chip, d->irq);
+	int gpio = d->hwirq;
 
 	writel(BIT(INTR_STATUS), GPIO_INTR_STATUS(gpio));
 	if (test_bit(gpio, msm_gpio.dual_edge_irqs))
@@ -247,8 +239,8 @@ static void msm_gpio_irq_ack(struct irq_
 
 static void msm_gpio_irq_mask(struct irq_data *d)
 {
-	int gpio = msm_irq_to_gpio(&msm_gpio.gpio_chip, d->irq);
 	unsigned long irq_flags;
+	int gpio = d->hwirq;
 
 	spin_lock_irqsave(&tlmm_lock, irq_flags);
 	writel(TARGET_PROC_NONE, GPIO_INTR_CFG_SU(gpio));
@@ -259,8 +251,8 @@ static void msm_gpio_irq_mask(struct irq
 
 static void msm_gpio_irq_unmask(struct irq_data *d)
 {
-	int gpio = msm_irq_to_gpio(&msm_gpio.gpio_chip, d->irq);
 	unsigned long irq_flags;
+	int gpio = d->hwirq;
 
 	spin_lock_irqsave(&tlmm_lock, irq_flags);
 	__set_bit(gpio, msm_gpio.enabled_irqs);
@@ -271,8 +263,8 @@ static void msm_gpio_irq_unmask(struct i
 
 static int msm_gpio_irq_set_type(struct irq_data *d, unsigned int flow_type)
 {
-	int gpio = msm_irq_to_gpio(&msm_gpio.gpio_chip, d->irq);
 	unsigned long irq_flags;
+	int gpio = d->hwirq;
 	uint32_t bits;
 
 	spin_lock_irqsave(&tlmm_lock, irq_flags);
@@ -331,7 +323,7 @@ static void msm_summary_irq_handler(unsi
 
 static int msm_gpio_irq_set_wake(struct irq_data *d, unsigned int on)
 {
-	int gpio = msm_irq_to_gpio(&msm_gpio.gpio_chip, d->irq);
+	int gpio = d->hwirq;
 
 	if (on) {
 		if (bitmap_empty(msm_gpio.wake_irqs, MAX_NR_GPIO))
#22 lore raw

PATCH 19/19 gpio/davinci: Avoid redundant lookup of irq_data

In reply to Thomas Gleixner

It's pretty silly to do

     void *cd = irq_get_chip_data(irq_data->irq);

because that results in cd = irq_data->chip_data, but goes through a redundant lookup of the irq_data. Use irq_data directly.

Cc Linus Walleij <[email protected]>
Cc Alexandre Courbot <[email protected]>
Cc Jiang Liu <[email protected]>
---
 drivers/gpio/gpio-davinci.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
---
 drivers/gpio/gpio-davinci.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpio/gpio-davinci.c +4 -4
Index: tip/drivers/gpio/gpio-davinci.c
===================================================================
@@ -65,11 +65,11 @@ static struct davinci_gpio_regs __iomem
 	return ptr;
 }
 
-static inline struct davinci_gpio_regs __iomem *irq2regs(int irq)
+static inline struct davinci_gpio_regs __iomem *irq2regs(struct irq_data *d)
 {
 	struct davinci_gpio_regs __iomem *g;
 
-	g = (__force struct davinci_gpio_regs __iomem *)irq_get_chip_data(irq);
+	g = (__force struct davinci_gpio_regs __iomem *)irq_data_get_chip_data(d);
 
 	return g;
 }
@@ -287,7 +287,7 @@ static int davinci_gpio_probe(struct pla
 
 static void gpio_irq_disable(struct irq_data *d)
 {
-	struct davinci_gpio_regs __iomem *g = irq2regs(d->irq);
+	struct davinci_gpio_regs __iomem *g = irq2regs(d);
 	u32 mask = (u32) irq_data_get_irq_handler_data(d);
 
 	writel_relaxed(mask, &g->clr_falling);
@@ -296,7 +296,7 @@ static void gpio_irq_disable(struct irq_
 
 static void gpio_irq_enable(struct irq_data *d)
 {
-	struct davinci_gpio_regs __iomem *g = irq2regs(d->irq);
+	struct davinci_gpio_regs __iomem *g = irq2regs(d);
 	u32 mask = (u32) irq_data_get_irq_handler_data(d);
 	unsigned status = irqd_get_trigger_type(d);
 
#23 lore raw

Re: [patch 19/19] gpio/davinci: Avoid redundant lookup of irq_data

Review

Quoted 2 lines · Thomas Gleixner
(quoted diff) +1 -1
-	g = (__force struct davinci_gpio_regs __iomem *)irq_get_chip_data(irq);
+	g = (__force struct davinci_gpio_regs __iomem *)irq_data_get_chip_data(d);

Too tired to use the proper function AND enable the Kconfig switch to compile it actually. Updated patch below. git branch irq/gpio is updated as well.

Thanks,

tglx

--------------->
Subject: gpio/davinci: Avoid redundant lookup of irq_data
From: Thomas Gleixner <[email protected]>
Date: Mon, 13 Jul 2015 01:18:56 +0200

It's pretty silly to do

     void *cd = irq_get_chip_data(irq_data->irq);

because that results in cd = irq_data->chip_data, but goes through a redundant lookup of the irq_data. Use irq_data directly.

Cc Linus Walleij <[email protected]>
Cc Alexandre Courbot <[email protected]>
Cc Jiang Liu <[email protected]>
---
 drivers/gpio/gpio-davinci.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
---
 drivers/gpio/gpio-davinci.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpio/gpio-davinci.c +4 -4
Index: tip/drivers/gpio/gpio-davinci.c
===================================================================
@@ -65,11 +65,11 @@ static struct davinci_gpio_regs __iomem
 	return ptr;
 }
 
-static inline struct davinci_gpio_regs __iomem *irq2regs(int irq)
+static inline struct davinci_gpio_regs __iomem *irq2regs(struct irq_data *d)
 {
 	struct davinci_gpio_regs __iomem *g;
 
-	g = (__force struct davinci_gpio_regs __iomem *)irq_get_chip_data(irq);
+	g = (__force struct davinci_gpio_regs __iomem *)irq_data_get_irq_chip_data(d);
 
 	return g;
 }
@@ -287,7 +287,7 @@ static int davinci_gpio_probe(struct pla
 
 static void gpio_irq_disable(struct irq_data *d)
 {
-	struct davinci_gpio_regs __iomem *g = irq2regs(d->irq);
+	struct davinci_gpio_regs __iomem *g = irq2regs(d);
 	u32 mask = (u32) irq_data_get_irq_handler_data(d);
 
 	writel_relaxed(mask, &g->clr_falling);
@@ -296,7 +296,7 @@ static void gpio_irq_disable(struct irq_
 
 static void gpio_irq_enable(struct irq_data *d)
 {
-	struct davinci_gpio_regs __iomem *g = irq2regs(d->irq);
+	struct davinci_gpio_regs __iomem *g = irq2regs(d);
 	u32 mask = (u32) irq_data_get_irq_handler_data(d);
 	unsigned status = irqd_get_trigger_type(d);
 
#24 lore raw
In reply to Thomas Gleixner
Quoted 7 lines · Thomas Gleixner

The following patch series contains the following changes:

- Consolidation of chained interrupt handler setup/removal

- Switch to functions which avoid a redundant interrupt descriptor lookup

Quoted 7 lines

- Preparation of interrupt flow handlers for the 'irq' argument removal

The series has no dependencies and is also available as a git branch for your convenience:

git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git irq/gpio

Hmm.....

git pull git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git irq/gpio
fatal: Couldn't find remote ref irq/gpio

Same with pinctrl, did you push it?

Or am I a shitty git operator ... don't rule that out :/

Yours,
Linus Walleij

#25 lore raw
Quoted 17 lines · Linus Walleij
Quoted 7 lines · Thomas Gleixner

The following patch series contains the following changes:

- Consolidation of chained interrupt handler setup/removal

- Switch to functions which avoid a redundant interrupt descriptor lookup

Quoted 7 lines

- Preparation of interrupt flow handlers for the 'irq' argument removal

The series has no dependencies and is also available as a git branch for your convenience:

git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git irq/gpio

Quoted 8 lines

Hmm.....

git pull git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git irq/gpio
fatal: Couldn't find remote ref irq/gpio

Same with pinctrl, did you push it?

Or am I a shitty git operator ... don't rule that out :/

No, I have moved the branches because they got accidentally pulled into next :)

git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git queue/irq/gpio
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git queue/irq/pinctrl

Both have the latest fixes included.

Thanks,

tglx

#26 lore raw
Quoted 9 lines · Thomas Gleixner
Quoted 6 lines · Linus Walleij

git pull git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git irq/gpio
fatal: Couldn't find remote ref irq/gpio

Same with pinctrl, did you push it?

Or am I a shitty git operator ... don't rule that out :/

Quoted 7 lines

No, I have moved the branches because they got accidentally pulled into next :)

git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git queue/irq/gpio
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git queue/irq/pinctrl

Both have the latest fixes included.

OK I pulled the GPIO patches to my GPIO tree and the pinctrl patches to the pinctrl tree and pushed to the 0day builder.

If it builds I will push both to next so they turn up there by tomorrow or so.

Yours,
Linus Walleij