aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/net/wireless/wl12xx/wl1271_boot.c8
-rw-r--r--drivers/net/wireless/wl12xx/wl1271_main.c36
2 files changed, 27 insertions, 17 deletions
diff --git a/drivers/net/wireless/wl12xx/wl1271_boot.c b/drivers/net/wireless/wl12xx/wl1271_boot.c
index bc3fe0275cac..57ba78d83e87 100644
--- a/drivers/net/wireless/wl12xx/wl1271_boot.c
+++ b/drivers/net/wireless/wl12xx/wl1271_boot.c
@@ -228,14 +228,6 @@ static int wl1271_boot_upload_nvs(struct wl1271 *wl)
228 nvs_len = sizeof(wl->nvs->nvs); 228 nvs_len = sizeof(wl->nvs->nvs);
229 nvs_ptr = (u8 *)wl->nvs->nvs; 229 nvs_ptr = (u8 *)wl->nvs->nvs;
230 230
231 /* Update the device MAC address into the nvs */
232 nvs_ptr[11] = wl->mac_addr[0];
233 nvs_ptr[10] = wl->mac_addr[1];
234 nvs_ptr[6] = wl->mac_addr[2];
235 nvs_ptr[5] = wl->mac_addr[3];
236 nvs_ptr[4] = wl->mac_addr[4];
237 nvs_ptr[3] = wl->mac_addr[5];
238
239 /* 231 /*
240 * Layout before the actual NVS tables: 232 * Layout before the actual NVS tables:
241 * 1 byte : burst length. 233 * 1 byte : burst length.
diff --git a/drivers/net/wireless/wl12xx/wl1271_main.c b/drivers/net/wireless/wl12xx/wl1271_main.c
index 282c2bbfec86..b5d53a3fcc5d 100644
--- a/drivers/net/wireless/wl12xx/wl1271_main.c
+++ b/drivers/net/wireless/wl12xx/wl1271_main.c
@@ -467,6 +467,32 @@ out:
467 return ret; 467 return ret;
468} 468}
469 469
470static int wl1271_update_mac_addr(struct wl1271 *wl)
471{
472 int ret = 0;
473 u8 *nvs_ptr = (u8 *)wl->nvs->nvs;
474
475 /* get mac address from the NVS */
476 wl->mac_addr[0] = nvs_ptr[11];
477 wl->mac_addr[1] = nvs_ptr[10];
478 wl->mac_addr[2] = nvs_ptr[6];
479 wl->mac_addr[3] = nvs_ptr[5];
480 wl->mac_addr[4] = nvs_ptr[4];
481 wl->mac_addr[5] = nvs_ptr[3];
482
483 /* FIXME: if it is a zero-address, we should bail out. Now, instead,
484 we randomize an address */
485 if (is_zero_ether_addr(wl->mac_addr)) {
486 static const u8 nokia_oui[3] = {0x00, 0x1f, 0xdf};
487 memcpy(wl->mac_addr, nokia_oui, 3);
488 get_random_bytes(wl->mac_addr + 3, 3);
489 }
490
491 SET_IEEE80211_PERM_ADDR(wl->hw, wl->mac_addr);
492
493 return ret;
494}
495
470static int wl1271_fetch_nvs(struct wl1271 *wl) 496static int wl1271_fetch_nvs(struct wl1271 *wl)
471{ 497{
472 const struct firmware *fw; 498 const struct firmware *fw;
@@ -496,7 +522,7 @@ static int wl1271_fetch_nvs(struct wl1271 *wl)
496 522
497 memcpy(wl->nvs, fw->data, sizeof(struct wl1271_nvs_file)); 523 memcpy(wl->nvs, fw->data, sizeof(struct wl1271_nvs_file));
498 524
499 ret = 0; 525 ret = wl1271_update_mac_addr(wl);
500 526
501out: 527out:
502 release_firmware(fw); 528 release_firmware(fw);
@@ -1893,7 +1919,6 @@ static int __devinit wl1271_probe(struct spi_device *spi)
1893 struct ieee80211_hw *hw; 1919 struct ieee80211_hw *hw;
1894 struct wl1271 *wl; 1920 struct wl1271 *wl;
1895 int ret, i; 1921 int ret, i;
1896 static const u8 nokia_oui[3] = {0x00, 0x1f, 0xdf};
1897 1922
1898 pdata = spi->dev.platform_data; 1923 pdata = spi->dev.platform_data;
1899 if (!pdata) { 1924 if (!pdata) {
@@ -1938,13 +1963,6 @@ static int __devinit wl1271_probe(struct spi_device *spi)
1938 1963
1939 spin_lock_init(&wl->wl_lock); 1964 spin_lock_init(&wl->wl_lock);
1940 1965
1941 /*
1942 * In case our MAC address is not correctly set,
1943 * we use a random but Nokia MAC.
1944 */
1945 memcpy(wl->mac_addr, nokia_oui, 3);
1946 get_random_bytes(wl->mac_addr + 3, 3);
1947
1948 wl->state = WL1271_STATE_OFF; 1966 wl->state = WL1271_STATE_OFF;
1949 mutex_init(&wl->mutex); 1967 mutex_init(&wl->mutex);
1950 1968