[PATCH 2/2] glamo-core: use a standard irq handler for irq demultiplexing

Thibaut Girka thib at sitedethib.com
Thu Jun 24 00:51:13 CEST 2010


Use a standard irq handler for irq demultiplexing instead of a chained handler.
Remove reimplementation of handle_level_irq and simplifies code.
---
 drivers/mfd/glamo-core.c |   59 +++++++++++++--------------------------------
 1 files changed, 17 insertions(+), 42 deletions(-)

diff --git a/drivers/mfd/glamo-core.c b/drivers/mfd/glamo-core.c
index b90146a..48f56fa 100644
--- a/drivers/mfd/glamo-core.c
+++ b/drivers/mfd/glamo-core.c
@@ -302,46 +302,18 @@ static struct irq_chip glamo_irq_chip = {
 	.unmask	= glamo_unmask_irq,
 };
 
-static void glamo_irq_demux_handler(unsigned int irq, struct irq_desc *desc)
+static irqreturn_t glamo_irq_demux_handler(int irq, void *data)
 {
-	struct glamo_core *glamo = get_irq_desc_data(desc);
-	desc->status &= ~(IRQ_REPLAY | IRQ_WAITING);
-
-	if (unlikely(desc->status & IRQ_INPROGRESS)) {
-		desc->status |= (IRQ_PENDING | IRQ_MASKED);
-		desc->chip->mask(irq);
-		desc->chip->ack(irq);
-		return;
+	struct glamo_core *glamo = data;
+	uint16_t irqstatus;
+	int i;
+	/* read IRQ status register */
+	irqstatus = __reg_read(glamo, GLAMO_REG_IRQ_STATUS);
+	for (i = 0; i < 9; ++i) {
+		if (irqstatus & BIT(i))
+			generic_handle_irq(glamo->irq_base + i);
 	}
-	kstat_incr_irqs_this_cpu(irq, desc);
-
-	desc->chip->ack(irq);
-	desc->status |= IRQ_INPROGRESS;
-
-	do {
-		uint16_t irqstatus;
-		int i;
-
-		if (unlikely((desc->status &
-				(IRQ_PENDING | IRQ_MASKED | IRQ_DISABLED)) ==
-				(IRQ_PENDING | IRQ_MASKED))) {
-			/* dealing with pending IRQ, unmasking */
-			desc->chip->unmask(irq);
-			desc->status &= ~IRQ_MASKED;
-		}
-
-		desc->status &= ~IRQ_PENDING;
-
-		/* read IRQ status register */
-		irqstatus = __reg_read(glamo, GLAMO_REG_IRQ_STATUS);
-		for (i = 0; i < 9; ++i) {
-			if (irqstatus & BIT(i))
-				generic_handle_irq(glamo->irq_base + i);
-		}
-
-	} while ((desc->status & (IRQ_PENDING | IRQ_DISABLED)) == IRQ_PENDING);
-
-	desc->status &= ~IRQ_INPROGRESS;
+	return IRQ_HANDLED;
 }
 
 /*
@@ -985,10 +957,6 @@ static int __devinit glamo_probe(struct platform_device *pdev)
 					handle_level_irq);
 	}
 
-	set_irq_type(glamo->irq, IRQ_TYPE_EDGE_FALLING);
-	set_irq_data(glamo->irq, glamo);
-	set_irq_chained_handler(glamo->irq, glamo_irq_demux_handler);
-
 	ret = mfd_add_devices(&pdev->dev, pdev->id, glamo_cells,
 				ARRAY_SIZE(glamo_cells), mem, glamo->irq_base);
 
@@ -997,6 +965,13 @@ static int __devinit glamo_probe(struct platform_device *pdev)
 		goto err_free_irqs;
 	}
 
+	ret = request_irq(glamo->irq, glamo_irq_demux_handler, 0,
+			  "glamo-core", glamo);
+	if (ret) {
+		dev_err(&pdev->dev, "Failed to grab irq%d: %d\n", glamo->irq, ret);
+		goto err_free_irqs;
+	}
+
 	dev_info(&glamo->pdev->dev, "Glamo core PLL1: %uHz, PLL2: %uHz\n",
 		 glamo_pll_rate(glamo, GLAMO_PLL1),
 		 glamo_pll_rate(glamo, GLAMO_PLL2));
-- 
1.7.1




More information about the openmoko-kernel mailing list