Commit 86821d18 authored by David S. Miller's avatar David S. Miller

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: default avatarDavid S. Miller <davem@davemloft.net>
parent 6d1e428a
...@@ -27,73 +27,55 @@ enum auxio_type { ...@@ -27,73 +27,55 @@ enum auxio_type {
static enum auxio_type auxio_devtype = AUXIO_TYPE_NODEV; static enum auxio_type auxio_devtype = AUXIO_TYPE_NODEV;
static DEFINE_SPINLOCK(auxio_lock); 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) { if (auxio_register) {
unsigned char regval;
unsigned long flags; unsigned long flags;
unsigned char newval; u8 regval, newval;
spin_lock_irqsave(&auxio_lock, flags); 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 = regval | bits_on;
newval &= ~bits_off; newval &= ~bits_off;
if (!ebus)
newval &= ~AUXIO_AUX1_MASK; newval &= ~AUXIO_AUX1_MASK;
if (ebus)
writel((u32) newval, auxio_register);
else
sbus_writeb(newval, auxio_register); sbus_writeb(newval, auxio_register);
spin_unlock_irqrestore(&auxio_lock, flags); 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) { u8 bits_on = (ebus ? AUXIO_PCIO_LED : AUXIO_AUX1_LED);
unsigned char regval; u8 bits_off = 0;
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);
spin_unlock_irqrestore(&auxio_lock, flags); if (!on) {
u8 tmp = bits_off;
bits_off = bits_on;
bits_on = tmp;
} }
} __auxio_rmw(bits_on, bits_off, ebus);
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) ;
} }
void auxio_set_led(int on) void auxio_set_led(int on)
{ {
switch(auxio_devtype) { int ebus = auxio_devtype == AUXIO_TYPE_EBUS;
case AUXIO_TYPE_SBUS: u8 bit;
__auxio_sbus_set_led(on);
break; bit = (ebus ? AUXIO_PCIO_LED : AUXIO_AUX1_LED);
case AUXIO_TYPE_EBUS: __auxio_set_bit(bit, on, ebus);
__auxio_ebus_set_led(on);
break;
default:
break;
}
} }
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_set_bit(AUXIO_AUX1_LTE, on, 0);
__auxio_sbus_set(0, AUXIO_AUX1_LTE) ;
} }
void auxio_set_lte(int on) void auxio_set_lte(int on)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment