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 {
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;
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)
......
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