]> Pileus Git - ~andy/linux/commitdiff
iwlwifi: add RATE_MCS_RATE_MSK
authorDaniel Halperin <dhalperi@cs.washington.edu>
Sat, 19 Mar 2011 01:48:55 +0000 (18:48 -0700)
committerWey-Yi Guy <wey-yi.w.guy@intel.com>
Fri, 25 Mar 2011 13:58:06 +0000 (06:58 -0700)
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>
drivers/net/wireless/iwlwifi/iwl-agn-rs.c
drivers/net/wireless/iwlwifi/iwl-agn.h
drivers/net/wireless/iwlwifi/iwl-commands.h

index 63b58ecb0dc61b036add8b403badd2ef73e31f1b..e394e49228ba0dacbae9d353f63547310283783f 100644 (file)
@@ -115,13 +115,18 @@ const struct iwl_rate_info iwl_rates[IWL_RATE_COUNT] = {
        /* FIXME:RS:          ^^    should be INV (legacy) */
 };
 
+static inline u8 rs_extract_rate(u32 rate_n_flags)
+{
+       return (u8)(rate_n_flags & RATE_MCS_RATE_MSK);
+}
+
 static int iwl_hwrate_to_plcp_idx(u32 rate_n_flags)
 {
        int idx = 0;
 
        /* HT rate format */
        if (rate_n_flags & RATE_MCS_HT_MSK) {
-               idx = (rate_n_flags & 0xff);
+               idx = rs_extract_rate(rate_n_flags);
 
                if (idx >= IWL_RATE_MIMO3_6M_PLCP)
                        idx = idx - IWL_RATE_MIMO3_6M_PLCP;
@@ -138,7 +143,8 @@ static int iwl_hwrate_to_plcp_idx(u32 rate_n_flags)
        /* legacy rate format, search for match in table */
        } else {
                for (idx = 0; idx < ARRAY_SIZE(iwl_rates); idx++)
-                       if (iwl_rates[idx].plcp == (rate_n_flags & 0xFF))
+                       if (iwl_rates[idx].plcp ==
+                                       rs_extract_rate(rate_n_flags))
                                return idx;
        }
 
@@ -239,11 +245,6 @@ static const struct iwl_rate_mcs_info iwl_rate_mcs[IWL_RATE_COUNT] = {
 
 #define MCS_INDEX_PER_STREAM   (8)
 
-static inline u8 rs_extract_rate(u32 rate_n_flags)
-{
-       return (u8)(rate_n_flags & 0xFF);
-}
-
 static void rs_rate_scale_clear_window(struct iwl_rate_scale_data *window)
 {
        window->data = 0;
index 4f7c9ce9d8bdeacd1bad3bb50ed7bc8ebb95f4d6..39313acb9cc79cc74a5a5f3d9ce00e32c457d161 100644 (file)
@@ -310,7 +310,7 @@ static inline u32 iwl_ant_idx_to_flags(u8 ant_idx)
 
 static inline u8 iwl_hw_get_rate(__le32 rate_n_flags)
 {
-       return le32_to_cpu(rate_n_flags) & 0xFF;
+       return le32_to_cpu(rate_n_flags) & RATE_MCS_RATE_MSK;
 }
 
 static inline __le32 iwl_hw_set_rate_n_flags(u8 rate, u32 flags)
index ca42ffa63ed73865596325dc2f3157964efda6e2..288391558afdd6d64938c4143671a2fbbb9fea95 100644 (file)
@@ -324,6 +324,8 @@ struct iwl3945_power_per_rate {
 #define RATE_MCS_SPATIAL_MSK 0x18
 #define RATE_MCS_HT_DUP_POS 5
 #define RATE_MCS_HT_DUP_MSK 0x20
+/* Both legacy and HT use bits 7:0 as the CCK/OFDM rate or HT MCS */
+#define RATE_MCS_RATE_MSK 0xff
 
 /* Bit 8: (1) HT format, (0) legacy format in bits 7:0 */
 #define RATE_MCS_FLAGS_POS 8