aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuis R. Rodriguez <lrodriguez@atheros.com>2009-09-10 01:43:17 -0400
committerJohn W. Linville <linville@tuxdriver.com>2009-10-07 16:39:25 -0400
commitbcd8f54a84ce99ade91c250a9bc850a9fd3389c1 (patch)
treeb17a29b781c0ea56f567d18f45e2d0cdc29bada2
parent17753748e15eaf29c8db15c5c05b8dde5db6e64d (diff)
atheros: use get_unaligned_le*() for bssid mask setting
Historically some macro helpers have been users for this, AR5K_LOW_ID() and AR5K_HIGH_ID(), use upstream unaligned helpers instead. This applid to ath5k and ar9170. ath9k already uses this. Worth noting is ath5k uses an ah_sta_id but that is already the MAC address combined with the associaiton ID, ah_sta_id is really ETH_ALEN in size. Cc: Bob Copeland <me@bobcopeland.com> Cc: Nick Kossifidis <mick@madwifi-project.org> Cc: Christian Lamparter <chunkeey@web.de> Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r--drivers/net/wireless/ath/ar9170/mac.c10
-rw-r--r--drivers/net/wireless/ath/ath.h1
-rw-r--r--drivers/net/wireless/ath/ath5k/ath5k.h7
-rw-r--r--drivers/net/wireless/ath/ath5k/pcu.c36
-rw-r--r--drivers/net/wireless/ath/ath5k/reset.c6
5 files changed, 31 insertions, 29 deletions
diff --git a/drivers/net/wireless/ath/ar9170/mac.c b/drivers/net/wireless/ath/ar9170/mac.c
index 614e3218a2bc..0c6273a63d6b 100644
--- a/drivers/net/wireless/ath/ar9170/mac.c
+++ b/drivers/net/wireless/ath/ar9170/mac.c
@@ -35,6 +35,9 @@
35 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 35 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
36 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 36 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
37 */ 37 */
38
39#include <asm/unaligned.h>
40
38#include "ar9170.h" 41#include "ar9170.h"
39#include "cmd.h" 42#include "cmd.h"
40 43
@@ -227,11 +230,8 @@ static int ar9170_set_mac_reg(struct ar9170 *ar, const u32 reg, const u8 *mac)
227 230
228 ar9170_regwrite_begin(ar); 231 ar9170_regwrite_begin(ar);
229 232
230 ar9170_regwrite(reg, 233 ar9170_regwrite(reg, get_unaligned_le32(mac));
231 (mac[3] << 24) | (mac[2] << 16) | 234 ar9170_regwrite(reg + 4, get_unaligned_le16(mac + 4));
232 (mac[1] << 8) | mac[0]);
233
234 ar9170_regwrite(reg + 4, (mac[5] << 8) | mac[4]);
235 235
236 ar9170_regwrite_finish(); 236 ar9170_regwrite_finish();
237 237
diff --git a/drivers/net/wireless/ath/ath.h b/drivers/net/wireless/ath/ath.h
index 59072e3820d0..44f885a37c11 100644
--- a/drivers/net/wireless/ath/ath.h
+++ b/drivers/net/wireless/ath/ath.h
@@ -18,6 +18,7 @@
18#define ATH_H 18#define ATH_H
19 19
20#include <linux/skbuff.h> 20#include <linux/skbuff.h>
21#include <linux/if_ether.h>
21 22
22static const u8 ath_bcast_mac[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; 23static const u8 ath_bcast_mac[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
23 24
diff --git a/drivers/net/wireless/ath/ath5k/ath5k.h b/drivers/net/wireless/ath/ath5k/ath5k.h
index 6cd5efcec417..93a9c1f93f69 100644
--- a/drivers/net/wireless/ath/ath5k/ath5k.h
+++ b/drivers/net/wireless/ath/ath5k/ath5k.h
@@ -165,13 +165,6 @@
165#define AR5K_INI_VAL_XR 0 165#define AR5K_INI_VAL_XR 0
166#define AR5K_INI_VAL_MAX 5 166#define AR5K_INI_VAL_MAX 5
167 167
168/* Used for BSSID etc manipulation */
169#define AR5K_LOW_ID(_a)( \
170(_a)[0] | (_a)[1] << 8 | (_a)[2] << 16 | (_a)[3] << 24 \
171)
172
173#define AR5K_HIGH_ID(_a) ((_a)[4] | (_a)[5] << 8)
174
175/* 168/*
176 * Some tuneable values (these should be changeable by the user) 169 * Some tuneable values (these should be changeable by the user)
177 * TODO: Make use of them and add more options OR use debug/configfs 170 * TODO: Make use of them and add more options OR use debug/configfs
diff --git a/drivers/net/wireless/ath/ath5k/pcu.c b/drivers/net/wireless/ath/ath5k/pcu.c
index 43aa35806618..7bbcfe4fe34b 100644
--- a/drivers/net/wireless/ath/ath5k/pcu.c
+++ b/drivers/net/wireless/ath/ath5k/pcu.c
@@ -24,6 +24,8 @@
24* Protocol Control Unit Functions * 24* Protocol Control Unit Functions *
25\*********************************/ 25\*********************************/
26 26
27#include <asm/unaligned.h>
28
27#include "ath5k.h" 29#include "ath5k.h"
28#include "reg.h" 30#include "reg.h"
29#include "debug.h" 31#include "debug.h"
@@ -95,8 +97,8 @@ int ath5k_hw_set_opmode(struct ath5k_hw *ah)
95 /* 97 /*
96 * Set PCU registers 98 * Set PCU registers
97 */ 99 */
98 low_id = AR5K_LOW_ID(ah->ah_sta_id); 100 low_id = get_unaligned_le32(ah->ah_sta_id);
99 high_id = AR5K_HIGH_ID(ah->ah_sta_id); 101 high_id = get_unaligned_le16(ah->ah_sta_id + 4);
100 ath5k_hw_reg_write(ah, low_id, AR5K_STA_ID0); 102 ath5k_hw_reg_write(ah, low_id, AR5K_STA_ID0);
101 ath5k_hw_reg_write(ah, pcu_reg | high_id, AR5K_STA_ID1); 103 ath5k_hw_reg_write(ah, pcu_reg | high_id, AR5K_STA_ID1);
102 104
@@ -279,8 +281,8 @@ int ath5k_hw_set_lladdr(struct ath5k_hw *ah, const u8 *mac)
279 281
280 pcu_reg = ath5k_hw_reg_read(ah, AR5K_STA_ID1) & 0xffff0000; 282 pcu_reg = ath5k_hw_reg_read(ah, AR5K_STA_ID1) & 0xffff0000;
281 283
282 low_id = AR5K_LOW_ID(mac); 284 low_id = get_unaligned_le32(mac);
283 high_id = AR5K_HIGH_ID(mac); 285 high_id = get_unaligned_le16(mac + 4);
284 286
285 ath5k_hw_reg_write(ah, low_id, AR5K_STA_ID0); 287 ath5k_hw_reg_write(ah, low_id, AR5K_STA_ID0);
286 ath5k_hw_reg_write(ah, pcu_reg | high_id, AR5K_STA_ID1); 288 ath5k_hw_reg_write(ah, pcu_reg | high_id, AR5K_STA_ID1);
@@ -306,17 +308,18 @@ void ath5k_hw_set_associd(struct ath5k_hw *ah, const u8 *bssid, u16 assoc_id)
306 * Set simple BSSID mask on 5212 308 * Set simple BSSID mask on 5212
307 */ 309 */
308 if (ah->ah_version == AR5K_AR5212) { 310 if (ah->ah_version == AR5K_AR5212) {
309 ath5k_hw_reg_write(ah, AR5K_LOW_ID(ah->ah_bssid_mask), 311 ath5k_hw_reg_write(ah, get_unaligned_le32(ah->ah_bssid_mask),
310 AR5K_BSS_IDM0); 312 AR5K_BSS_IDM0);
311 ath5k_hw_reg_write(ah, AR5K_HIGH_ID(ah->ah_bssid_mask), 313 ath5k_hw_reg_write(ah,
312 AR5K_BSS_IDM1); 314 get_unaligned_le16(ah->ah_bssid_mask + 4),
315 AR5K_BSS_IDM1);
313 } 316 }
314 317
315 /* 318 /*
316 * Set BSSID which triggers the "SME Join" operation 319 * Set BSSID which triggers the "SME Join" operation
317 */ 320 */
318 low_id = AR5K_LOW_ID(bssid); 321 low_id = get_unaligned_le32(bssid);
319 high_id = AR5K_HIGH_ID(bssid); 322 high_id = get_unaligned_le16(bssid);
320 ath5k_hw_reg_write(ah, low_id, AR5K_BSS_ID0); 323 ath5k_hw_reg_write(ah, low_id, AR5K_BSS_ID0);
321 ath5k_hw_reg_write(ah, high_id | ((assoc_id & 0x3fff) << 324 ath5k_hw_reg_write(ah, high_id | ((assoc_id & 0x3fff) <<
322 AR5K_BSS_ID1_AID_S), AR5K_BSS_ID1); 325 AR5K_BSS_ID1_AID_S), AR5K_BSS_ID1);
@@ -437,8 +440,8 @@ int ath5k_hw_set_bssid_mask(struct ath5k_hw *ah, const u8 *mask)
437 * on reset */ 440 * on reset */
438 memcpy(ah->ah_bssid_mask, mask, ETH_ALEN); 441 memcpy(ah->ah_bssid_mask, mask, ETH_ALEN);
439 if (ah->ah_version == AR5K_AR5212) { 442 if (ah->ah_version == AR5K_AR5212) {
440 low_id = AR5K_LOW_ID(mask); 443 low_id = get_unaligned_le32(mask);
441 high_id = AR5K_HIGH_ID(mask); 444 high_id = get_unaligned_le16(mask + 4);
442 445
443 ath5k_hw_reg_write(ah, low_id, AR5K_BSS_IDM0); 446 ath5k_hw_reg_write(ah, low_id, AR5K_BSS_IDM0);
444 ath5k_hw_reg_write(ah, high_id, AR5K_BSS_IDM1); 447 ath5k_hw_reg_write(ah, high_id, AR5K_BSS_IDM1);
@@ -1157,14 +1160,17 @@ int ath5k_hw_set_key_lladdr(struct ath5k_hw *ah, u16 entry, const u8 *mac)
1157 /* Invalid entry (key table overflow) */ 1160 /* Invalid entry (key table overflow) */
1158 AR5K_ASSERT_ENTRY(entry, AR5K_KEYTABLE_SIZE); 1161 AR5K_ASSERT_ENTRY(entry, AR5K_KEYTABLE_SIZE);
1159 1162
1160 /* MAC may be NULL if it's a broadcast key. In this case no need to 1163 /*
1161 * to compute AR5K_LOW_ID and AR5K_HIGH_ID as we already know it. */ 1164 * MAC may be NULL if it's a broadcast key. In this case no need to
1165 * to compute get_unaligned_le32 and get_unaligned_le16 as we
1166 * already know it.
1167 */
1162 if (!mac) { 1168 if (!mac) {
1163 low_id = 0xffffffff; 1169 low_id = 0xffffffff;
1164 high_id = 0xffff | AR5K_KEYTABLE_VALID; 1170 high_id = 0xffff | AR5K_KEYTABLE_VALID;
1165 } else { 1171 } else {
1166 low_id = AR5K_LOW_ID(mac); 1172 low_id = get_unaligned_le32(mac);
1167 high_id = AR5K_HIGH_ID(mac) | AR5K_KEYTABLE_VALID; 1173 high_id = get_unaligned_le16(mac + 4) | AR5K_KEYTABLE_VALID;
1168 } 1174 }
1169 1175
1170 ath5k_hw_reg_write(ah, low_id, AR5K_KEYTABLE_MAC0(entry)); 1176 ath5k_hw_reg_write(ah, low_id, AR5K_KEYTABLE_MAC0(entry));
diff --git a/drivers/net/wireless/ath/ath5k/reset.c b/drivers/net/wireless/ath/ath5k/reset.c
index 34e13c700849..3454dacc2af8 100644
--- a/drivers/net/wireless/ath/ath5k/reset.c
+++ b/drivers/net/wireless/ath/ath5k/reset.c
@@ -25,6 +25,8 @@
25 Reset functions and helpers 25 Reset functions and helpers
26\*****************************/ 26\*****************************/
27 27
28#include <asm/unaligned.h>
29
28#include <linux/pci.h> /* To determine if a card is pci-e */ 30#include <linux/pci.h> /* To determine if a card is pci-e */
29#include <linux/log2.h> 31#include <linux/log2.h>
30#include "ath5k.h" 32#include "ath5k.h"
@@ -1171,9 +1173,9 @@ int ath5k_hw_reset(struct ath5k_hw *ah, enum nl80211_iftype op_mode,
1171 ath5k_hw_reg_write(ah, s_led[2], AR5K_GPIODO); 1173 ath5k_hw_reg_write(ah, s_led[2], AR5K_GPIODO);
1172 1174
1173 /* Restore sta_id flags and preserve our mac address*/ 1175 /* Restore sta_id flags and preserve our mac address*/
1174 ath5k_hw_reg_write(ah, AR5K_LOW_ID(ah->ah_sta_id), 1176 ath5k_hw_reg_write(ah, get_unaligned_le32(ah->ah_sta_id),
1175 AR5K_STA_ID0); 1177 AR5K_STA_ID0);
1176 ath5k_hw_reg_write(ah, staid1_flags | AR5K_HIGH_ID(ah->ah_sta_id), 1178 ath5k_hw_reg_write(ah, staid1_flags | get_unaligned_le16(ah->ah_sta_id),
1177 AR5K_STA_ID1); 1179 AR5K_STA_ID1);
1178 1180
1179 1181