aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/rt2x00/rt2x00config.c
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/rt2x00/rt2x00config.c
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/rt2x00/rt2x00config.c')
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00config.c32
1 files changed, 30 insertions, 2 deletions
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)