Commit c483bb4c authored by Ivo van Doorn's avatar Ivo van Doorn Committed by John W. Linville

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: default avatarIvo van Doorn <IvDoorn@gmail.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 70249816
...@@ -198,46 +198,35 @@ struct rt2x00_field32 { ...@@ -198,46 +198,35 @@ struct rt2x00_field32 {
}; \ }; \
}) })
static inline void rt2x00_set_field32(u32 *reg, #define SET_FIELD(__reg, __type, __field, __value)\
const struct rt2x00_field32 field, ({ \
const u32 value) typecheck(__type, __field); \
{ *(__reg) &= ~((__field).bit_mask); \
*reg &= ~(field.bit_mask); *(__reg) |= ((__value) << \
*reg |= (value << field.bit_offset) & field.bit_mask; ((__field).bit_offset)) & \
} ((__field).bit_mask); \
})
static inline u32 rt2x00_get_field32(const u32 reg,
const struct rt2x00_field32 field) #define GET_FIELD(__reg, __type, __field) \
{ ({ \
return (reg & field.bit_mask) >> field.bit_offset; typecheck(__type, __field); \
} ((__reg) & ((__field).bit_mask)) >> \
((__field).bit_offset); \
static inline void rt2x00_set_field16(u16 *reg, })
const struct rt2x00_field16 field,
const u16 value) #define rt2x00_set_field32(__reg, __field, __value) \
{ SET_FIELD(__reg, struct rt2x00_field32, __field, __value)
*reg &= ~(field.bit_mask); #define rt2x00_get_field32(__reg, __field) \
*reg |= (value << field.bit_offset) & field.bit_mask; GET_FIELD(__reg, struct rt2x00_field32, __field)
}
#define rt2x00_set_field16(__reg, __field, __value) \
static inline u16 rt2x00_get_field16(const u16 reg, SET_FIELD(__reg, struct rt2x00_field16, __field, __value)
const struct rt2x00_field16 field) #define rt2x00_get_field16(__reg, __field) \
{ GET_FIELD(__reg, struct rt2x00_field16, __field)
return (reg & field.bit_mask) >> field.bit_offset;
} #define rt2x00_set_field8(__reg, __field, __value) \
SET_FIELD(__reg, struct rt2x00_field8, __field, __value)
static inline void rt2x00_set_field8(u8 *reg, #define rt2x00_get_field8(__reg, __field) \
const struct rt2x00_field8 field, GET_FIELD(__reg, struct rt2x00_field8, __field)
const u8 value)
{
*reg &= ~(field.bit_mask);
*reg |= (value << field.bit_offset) & field.bit_mask;
}
static inline u8 rt2x00_get_field8(const u8 reg,
const struct rt2x00_field8 field)
{
return (reg & field.bit_mask) >> field.bit_offset;
}
#endif /* RT2X00REG_H */ #endif /* RT2X00REG_H */
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