aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless
diff options
context:
space:
mode:
authorIvo van Doorn <ivdoorn@gmail.com>2007-10-06 08:11:46 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-10-10 19:55:08 -0400
commit4abee4bbd771ce42b9a0a19be11264721aa0e3ed (patch)
tree238f6f7a411c69062aa5d1287409769068b0783d /drivers/net/wireless
parentc109810318ef4d37e495f740e624b1a15b7a0818 (diff)
[PATCH] rt2x00: Remove duplicate code in MAC & BSSID handling
The various drivers contained duplicate code to handle the MAC and BSSID initialization correctly. This moves the address copy to little endian variables to rt2x00config. Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless')
-rw-r--r--drivers/net/wireless/rt2x00/rt2400pci.c30
-rw-r--r--drivers/net/wireless/rt2x00/rt2500pci.c30
-rw-r--r--drivers/net/wireless/rt2x00/rt2500usb.c30
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00.h4
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00config.c32
-rw-r--r--drivers/net/wireless/rt2x00/rt61pci.c34
-rw-r--r--drivers/net/wireless/rt2x00/rt73usb.c34
7 files changed, 76 insertions, 118 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2400pci.c b/drivers/net/wireless/rt2x00/rt2400pci.c
index faa47111a579..7b2a85ade135 100644
--- a/drivers/net/wireless/rt2x00/rt2400pci.c
+++ b/drivers/net/wireless/rt2x00/rt2400pci.c
@@ -249,32 +249,18 @@ static int rt2400pci_rfkill_poll(struct rt2x00_dev *rt2x00dev)
249/* 249/*
250 * Configuration handlers. 250 * Configuration handlers.
251 */ 251 */
252static void rt2400pci_config_mac_addr(struct rt2x00_dev *rt2x00dev, u8 *addr) 252static void rt2400pci_config_mac_addr(struct rt2x00_dev *rt2x00dev,
253 __le32 *mac)
253{ 254{
254 __le32 reg[2]; 255 rt2x00pci_register_multiwrite(rt2x00dev, CSR3, mac,
255 256 (2 * sizeof(__le32)));
256 memset(&reg, 0, sizeof(reg));
257 memcpy(&reg, addr, ETH_ALEN);
258
259 /*
260 * The MAC address is passed to us as an array of bytes,
261 * that array is little endian, so no need for byte ordering.
262 */
263 rt2x00pci_register_multiwrite(rt2x00dev, CSR3, &reg, sizeof(reg));
264} 257}
265 258
266static void rt2400pci_config_bssid(struct rt2x00_dev *rt2x00dev, u8 *bssid) 259static void rt2400pci_config_bssid(struct rt2x00_dev *rt2x00dev,
260 __le32 *bssid)
267{ 261{
268 __le32 reg[2]; 262 rt2x00pci_register_multiwrite(rt2x00dev, CSR5, bssid,
269 263 (2 * sizeof(__le32)));
270 memset(&reg, 0, sizeof(reg));
271 memcpy(&reg, bssid, ETH_ALEN);
272
273 /*
274 * The BSSID is passed to us as an array of bytes,
275 * that array is little endian, so no need for byte ordering.
276 */
277 rt2x00pci_register_multiwrite(rt2x00dev, CSR5, &reg, sizeof(reg));
278} 264}
279 265
280static void rt2400pci_config_type(struct rt2x00_dev *rt2x00dev, int type) 266static void rt2400pci_config_type(struct rt2x00_dev *rt2x00dev, int type)
diff --git a/drivers/net/wireless/rt2x00/rt2500pci.c b/drivers/net/wireless/rt2x00/rt2500pci.c
index 842da900d7c1..63a7b3cdf0cd 100644
--- a/drivers/net/wireless/rt2x00/rt2500pci.c
+++ b/drivers/net/wireless/rt2x00/rt2500pci.c
@@ -249,32 +249,18 @@ static int rt2500pci_rfkill_poll(struct rt2x00_dev *rt2x00dev)
249/* 249/*
250 * Configuration handlers. 250 * Configuration handlers.
251 */ 251 */
252static void rt2500pci_config_mac_addr(struct rt2x00_dev *rt2x00dev, u8 *addr) 252static void rt2500pci_config_mac_addr(struct rt2x00_dev *rt2x00dev,
253 __le32 *mac)
253{ 254{
254 __le32 reg[2]; 255 rt2x00pci_register_multiwrite(rt2x00dev, CSR3, mac,
255 256 (2 * sizeof(__le32)));
256 memset(&reg, 0, sizeof(reg));
257 memcpy(&reg, addr, ETH_ALEN);
258
259 /*
260 * The MAC address is passed to us as an array of bytes,
261 * that array is little endian, so no need for byte ordering.
262 */
263 rt2x00pci_register_multiwrite(rt2x00dev, CSR3, &reg, sizeof(reg));
264} 257}
265 258
266static void rt2500pci_config_bssid(struct rt2x00_dev *rt2x00dev, u8 *bssid) 259static void rt2500pci_config_bssid(struct rt2x00_dev *rt2x00dev,
260 __le32 *bssid)
267{ 261{
268 __le32 reg[2]; 262 rt2x00pci_register_multiwrite(rt2x00dev, CSR5, bssid,
269 263 (2 * sizeof(__le32)));
270 memset(&reg, 0, sizeof(reg));
271 memcpy(&reg, bssid, ETH_ALEN);
272
273 /*
274 * The BSSID is passed to us as an array of bytes,
275 * that array is little endian, so no need for byte ordering.
276 */
277 rt2x00pci_register_multiwrite(rt2x00dev, CSR5, &reg, sizeof(reg));
278} 264}
279 265
280static void rt2500pci_config_type(struct rt2x00_dev *rt2x00dev, const int type) 266static void rt2500pci_config_type(struct rt2x00_dev *rt2x00dev, const int type)
diff --git a/drivers/net/wireless/rt2x00/rt2500usb.c b/drivers/net/wireless/rt2x00/rt2500usb.c
index 7aacc7b5c1b2..973f653ecfc2 100644
--- a/drivers/net/wireless/rt2x00/rt2500usb.c
+++ b/drivers/net/wireless/rt2x00/rt2500usb.c
@@ -254,32 +254,18 @@ static const struct rt2x00debug rt2500usb_rt2x00debug = {
254/* 254/*
255 * Configuration handlers. 255 * Configuration handlers.
256 */ 256 */
257static void rt2500usb_config_mac_addr(struct rt2x00_dev *rt2x00dev, u8 *addr) 257static void rt2500usb_config_mac_addr(struct rt2x00_dev *rt2x00dev,
258 __le32 *mac)
258{ 259{
259 __le16 reg[3]; 260 rt2500usb_register_multiwrite(rt2x00dev, MAC_CSR2, &mac,
260 261 (3 * sizeof(__le16)));
261 memset(&reg, 0, sizeof(reg));
262 memcpy(&reg, addr, ETH_ALEN);
263
264 /*
265 * The MAC address is passed to us as an array of bytes,
266 * that array is little endian, so no need for byte ordering.
267 */
268 rt2500usb_register_multiwrite(rt2x00dev, MAC_CSR2, &reg, sizeof(reg));
269} 262}
270 263
271static void rt2500usb_config_bssid(struct rt2x00_dev *rt2x00dev, u8 *bssid) 264static void rt2500usb_config_bssid(struct rt2x00_dev *rt2x00dev,
265 __le32 *bssid)
272{ 266{
273 __le16 reg[3]; 267 rt2500usb_register_multiwrite(rt2x00dev, MAC_CSR5, bssid,
274 268 (3 * sizeof(__le16)));
275 memset(&reg, 0, sizeof(reg));
276 memcpy(&reg, bssid, ETH_ALEN);
277
278 /*
279 * The BSSID is passed to us as an array of bytes,
280 * that array is little endian, so no need for byte ordering.
281 */
282 rt2500usb_register_multiwrite(rt2x00dev, MAC_CSR5, &reg, sizeof(reg));
283} 269}
284 270
285static void rt2500usb_config_type(struct rt2x00_dev *rt2x00dev, const int type) 271static void rt2500usb_config_type(struct rt2x00_dev *rt2x00dev, const int type)
diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
index 6262d4e47c56..5d30ca6680b6 100644
--- a/drivers/net/wireless/rt2x00/rt2x00.h
+++ b/drivers/net/wireless/rt2x00/rt2x00.h
@@ -408,8 +408,8 @@ struct rt2x00lib_ops {
408 /* 408 /*
409 * Configuration handlers. 409 * Configuration handlers.
410 */ 410 */
411 void (*config_mac_addr) (struct rt2x00_dev *rt2x00dev, u8 *mac); 411 void (*config_mac_addr) (struct rt2x00_dev *rt2x00dev, __le32 *mac);
412 void (*config_bssid) (struct rt2x00_dev *rt2x00dev, u8 *bssid); 412 void (*config_bssid) (struct rt2x00_dev *rt2x00dev, __le32 *bssid);
413 void (*config_packet_filter) (struct rt2x00_dev *rt2x00dev, 413 void (*config_packet_filter) (struct rt2x00_dev *rt2x00dev,
414 const unsigned int filter); 414 const unsigned int filter);
415 void (*config_type) (struct rt2x00_dev *rt2x00dev, const int type); 415 void (*config_type) (struct rt2x00_dev *rt2x00dev, const int type);
diff --git a/drivers/net/wireless/rt2x00/rt2x00config.c b/drivers/net/wireless/rt2x00/rt2x00config.c
index 13b510687bcb..aeeaa0c14245 100644
--- a/drivers/net/wireless/rt2x00/rt2x00config.c
+++ b/drivers/net/wireless/rt2x00/rt2x00config.c
@@ -34,16 +34,44 @@
34#include "rt2x00.h" 34#include "rt2x00.h"
35#include "rt2x00lib.h" 35#include "rt2x00lib.h"
36 36
37
38/*
39 * The MAC and BSSID addressess are simple array of bytes,
40 * these arrays are little endian, so when sending the addressess
41 * to the drivers, copy the it into a endian-signed variable.
42 *
43 * Note that all devices (except rt2500usb) have 32 bits
44 * register word sizes. This means that whatever variable we
45 * pass _must_ be a multiple of 32 bits. Otherwise the device
46 * might not accept what we are sending to it.
47 * This will also make it easier for the driver to write
48 * the data to the device.
49 *
50 * Also note that when NULL is passed as address the
51 * we will send 00:00:00:00:00 to the device to clear the address.
52 * This will prevent the device being confused when it wants
53 * to ACK frames or consideres itself associated.
54 */
37void rt2x00lib_config_mac_addr(struct rt2x00_dev *rt2x00dev, u8 *mac) 55void rt2x00lib_config_mac_addr(struct rt2x00_dev *rt2x00dev, u8 *mac)
38{ 56{
57 __le32 reg[2];
58
59 memset(&reg, 0, sizeof(reg));
39 if (mac) 60 if (mac)
40 rt2x00dev->ops->lib->config_mac_addr(rt2x00dev, mac); 61 memcpy(&reg, mac, ETH_ALEN);
62
63 rt2x00dev->ops->lib->config_mac_addr(rt2x00dev, &reg[0]);
41} 64}
42 65
43void rt2x00lib_config_bssid(struct rt2x00_dev *rt2x00dev, u8 *bssid) 66void rt2x00lib_config_bssid(struct rt2x00_dev *rt2x00dev, u8 *bssid)
44{ 67{
68 __le32 reg[2];
69
70 memset(&reg, 0, sizeof(reg));
45 if (bssid) 71 if (bssid)
46 rt2x00dev->ops->lib->config_bssid(rt2x00dev, bssid); 72 memcpy(&reg, bssid, ETH_ALEN);
73
74 rt2x00dev->ops->lib->config_bssid(rt2x00dev, &reg[0]);
47} 75}
48 76
49void rt2x00lib_config_type(struct rt2x00_dev *rt2x00dev, int type) 77void rt2x00lib_config_type(struct rt2x00_dev *rt2x00dev, int type)
diff --git a/drivers/net/wireless/rt2x00/rt61pci.c b/drivers/net/wireless/rt2x00/rt61pci.c
index 6aa517645b6a..5d31ced11149 100644
--- a/drivers/net/wireless/rt2x00/rt61pci.c
+++ b/drivers/net/wireless/rt2x00/rt61pci.c
@@ -274,42 +274,28 @@ static int rt61pci_rfkill_poll(struct rt2x00_dev *rt2x00dev)
274/* 274/*
275 * Configuration handlers. 275 * Configuration handlers.
276 */ 276 */
277static void rt61pci_config_mac_addr(struct rt2x00_dev *rt2x00dev, u8 *addr) 277static void rt61pci_config_mac_addr(struct rt2x00_dev *rt2x00dev, __le32 *mac)
278{ 278{
279 __le32 reg[2];
280 u32 tmp; 279 u32 tmp;
281 280
282 memset(&reg, 0, sizeof(reg)); 281 tmp = le32_to_cpu(mac[1]);
283 memcpy(&reg, addr, ETH_ALEN);
284
285 tmp = le32_to_cpu(reg[1]);
286 rt2x00_set_field32(&tmp, MAC_CSR3_UNICAST_TO_ME_MASK, 0xff); 282 rt2x00_set_field32(&tmp, MAC_CSR3_UNICAST_TO_ME_MASK, 0xff);
287 reg[1] = cpu_to_le32(tmp); 283 mac[1] = cpu_to_le32(tmp);
288 284
289 /* 285 rt2x00pci_register_multiwrite(rt2x00dev, MAC_CSR2, mac,
290 * The MAC address is passed to us as an array of bytes, 286 (2 * sizeof(__le32)));
291 * that array is little endian, so no need for byte ordering.
292 */
293 rt2x00pci_register_multiwrite(rt2x00dev, MAC_CSR2, &reg, sizeof(reg));
294} 287}
295 288
296static void rt61pci_config_bssid(struct rt2x00_dev *rt2x00dev, u8 *bssid) 289static void rt61pci_config_bssid(struct rt2x00_dev *rt2x00dev, __le32 *bssid)
297{ 290{
298 __le32 reg[2];
299 u32 tmp; 291 u32 tmp;
300 292
301 memset(&reg, 0, sizeof(reg)); 293 tmp = le32_to_cpu(bssid[1]);
302 memcpy(&reg, bssid, ETH_ALEN);
303
304 tmp = le32_to_cpu(reg[1]);
305 rt2x00_set_field32(&tmp, MAC_CSR5_BSS_ID_MASK, 3); 294 rt2x00_set_field32(&tmp, MAC_CSR5_BSS_ID_MASK, 3);
306 reg[1] = cpu_to_le32(tmp); 295 bssid[1] = cpu_to_le32(tmp);
307 296
308 /* 297 rt2x00pci_register_multiwrite(rt2x00dev, MAC_CSR4, bssid,
309 * The BSSID is passed to us as an array of bytes, 298 (2 * sizeof(__le32)));
310 * that array is little endian, so no need for byte ordering.
311 */
312 rt2x00pci_register_multiwrite(rt2x00dev, MAC_CSR4, &reg, sizeof(reg));
313} 299}
314 300
315static void rt61pci_config_type(struct rt2x00_dev *rt2x00dev, const int type) 301static void rt61pci_config_type(struct rt2x00_dev *rt2x00dev, const int type)
diff --git a/drivers/net/wireless/rt2x00/rt73usb.c b/drivers/net/wireless/rt2x00/rt73usb.c
index ffed3ec5fb99..5fa697bfaa14 100644
--- a/drivers/net/wireless/rt2x00/rt73usb.c
+++ b/drivers/net/wireless/rt2x00/rt73usb.c
@@ -255,42 +255,28 @@ static const struct rt2x00debug rt73usb_rt2x00debug = {
255/* 255/*
256 * Configuration handlers. 256 * Configuration handlers.
257 */ 257 */
258static void rt73usb_config_mac_addr(struct rt2x00_dev *rt2x00dev, u8 *addr) 258static void rt73usb_config_mac_addr(struct rt2x00_dev *rt2x00dev, __le32 *mac)
259{ 259{
260 __le32 reg[2];
261 u32 tmp; 260 u32 tmp;
262 261
263 memset(&reg, 0, sizeof(reg)); 262 tmp = le32_to_cpu(mac[1]);
264 memcpy(&reg, addr, ETH_ALEN);
265
266 tmp = le32_to_cpu(reg[1]);
267 rt2x00_set_field32(&tmp, MAC_CSR3_UNICAST_TO_ME_MASK, 0xff); 263 rt2x00_set_field32(&tmp, MAC_CSR3_UNICAST_TO_ME_MASK, 0xff);
268 reg[1] = cpu_to_le32(tmp); 264 mac[1] = cpu_to_le32(tmp);
269 265
270 /* 266 rt73usb_register_multiwrite(rt2x00dev, MAC_CSR2, mac,
271 * The MAC address is passed to us as an array of bytes, 267 (2 * sizeof(__le32)));
272 * that array is little endian, so no need for byte ordering.
273 */
274 rt73usb_register_multiwrite(rt2x00dev, MAC_CSR2, &reg, sizeof(reg));
275} 268}
276 269
277static void rt73usb_config_bssid(struct rt2x00_dev *rt2x00dev, u8 *bssid) 270static void rt73usb_config_bssid(struct rt2x00_dev *rt2x00dev, __le32 *bssid)
278{ 271{
279 __le32 reg[2];
280 u32 tmp; 272 u32 tmp;
281 273
282 memset(&reg, 0, sizeof(reg)); 274 tmp = le32_to_cpu(bssid[1]);
283 memcpy(&reg, bssid, ETH_ALEN);
284
285 tmp = le32_to_cpu(reg[1]);
286 rt2x00_set_field32(&tmp, MAC_CSR5_BSS_ID_MASK, 3); 275 rt2x00_set_field32(&tmp, MAC_CSR5_BSS_ID_MASK, 3);
287 reg[1] = cpu_to_le32(tmp); 276 bssid[1] = cpu_to_le32(tmp);
288 277
289 /* 278 rt73usb_register_multiwrite(rt2x00dev, MAC_CSR4, bssid,
290 * The BSSID is passed to us as an array of bytes, 279 (2 * sizeof(__le32)));
291 * that array is little endian, so no need for byte ordering.
292 */
293 rt73usb_register_multiwrite(rt2x00dev, MAC_CSR4, &reg, sizeof(reg));
294} 280}
295 281
296static void rt73usb_config_type(struct rt2x00_dev *rt2x00dev, const int type) 282static void rt73usb_config_type(struct rt2x00_dev *rt2x00dev, const int type)