diff options
author | Tomas Winkler <tomas.winkler@intel.com> | 2008-10-24 02:48:55 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2008-10-31 19:02:27 -0400 |
commit | 127901ab69bbb263fb2b46e850cf20c57ac321d3 (patch) | |
tree | 35ab1fa324ca430ab486e9bc63cfea41966b1c49 /drivers/net/wireless/iwlwifi/iwl-helpers.h | |
parent | 951891c7ef844919d30aac7b1fc7396fd8be23ff (diff) |
iwlwifi: refactor tx byte count table usage
This patch drops unreadable usage of IWL_SET/GET_BITS16 in byte count
tables handling
This patch also cleans a bit the byte count table code and adds
WARN_ON traps on invalid values
This patch is pure cleanup, no functional changes.
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Cc: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/iwlwifi/iwl-helpers.h')
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-helpers.h | 102 |
1 files changed, 0 insertions, 102 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-helpers.h b/drivers/net/wireless/iwlwifi/iwl-helpers.h index 029d19c7075..4f0fa215d32 100644 --- a/drivers/net/wireless/iwlwifi/iwl-helpers.h +++ b/drivers/net/wireless/iwlwifi/iwl-helpers.h | |||
@@ -32,108 +32,6 @@ | |||
32 | 32 | ||
33 | #include <linux/ctype.h> | 33 | #include <linux/ctype.h> |
34 | 34 | ||
35 | /* | ||
36 | * The structures defined by the hardware/uCode interface | ||
37 | * have bit-wise operations. For each bit-field there is | ||
38 | * a data symbol in the structure, the start bit position | ||
39 | * and the length of the bit-field. | ||
40 | * | ||
41 | * iwl_get_bits and iwl_set_bits will return or set the | ||
42 | * appropriate bits on a 32-bit value. | ||
43 | * | ||
44 | * IWL_GET_BITS and IWL_SET_BITS use symbol expansion to | ||
45 | * expand out to the appropriate call to iwl_get_bits | ||
46 | * and iwl_set_bits without having to reference all of the | ||
47 | * numerical constants and defines provided in the hardware | ||
48 | * definition | ||
49 | */ | ||
50 | |||
51 | /** | ||
52 | * iwl_get_bits - Extract a hardware bit-field value | ||
53 | * @src: source hardware value (__le32) | ||
54 | * @pos: bit-position (0-based) of first bit of value | ||
55 | * @len: length of bit-field | ||
56 | * | ||
57 | * iwl_get_bits will return the bit-field in cpu endian ordering. | ||
58 | * | ||
59 | * NOTE: If used from IWL_GET_BITS then pos and len are compile-constants and | ||
60 | * will collapse to minimal code by the compiler. | ||
61 | */ | ||
62 | static inline u32 iwl_get_bits(__le32 src, u8 pos, u8 len) | ||
63 | { | ||
64 | u32 tmp = le32_to_cpu(src); | ||
65 | |||
66 | tmp >>= pos; | ||
67 | tmp &= (1UL << len) - 1; | ||
68 | return tmp; | ||
69 | } | ||
70 | |||
71 | /** | ||
72 | * iwl_set_bits - Set a hardware bit-field value | ||
73 | * @dst: Address of __le32 hardware value | ||
74 | * @pos: bit-position (0-based) of first bit of value | ||
75 | * @len: length of bit-field | ||
76 | * @val: cpu endian value to encode into the bit-field | ||
77 | * | ||
78 | * iwl_set_bits will encode val into dst, masked to be len bits long at bit | ||
79 | * position pos. | ||
80 | * | ||
81 | * NOTE: If used IWL_SET_BITS pos and len will be compile-constants and | ||
82 | * will collapse to minimal code by the compiler. | ||
83 | */ | ||
84 | static inline void iwl_set_bits(__le32 *dst, u8 pos, u8 len, int val) | ||
85 | { | ||
86 | u32 tmp = le32_to_cpu(*dst); | ||
87 | |||
88 | tmp &= ~(((1UL << len) - 1) << pos); | ||
89 | tmp |= (val & ((1UL << len) - 1)) << pos; | ||
90 | *dst = cpu_to_le32(tmp); | ||
91 | } | ||
92 | |||
93 | static inline void iwl_set_bits16(__le16 *dst, u8 pos, u8 len, int val) | ||
94 | { | ||
95 | u16 tmp = le16_to_cpu(*dst); | ||
96 | |||
97 | tmp &= ~((1UL << (pos + len)) - (1UL << pos)); | ||
98 | tmp |= (val & ((1UL << len) - 1)) << pos; | ||
99 | *dst = cpu_to_le16(tmp); | ||
100 | } | ||
101 | |||
102 | /* | ||
103 | * The bit-field definitions in iwl-xxxx-hw.h are in the form of: | ||
104 | * | ||
105 | * struct example { | ||
106 | * __le32 val1; | ||
107 | * #define IWL_name_POS 8 | ||
108 | * #define IWL_name_LEN 4 | ||
109 | * #define IWL_name_SYM val1 | ||
110 | * }; | ||
111 | * | ||
112 | * The IWL_SET_BITS and IWL_GET_BITS macros are provided to allow the driver | ||
113 | * to call: | ||
114 | * | ||
115 | * struct example bar; | ||
116 | * u32 val = IWL_GET_BITS(bar, name); | ||
117 | * val = val * 2; | ||
118 | * IWL_SET_BITS(bar, name, val); | ||
119 | * | ||
120 | * All cpu / host ordering, masking, and shifts are performed by the macros | ||
121 | * and iwl_{get,set}_bits. | ||
122 | * | ||
123 | */ | ||
124 | #define IWL_SET_BITS(s, sym, v) \ | ||
125 | iwl_set_bits(&(s).IWL_ ## sym ## _SYM, IWL_ ## sym ## _POS, \ | ||
126 | IWL_ ## sym ## _LEN, (v)) | ||
127 | |||
128 | #define IWL_SET_BITS16(s, sym, v) \ | ||
129 | iwl_set_bits16(&(s).IWL_ ## sym ## _SYM, IWL_ ## sym ## _POS, \ | ||
130 | IWL_ ## sym ## _LEN, (v)) | ||
131 | |||
132 | #define IWL_GET_BITS(s, sym) \ | ||
133 | iwl_get_bits((s).IWL_ ## sym ## _SYM, IWL_ ## sym ## _POS, \ | ||
134 | IWL_ ## sym ## _LEN) | ||
135 | |||
136 | |||
137 | #define KELVIN_TO_CELSIUS(x) ((x)-273) | 35 | #define KELVIN_TO_CELSIUS(x) ((x)-273) |
138 | #define CELSIUS_TO_KELVIN(x) ((x)+273) | 36 | #define CELSIUS_TO_KELVIN(x) ((x)+273) |
139 | #define IWL_MASK(lo, hi) ((1 << (hi)) | ((1 << (hi)) - (1 << (lo)))) | 37 | #define IWL_MASK(lo, hi) ((1 << (hi)) | ((1 << (hi)) - (1 << (lo)))) |