diff options
author | David S. Miller <davem@davemloft.net> | 2008-10-29 23:18:41 -0700 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-12-04 09:16:44 -0800 |
commit | 86821d18f9d8fd42fa3180ad3703d491aecc52d9 (patch) | |
tree | 003f664c4bbe560968207a0067340fa3728e9b15 /arch | |
parent | 6d1e428a4e02761250c6498fe63657444fdfc3d5 (diff) |
sparc64: Rework auxio driver to save some text space.
Use common functions instead of inlining and duplicating logic
over and over to handle the SBUS vs. EBUS cases.
Before:
text data bss dec hex filename
715 568 16 1299 513 arch/sparc64/kernel/auxio.o
After:
text data bss dec hex filename
631 568 16 1215 4bf arch/sparc64/kernel/auxio.o
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/sparc64/kernel/auxio.c | 70 |
1 files changed, 26 insertions, 44 deletions
diff --git a/arch/sparc64/kernel/auxio.c b/arch/sparc64/kernel/auxio.c index 858beda86524..8b67347d4221 100644 --- a/arch/sparc64/kernel/auxio.c +++ b/arch/sparc64/kernel/auxio.c @@ -27,73 +27,55 @@ enum auxio_type { static enum auxio_type auxio_devtype = AUXIO_TYPE_NODEV; static DEFINE_SPINLOCK(auxio_lock); -static void __auxio_sbus_set(u8 bits_on, u8 bits_off) +static void __auxio_rmw(u8 bits_on, u8 bits_off, int ebus) { if (auxio_register) { - unsigned char regval; unsigned long flags; - unsigned char newval; + u8 regval, newval; spin_lock_irqsave(&auxio_lock, flags); - regval = sbus_readb(auxio_register); + regval = (ebus ? + (u8) readl(auxio_register) : + sbus_readb(auxio_register)); newval = regval | bits_on; newval &= ~bits_off; - newval &= ~AUXIO_AUX1_MASK; - sbus_writeb(newval, auxio_register); + if (!ebus) + newval &= ~AUXIO_AUX1_MASK; + if (ebus) + writel((u32) newval, auxio_register); + else + sbus_writeb(newval, auxio_register); spin_unlock_irqrestore(&auxio_lock, flags); } } -static void __auxio_ebus_set(u8 bits_on, u8 bits_off) +static void __auxio_set_bit(u8 bit, int on, int ebus) { - if (auxio_register) { - unsigned char regval; - unsigned long flags; - unsigned char newval; - - spin_lock_irqsave(&auxio_lock, flags); - - regval = (u8)readl(auxio_register); - newval = regval | bits_on; - newval &= ~bits_off; - writel((u32)newval, auxio_register); + u8 bits_on = (ebus ? AUXIO_PCIO_LED : AUXIO_AUX1_LED); + u8 bits_off = 0; - spin_unlock_irqrestore(&auxio_lock, flags); + if (!on) { + u8 tmp = bits_off; + bits_off = bits_on; + bits_on = tmp; } -} - -static inline void __auxio_ebus_set_led(int on) -{ - (on) ? __auxio_ebus_set(AUXIO_PCIO_LED, 0) : - __auxio_ebus_set(0, AUXIO_PCIO_LED) ; -} - -static inline void __auxio_sbus_set_led(int on) -{ - (on) ? __auxio_sbus_set(AUXIO_AUX1_LED, 0) : - __auxio_sbus_set(0, AUXIO_AUX1_LED) ; + __auxio_rmw(bits_on, bits_off, ebus); } void auxio_set_led(int on) { - switch(auxio_devtype) { - case AUXIO_TYPE_SBUS: - __auxio_sbus_set_led(on); - break; - case AUXIO_TYPE_EBUS: - __auxio_ebus_set_led(on); - break; - default: - break; - } + int ebus = auxio_devtype == AUXIO_TYPE_EBUS; + u8 bit; + + bit = (ebus ? AUXIO_PCIO_LED : AUXIO_AUX1_LED); + __auxio_set_bit(bit, on, ebus); } -static inline void __auxio_sbus_set_lte(int on) +static void __auxio_sbus_set_lte(int on) { - (on) ? __auxio_sbus_set(AUXIO_AUX1_LTE, 0) : - __auxio_sbus_set(0, AUXIO_AUX1_LTE) ; + __auxio_set_bit(AUXIO_AUX1_LTE, on, 0); } void auxio_set_lte(int on) |