public inbox for linux-omap@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] IRQ: simplify OMAP2 mask_irq/unmask_irq code
@ 2008-05-20 18:21 Paul Walmsley
  2008-05-20 23:18 ` Kyungmin Park
  0 siblings, 1 reply; 11+ messages in thread
From: Paul Walmsley @ 2008-05-20 18:21 UTC (permalink / raw)
  To: linux-omap; +Cc: lethal


Simplify the IRQ register/IRQ register bit calculations in
mach-omap2/irq.c.  

Test-booted on 3430SDP.

Signed-off-by: Paul Walmsley <paul@pwsan.com>

---

size:
   text    data     bss     dec     hex filename
3341347  170992  109008 3621347  3741e3 vmlinux.3430sdp
3341315  170992  109008 3621315  3741c3 vmlinux.3430sdp.patched

---

 arch/arm/mach-omap2/irq.c |   17 +++++++----------
 1 files changed, 7 insertions(+), 10 deletions(-)


diff --git a/arch/arm/mach-omap2/irq.c b/arch/arm/mach-omap2/irq.c
index ac062ee..f610825 100644
--- a/arch/arm/mach-omap2/irq.c
+++ b/arch/arm/mach-omap2/irq.c
@@ -27,6 +27,9 @@
 #define INTC_MIR_CLEAR0	0x0088
 #define INTC_MIR_SET0	0x008c
 
+/* Number of IRQ state bits in each MIR register */
+#define IRQ_BITS_PER_REG	32
+
 /*
  * OMAP2 has a number of different interrupt controllers, each interrupt
  * controller is identified as its own "bank". Register definitions are
@@ -67,24 +70,18 @@ static void omap_ack_irq(unsigned int irq)
 
 static void omap_mask_irq(unsigned int irq)
 {
-	int offset = (irq >> 5) << 5;
+	int offset = irq & (~(IRQ_BITS_PER_REG - 1));
 
-	if (irq >= 64)
-		irq %= 64;
-	else if (irq >= 32)
-		irq %= 32;
+	irq %= IRQ_BITS_PER_REG;
 
 	intc_bank_write_reg(1 << irq, &irq_banks[0], INTC_MIR_SET0 + offset);
 }
 
 static void omap_unmask_irq(unsigned int irq)
 {
-	int offset = (irq >> 5) << 5;
+	int offset = irq & (~(IRQ_BITS_PER_REG - 1));
 
-	if (irq >= 64)
-		irq %= 64;
-	else if (irq >= 32)
-		irq %= 32;
+	irq %= IRQ_BITS_PER_REG;
 
 	intc_bank_write_reg(1 << irq, &irq_banks[0], INTC_MIR_CLEAR0 + offset);
 }

^ permalink raw reply related	[flat|nested] 11+ messages in thread
* [PATCH] IRQ: simplify OMAP2 mask_irq/unmask_irq code
@ 2008-05-21  1:19 Paul Walmsley
  2008-05-21 15:05 ` Tony Lindgren
  0 siblings, 1 reply; 11+ messages in thread
From: Paul Walmsley @ 2008-05-21  1:19 UTC (permalink / raw)
  To: linux-omap; +Cc: Paul Mundt, Kyungmin Park


Modify mach-omap2/irq.c to simplify the IRQ number-to-IRQ register and IRQ 
number-to-register bit calculations.

Signed-off-by: Kyungmin Park <kmpark@infradead.org>
Signed-off-by: Paul Walmsley <paul@pwsan.com>
Acked-by: Paul Mundt <lethal@linux-sh.org>

size:
   text    data     bss     dec     hex filename
3341347  170992  109008 3621347  3741e3 vmlinux.3430sdp
3341315  170992  109008 3621315  3741c3 vmlinux.3430sdp.patched
---

 arch/arm/mach-omap2/irq.c |   17 +++++++----------
 1 files changed, 7 insertions(+), 10 deletions(-)


diff --git a/arch/arm/mach-omap2/irq.c b/arch/arm/mach-omap2/irq.c
index ac062ee..9300712 100644
--- a/arch/arm/mach-omap2/irq.c
+++ b/arch/arm/mach-omap2/irq.c
@@ -27,6 +27,9 @@
 #define INTC_MIR_CLEAR0	0x0088
 #define INTC_MIR_SET0	0x008c
 
+/* Number of IRQ state bits in each MIR register */
+#define IRQ_BITS_PER_REG	32
+
 /*
  * OMAP2 has a number of different interrupt controllers, each interrupt
  * controller is identified as its own "bank". Register definitions are
@@ -67,24 +70,18 @@ static void omap_ack_irq(unsigned int irq)
 
 static void omap_mask_irq(unsigned int irq)
 {
-	int offset = (irq >> 5) << 5;
+	int offset = irq & (~(IRQ_BITS_PER_REG - 1));
 
-	if (irq >= 64)
-		irq %= 64;
-	else if (irq >= 32)
-		irq %= 32;
+	irq &= (IRQ_BITS_PER_REG - 1);
 
 	intc_bank_write_reg(1 << irq, &irq_banks[0], INTC_MIR_SET0 + offset);
 }
 
 static void omap_unmask_irq(unsigned int irq)
 {
-	int offset = (irq >> 5) << 5;
+	int offset = irq & (~(IRQ_BITS_PER_REG - 1));
 
-	if (irq >= 64)
-		irq %= 64;
-	else if (irq >= 32)
-		irq %= 32;
+	irq &= (IRQ_BITS_PER_REG - 1);
 
 	intc_bank_write_reg(1 << irq, &irq_banks[0], INTC_MIR_CLEAR0 + offset);
 }

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2008-05-22 19:50 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-20 18:21 [PATCH] IRQ: simplify OMAP2 mask_irq/unmask_irq code Paul Walmsley
2008-05-20 23:18 ` Kyungmin Park
2008-05-21  0:12   ` Paul Walmsley
2008-05-21  0:39     ` Philip Balister
2008-05-21  0:52       ` Kyungmin Park
2008-05-21  0:55     ` Paul Mundt
2008-05-21  1:19       ` Paul Walmsley
  -- strict thread matches above, loose matches on Subject: below --
2008-05-21  1:19 Paul Walmsley
2008-05-21 15:05 ` Tony Lindgren
2008-05-21 19:15   ` Paul Walmsley
2008-05-22 19:50     ` Tony Lindgren

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox