diff options
-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 */ |