diff options
author | Daniel Halperin <dhalperi@cs.washington.edu> | 2011-03-18 21:48:55 -0400 |
---|---|---|
committer | Wey-Yi Guy <wey-yi.w.guy@intel.com> | 2011-03-25 09:58:06 -0400 |
commit | 2520546aecc969372080448a2422b39eedb2a528 (patch) | |
tree | da1c3a8a13dc507e916ddb5351aacd2cb552a054 /drivers/net/wireless/iwlwifi | |
parent | d0eb633431ec922f8f9b2040f46d9b42a4cec193 (diff) |
iwlwifi: add RATE_MCS_RATE_MSK
Throughout the code we use rate_n_flags & 0xff to extract the lower byte
of the rate_n_flags u32 that contains the information about the rate.
Add a #define and remove the use of the magic number.
Signed-off-by: Daniel Halperin <dhalperi@cs.washington.edu>
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Diffstat (limited to 'drivers/net/wireless/iwlwifi')
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-agn-rs.c | 15 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-agn.h | 2 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-commands.h | 2 |
3 files changed, 11 insertions, 8 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c index 63b58ecb0dc6..e394e49228ba 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c | |||
@@ -115,13 +115,18 @@ const struct iwl_rate_info iwl_rates[IWL_RATE_COUNT] = { | |||
115 | /* FIXME:RS: ^^ should be INV (legacy) */ | 115 | /* FIXME:RS: ^^ should be INV (legacy) */ |
116 | }; | 116 | }; |
117 | 117 | ||
118 | static inline u8 rs_extract_rate(u32 rate_n_flags) | ||
119 | { | ||
120 | return (u8)(rate_n_flags & RATE_MCS_RATE_MSK); | ||
121 | } | ||
122 | |||
118 | static int iwl_hwrate_to_plcp_idx(u32 rate_n_flags) | 123 | static int iwl_hwrate_to_plcp_idx(u32 rate_n_flags) |
119 | { | 124 | { |
120 | int idx = 0; | 125 | int idx = 0; |
121 | 126 | ||
122 | /* HT rate format */ | 127 | /* HT rate format */ |
123 | if (rate_n_flags & RATE_MCS_HT_MSK) { | 128 | if (rate_n_flags & RATE_MCS_HT_MSK) { |
124 | idx = (rate_n_flags & 0xff); | 129 | idx = rs_extract_rate(rate_n_flags); |
125 | 130 | ||
126 | if (idx >= IWL_RATE_MIMO3_6M_PLCP) | 131 | if (idx >= IWL_RATE_MIMO3_6M_PLCP) |
127 | idx = idx - IWL_RATE_MIMO3_6M_PLCP; | 132 | idx = idx - IWL_RATE_MIMO3_6M_PLCP; |
@@ -138,7 +143,8 @@ static int iwl_hwrate_to_plcp_idx(u32 rate_n_flags) | |||
138 | /* legacy rate format, search for match in table */ | 143 | /* legacy rate format, search for match in table */ |
139 | } else { | 144 | } else { |
140 | for (idx = 0; idx < ARRAY_SIZE(iwl_rates); idx++) | 145 | for (idx = 0; idx < ARRAY_SIZE(iwl_rates); idx++) |
141 | if (iwl_rates[idx].plcp == (rate_n_flags & 0xFF)) | 146 | if (iwl_rates[idx].plcp == |
147 | rs_extract_rate(rate_n_flags)) | ||
142 | return idx; | 148 | return idx; |
143 | } | 149 | } |
144 | 150 | ||
@@ -239,11 +245,6 @@ static const struct iwl_rate_mcs_info iwl_rate_mcs[IWL_RATE_COUNT] = { | |||
239 | 245 | ||
240 | #define MCS_INDEX_PER_STREAM (8) | 246 | #define MCS_INDEX_PER_STREAM (8) |
241 | 247 | ||
242 | static inline u8 rs_extract_rate(u32 rate_n_flags) | ||
243 | { | ||
244 | return (u8)(rate_n_flags & 0xFF); | ||
245 | } | ||
246 | |||
247 | static void rs_rate_scale_clear_window(struct iwl_rate_scale_data *window) | 248 | static void rs_rate_scale_clear_window(struct iwl_rate_scale_data *window) |
248 | { | 249 | { |
249 | window->data = 0; | 250 | window->data = 0; |
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.h b/drivers/net/wireless/iwlwifi/iwl-agn.h index 4f7c9ce9d8bd..39313acb9cc7 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.h +++ b/drivers/net/wireless/iwlwifi/iwl-agn.h | |||
@@ -310,7 +310,7 @@ static inline u32 iwl_ant_idx_to_flags(u8 ant_idx) | |||
310 | 310 | ||
311 | static inline u8 iwl_hw_get_rate(__le32 rate_n_flags) | 311 | static inline u8 iwl_hw_get_rate(__le32 rate_n_flags) |
312 | { | 312 | { |
313 | return le32_to_cpu(rate_n_flags) & 0xFF; | 313 | return le32_to_cpu(rate_n_flags) & RATE_MCS_RATE_MSK; |
314 | } | 314 | } |
315 | 315 | ||
316 | static inline __le32 iwl_hw_set_rate_n_flags(u8 rate, u32 flags) | 316 | static inline __le32 iwl_hw_set_rate_n_flags(u8 rate, u32 flags) |
diff --git a/drivers/net/wireless/iwlwifi/iwl-commands.h b/drivers/net/wireless/iwlwifi/iwl-commands.h index ca42ffa63ed7..288391558afd 100644 --- a/drivers/net/wireless/iwlwifi/iwl-commands.h +++ b/drivers/net/wireless/iwlwifi/iwl-commands.h | |||
@@ -324,6 +324,8 @@ struct iwl3945_power_per_rate { | |||
324 | #define RATE_MCS_SPATIAL_MSK 0x18 | 324 | #define RATE_MCS_SPATIAL_MSK 0x18 |
325 | #define RATE_MCS_HT_DUP_POS 5 | 325 | #define RATE_MCS_HT_DUP_POS 5 |
326 | #define RATE_MCS_HT_DUP_MSK 0x20 | 326 | #define RATE_MCS_HT_DUP_MSK 0x20 |
327 | /* Both legacy and HT use bits 7:0 as the CCK/OFDM rate or HT MCS */ | ||
328 | #define RATE_MCS_RATE_MSK 0xff | ||
327 | 329 | ||
328 | /* Bit 8: (1) HT format, (0) legacy format in bits 7:0 */ | 330 | /* Bit 8: (1) HT format, (0) legacy format in bits 7:0 */ |
329 | #define RATE_MCS_FLAGS_POS 8 | 331 | #define RATE_MCS_FLAGS_POS 8 |