summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTroy Kisky <troy.kisky@boundarydevices.com>2012-05-23 18:38:54 -0700
committerIan Wisbon <ian.wisbon@timesys.com>2012-09-14 12:07:55 -0400
commite4844b81744401230d805b04a2a4aba4a4ff9469 (patch)
treea574a115ea4c33531f6fdcb443be7ac38a5b0b45
parentfe089418f6e2090ad4604f119d1e9c4672d51f38 (diff)
wl12xx: add mac override parameter3.0-boundary-imx6-201209141212
Note the cmdline parameter would be wl12xx.mac=nn:nn:nn:nn:nn:nn Signed-off-by: Troy Kisky <troy.kisky@boundarydevices.com>
-rw-r--r--drivers/net/wireless/wl12xx/main.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c
index ae9cae20dfec..f1ffec0b3bb6 100644
--- a/drivers/net/wireless/wl12xx/main.c
+++ b/drivers/net/wireless/wl12xx/main.c
@@ -3783,9 +3783,39 @@ static ssize_t wl1271_sysfs_show_hw_pg_ver(struct device *dev,
static DEVICE_ATTR(hw_pg_ver, S_IRUGO | S_IWUSR,
wl1271_sysfs_show_hw_pg_ver, NULL);
+
+static int parse_mac(unsigned char *mac, unsigned char const *str_mac)
+{
+ int i = 0;
+ char *end;
+ int ret = -EINVAL;
+
+ for (;;) {
+ mac[i++] = simple_strtoul(str_mac, &end, 16);
+ if (i == 6) {
+ if (!*end || (*end == ' '))
+ ret = 0;
+ break;
+ }
+ str_mac = end + 1;
+ if ((*end != '-') && (*end != ':'))
+ break;
+ }
+ return ret;
+}
+
+static char *mac;
+module_param(mac, charp, S_IRUGO);
+MODULE_PARM_DESC(mac, "mac address override");
+
int wl1271_register_hw(struct wl1271 *wl)
{
int ret;
+ u8 override_mac[ETH_ALEN];
+ memset(override_mac, 0, ETH_ALEN);
+ if (mac)
+ if (parse_mac(override_mac, mac))
+ memset(override_mac, 0, ETH_ALEN);
if (wl->mac80211_registered)
return 0;
@@ -3806,6 +3836,9 @@ int wl1271_register_hw(struct wl1271 *wl)
wl->mac_addr[5] = nvs_ptr[3];
}
+ if (is_valid_ether_addr(override_mac))
+ memcpy(wl->mac_addr, override_mac, sizeof(wl->mac_addr));
+
SET_IEEE80211_PERM_ADDR(wl->hw, wl->mac_addr);
ret = ieee80211_register_hw(wl->hw);