summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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);