mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] -mm: i386 i8259.c simplify i8259A_irq_real()
@ 2006-04-27 22:14 Andreas Mohr
  2006-04-27 23:34 ` Andrew Morton
  0 siblings, 1 reply; 2+ messages in thread
From: Andreas Mohr @ 2006-04-27 22:14 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel

Hello all,

I noticed the very "non-nice" asymmetry of i8259A_irq_real(),
so I decided to fix the weirdly aligned branches.
While doing this, I noticed that it could be streamlined much more,
resulting in an astonishing 208 byte object code saving for such a tiny code
fragment! (gcc 3.2.3)

Review appreciated, I believe it's correct but I've only tested it shortly
and it's slowpath anyway.

Patch against 2.6.17-rc2-mm1.

Thanks!

Signed-off-by: Andreas Mohr <andi@lisas.de>


--- linux-2.6.17-rc2-mm1.orig/arch/i386/kernel/i8259.c	2006-04-18 11:45:21.000000000 +0200
+++ linux-2.6.17-rc2-mm1/arch/i386/kernel/i8259.c	2006-04-27 23:57:34.000000000 +0200
@@ -145,17 +145,20 @@
 static inline int i8259A_irq_real(unsigned int irq)
 {
 	int value;
-	int irqmask = 1<<irq;
+	int irqmask;
+	int reg;
 
 	if (irq < 8) {
-		outb(0x0B,PIC_MASTER_CMD);	/* ISR register */
-		value = inb(PIC_MASTER_CMD) & irqmask;
-		outb(0x0A,PIC_MASTER_CMD);	/* back to the IRR register */
-		return value;
+		reg = PIC_MASTER_CMD;
+		irqmask = 1 << irq;
+	} else {
+		reg = PIC_SLAVE_CMD;
+		irqmask = 1 << (irq - 8);
 	}
-	outb(0x0B,PIC_SLAVE_CMD);	/* ISR register */
-	value = inb(PIC_SLAVE_CMD) & (irqmask >> 8);
-	outb(0x0A,PIC_SLAVE_CMD);	/* back to the IRR register */
+
+	outb(0x0B, reg);	/* ISR register */
+	value = inb(reg) & irqmask;
+	outb(0x0A, reg);	/* back to the IRR register */
 	return value;
 }
 

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

end of thread, other threads:[~2006-04-27 23:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-04-27 22:14 [PATCH] -mm: i386 i8259.c simplify i8259A_irq_real() Andreas Mohr
2006-04-27 23:34 ` Andrew Morton

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

all inboxes | Powered by JetHome®