diff options
author | Ivo van Doorn <IvDoorn@gmail.com> | 2008-06-03 14:29:43 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2008-06-14 12:17:55 -0400 |
commit | c483bb4cbdeb24d9d3bc0dc4248fdcb1f4c55244 (patch) | |
tree | e495da16c44655ed848643a0218db2ec4dec75ff /drivers/net | |
parent | 70249816a87b3c2293dc7b33331e614c67666336 (diff) |
rt2x00: Make rt2x00_set/get_field macros
The rt2x00_set_field functions are very often used,
but GCC is better able to optimize them when they
are macros instead of static inline functions.
After changing it to macro's each rt2x00 driver will
loose about ~3500 bytes in size.
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2x00reg.h | 71 |
1 files changed, 30 insertions, 41 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2x00reg.h b/drivers/net/wireless/rt2x00/rt2x00reg.h index b0d27edcc330..c3f1202404d9 100644 --- a/drivers/net/wireless/rt2x00/rt2x00reg.h +++ b/drivers/net/wireless/rt2x00/rt2x00reg.h | |||
@@ -198,46 +198,35 @@ struct rt2x00_field32 { | |||
198 | }; \ | 198 | }; \ |
199 | }) | 199 | }) |
200 | 200 | ||
201 | static inline void rt2x00_set_field32(u32 *reg, | 201 | #define SET_FIELD(__reg, __type, __field, __value)\ |
202 | const struct rt2x00_field32 field, | 202 | ({ \ |
203 | const u32 value) | 203 | typecheck(__type, __field); \ |
204 | { | 204 | *(__reg) &= ~((__field).bit_mask); \ |
205 | *reg &= ~(field.bit_mask); | 205 | *(__reg) |= ((__value) << \ |
206 | *reg |= (value << field.bit_offset) & field.bit_mask; | 206 | ((__field).bit_offset)) & \ |
207 | } | 207 | ((__field).bit_mask); \ |
208 | 208 | }) | |
209 | static inline u32 rt2x00_get_field32(const u32 reg, | 209 | |
210 | const struct rt2x00_field32 field) | 210 | #define GET_FIELD(__reg, __type, __field) \ |
211 | { | 211 | ({ \ |
212 | return (reg & field.bit_mask) >> field.bit_offset; | 212 | typecheck(__type, __field); \ |
213 | } | 213 | ((__reg) & ((__field).bit_mask)) >> \ |
214 | 214 | ((__field).bit_offset); \ | |
215 | static inline void rt2x00_set_field16(u16 *reg, | 215 | }) |
216 | const struct rt2x00_field16 field, | 216 | |
217 | const u16 value) | 217 | #define rt2x00_set_field32(__reg, __field, __value) \ |
218 | { | 218 | SET_FIELD(__reg, struct rt2x00_field32, __field, __value) |
219 | *reg &= ~(field.bit_mask); | 219 | #define rt2x00_get_field32(__reg, __field) \ |
220 | *reg |= (value << field.bit_offset) & field.bit_mask; | 220 | GET_FIELD(__reg, struct rt2x00_field32, __field) |
221 | } | 221 | |
222 | 222 | #define rt2x00_set_field16(__reg, __field, __value) \ | |
223 | static inline u16 rt2x00_get_field16(const u16 reg, | 223 | SET_FIELD(__reg, struct rt2x00_field16, __field, __value) |
224 | const struct rt2x00_field16 field) | 224 | #define rt2x00_get_field16(__reg, __field) \ |
225 | { | 225 | GET_FIELD(__reg, struct rt2x00_field16, __field) |
226 | return (reg & field.bit_mask) >> field.bit_offset; | 226 | |
227 | } | 227 | #define rt2x00_set_field8(__reg, __field, __value) \ |
228 | 228 | SET_FIELD(__reg, struct rt2x00_field8, __field, __value) | |
229 | static inline void rt2x00_set_field8(u8 *reg, | 229 | #define rt2x00_get_field8(__reg, __field) \ |
230 | const struct rt2x00_field8 field, | 230 | GET_FIELD(__reg, struct rt2x00_field8, __field) |
231 | const u8 value) | ||
232 | { | ||
233 | *reg &= ~(field.bit_mask); | ||
234 | *reg |= (value << field.bit_offset) & field.bit_mask; | ||
235 | } | ||
236 | |||
237 | static inline u8 rt2x00_get_field8(const u8 reg, | ||
238 | const struct rt2x00_field8 field) | ||
239 | { | ||
240 | return (reg & field.bit_mask) >> field.bit_offset; | ||
241 | } | ||
242 | 231 | ||
243 | #endif /* RT2X00REG_H */ | 232 | #endif /* RT2X00REG_H */ |