mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andreas Mohr <andi@rhlx01.fht-esslingen.de>
To: Andrew Morton <akpm@osdl.org>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] -mm: i386 i8259.c simplify i8259A_irq_real()
Date: Fri, 28 Apr 2006 00:14:52 +0200	[thread overview]
Message-ID: <20060427221452.GA29019@rhlx01.fht-esslingen.de> (raw)

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;
 }
 

             reply	other threads:[~2006-04-27 22:14 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-04-27 22:14 Andreas Mohr [this message]
2006-04-27 23:34 ` Andrew Morton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060427221452.GA29019@rhlx01.fht-esslingen.de \
    --to=andi@rhlx01.fht-esslingen.de \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®