diff options
author | David S. Miller <davem@davemloft.net> | 2008-10-30 02:18:41 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-12-04 12:16:44 -0500 |
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 { | |||
27 | static enum auxio_type auxio_devtype = AUXIO_TYPE_NODEV; | 27 | static enum auxio_type auxio_devtype = AUXIO_TYPE_NODEV; |
28 | static DEFINE_SPINLOCK(auxio_lock); | 28 | static DEFINE_SPINLOCK(auxio_lock); |
29 | 29 | ||
30 | static void __auxio_sbus_set(u8 bits_on, u8 bits_off) | 30 | static void __auxio_rmw(u8 bits_on, u8 bits_off, int ebus) |
31 | { | 31 | { |
32 | if (auxio_register) { | 32 | if (auxio_register) { |
33 | unsigned char regval; | ||
34 | unsigned long flags; | 33 | unsigned long flags; |
35 | unsigned char newval; | 34 | u8 regval, newval; |
36 | 35 | ||
37 | spin_lock_irqsave(&auxio_lock, flags); | 36 | spin_lock_irqsave(&auxio_lock, flags); |
38 | 37 | ||
39 | regval = sbus_readb(auxio_register); | 38 | regval = (ebus ? |
39 | (u8) readl(auxio_register) : | ||
40 | sbus_readb(auxio_register)); | ||
40 | newval = regval | bits_on; | 41 | newval = regval | bits_on; |
41 | newval &= ~bits_off; | 42 | newval &= ~bits_off; |
42 | newval &= ~AUXIO_AUX1_MASK; | 43 | if (!ebus) |
43 | sbus_writeb(newval, auxio_register); | 44 | newval &= ~AUXIO_AUX1_MASK; |
45 | if (ebus) | ||
46 | writel((u32) newval, auxio_register); | ||
47 | else | ||
48 | sbus_writeb(newval, auxio_register); | ||
44 | 49 | ||
45 | spin_unlock_irqrestore(&auxio_lock, flags); | 50 | spin_unlock_irqrestore(&auxio_lock, flags); |
46 | } | 51 | } |
47 | } | 52 | } |
48 | 53 | ||
49 | static void __auxio_ebus_set(u8 bits_on, u8 bits_off) | 54 | static void __auxio_set_bit(u8 bit, int on, int ebus) |
50 | { | 55 | { |
51 | if (auxio_register) { | 56 | u8 bits_on = (ebus ? AUXIO_PCIO_LED : AUXIO_AUX1_LED); |
52 | unsigned char regval; | 57 | u8 bits_off = 0; |
53 | unsigned long flags; | ||
54 | unsigned char newval; | ||
55 | |||
56 | spin_lock_irqsave(&auxio_lock, flags); | ||
57 | |||
58 | regval = (u8)readl(auxio_register); | ||
59 | newval = regval | bits_on; | ||
60 | newval &= ~bits_off; | ||
61 | writel((u32)newval, auxio_register); | ||
62 | 58 | ||
63 | spin_unlock_irqrestore(&auxio_lock, flags); | 59 | if (!on) { |
60 | u8 tmp = bits_off; | ||
61 | bits_off = bits_on; | ||
62 | bits_on = tmp; | ||
64 | } | 63 | } |
65 | } | 64 | __auxio_rmw(bits_on, bits_off, ebus); |
66 | |||
67 | static inline void __auxio_ebus_set_led(int on) | ||
68 | { | ||
69 | (on) ? __auxio_ebus_set(AUXIO_PCIO_LED, 0) : | ||
70 | __auxio_ebus_set(0, AUXIO_PCIO_LED) ; | ||
71 | } | ||
72 | |||
73 | static inline void __auxio_sbus_set_led(int on) | ||
74 | { | ||
75 | (on) ? __auxio_sbus_set(AUXIO_AUX1_LED, 0) : | ||
76 | __auxio_sbus_set(0, AUXIO_AUX1_LED) ; | ||
77 | } | 65 | } |
78 | 66 | ||
79 | void auxio_set_led(int on) | 67 | void auxio_set_led(int on) |
80 | { | 68 | { |
81 | switch(auxio_devtype) { | 69 | int ebus = auxio_devtype == AUXIO_TYPE_EBUS; |
82 | case AUXIO_TYPE_SBUS: | 70 | u8 bit; |
83 | __auxio_sbus_set_led(on); | 71 | |
84 | break; | 72 | bit = (ebus ? AUXIO_PCIO_LED : AUXIO_AUX1_LED); |
85 | case AUXIO_TYPE_EBUS: | 73 | __auxio_set_bit(bit, on, ebus); |
86 | __auxio_ebus_set_led(on); | ||
87 | break; | ||
88 | default: | ||
89 | break; | ||
90 | } | ||
91 | } | 74 | } |
92 | 75 | ||
93 | static inline void __auxio_sbus_set_lte(int on) | 76 | static void __auxio_sbus_set_lte(int on) |
94 | { | 77 | { |
95 | (on) ? __auxio_sbus_set(AUXIO_AUX1_LTE, 0) : | 78 | __auxio_set_bit(AUXIO_AUX1_LTE, on, 0); |
96 | __auxio_sbus_set(0, AUXIO_AUX1_LTE) ; | ||
97 | } | 79 | } |
98 | 80 | ||
99 | void auxio_set_lte(int on) | 81 | void auxio_set_lte(int on) |