[PATCH] -mm: i386 i8259.c simplify i8259A_irq_real()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <[email protected]>


--- 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;
 }
 
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux