summaryrefslogtreecommitdiff
path: root/package/mac80211/patches/407-ath9k-override-mac-address-from-platform-data.patch
blob: 999ced42d63a9f101375d7e18cadd95bdae23060 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
--- a/drivers/net/wireless/ath/ath9k/hw.c
+++ b/drivers/net/wireless/ath/ath9k/hw.c
@@ -17,8 +17,10 @@
 #include <linux/io.h>
 #include <linux/slab.h>
 #include <linux/etherdevice.h>
+#include <linux/ath9k_platform.h>
 #include <asm/unaligned.h>
 
+#include "ath9k.h"
 #include "hw.h"
 #include "hw-ops.h"
 #include "rc.h"
@@ -416,18 +418,23 @@ static void ath9k_hw_init_defaults(struc
 static int ath9k_hw_init_macaddr(struct ath_hw *ah)
 {
 	struct ath_common *common = ath9k_hw_common(ah);
+	struct ath_softc *sc = (struct ath_softc *) common->priv;
+	struct ath9k_platform_data *pdata = sc->dev->platform_data;
 	u32 sum;
 	int i;
 	u16 eeval;
 	u32 EEP_MAC[] = { EEP_MAC_LSW, EEP_MAC_MID, EEP_MAC_MSW };
 
 	sum = 0;
-	for (i = 0; i < 3; i++) {
-		eeval = ah->eep_ops->get_eeprom(ah, EEP_MAC[i]);
-		sum += eeval;
-		common->macaddr[2 * i] = eeval >> 8;
-		common->macaddr[2 * i + 1] = eeval & 0xff;
-	}
+	if (pdata && pdata->macaddr)
+		memcpy(common->macaddr, pdata->macaddr, ETH_ALEN);
+	else
+		for (i = 0; i < 3; i++) {
+			eeval = ah->eep_ops->get_eeprom(ah, EEP_MAC[i]);
+			sum += eeval;
+			common->macaddr[2 * i] = eeval >> 8;
+			common->macaddr[2 * i + 1] = eeval & 0xff;
+		}
 	if (!is_valid_ether_addr(common->macaddr)) {
 		ath_print(common, ATH_DBG_EEPROM,
 			"eeprom contains invalid mac address: %pM\n",
--- a/include/linux/ath9k_platform.h
+++ b/include/linux/ath9k_platform.h
@@ -23,6 +23,7 @@
 
 struct ath9k_platform_data {
 	u16 eeprom_data[ATH9K_PLAT_EEP_MAX_WORDS];
+	u8 *macaddr;
 };
 
 #endif /* _LINUX_ATH9K_PLATFORM_H */