lantiq: allow platforms with rt2x00 to override the mac address without overriding...
[openwrt/svn-archive/archive.git] / package / mac80211 / patches / 608-add_platform_data_mac_addr.patch
1 --- a/include/linux/rt2x00_platform.h
2 +++ b/include/linux/rt2x00_platform.h
3 @@ -14,6 +14,7 @@
4
5 struct rt2x00_platform_data {
6 char *eeprom_file_name;
7 + const u8 *mac_address;
8
9 int disable_2ghz;
10 int disable_5ghz;
11 --- a/drivers/net/wireless/rt2x00/rt2x00dev.c
12 +++ b/drivers/net/wireless/rt2x00/rt2x00dev.c
13 @@ -825,6 +825,18 @@ static void rt2x00lib_rate(struct ieee80
14 entry->flags |= IEEE80211_RATE_SHORT_PREAMBLE;
15 }
16
17 +const u8 *rt2x00lib_get_mac_address(struct rt2x00_dev *rt2x00dev)
18 +{
19 + struct rt2x00_platform_data *pdata;
20 +
21 + pdata = rt2x00dev->dev->platform_data;
22 + if (!pdata)
23 + return NULL;
24 +
25 + return pdata->mac_address;
26 +}
27 +EXPORT_SYMBOL_GPL(rt2x00lib_get_mac_address);
28 +
29 static int rt2x00lib_probe_hw_modes(struct rt2x00_dev *rt2x00dev,
30 struct hw_mode_spec *spec)
31 {
32 --- a/drivers/net/wireless/rt2x00/rt2x00.h
33 +++ b/drivers/net/wireless/rt2x00/rt2x00.h
34 @@ -1280,6 +1280,7 @@ static inline void rt2x00debug_dump_fram
35 */
36 u32 rt2x00lib_get_bssidx(struct rt2x00_dev *rt2x00dev,
37 struct ieee80211_vif *vif);
38 +const u8 *rt2x00lib_get_mac_address(struct rt2x00_dev *rt2x00dev);
39
40 /*
41 * Interrupt context handlers.
42 --- a/drivers/net/wireless/rt2x00/rt61pci.c
43 +++ b/drivers/net/wireless/rt2x00/rt61pci.c
44 @@ -2393,6 +2393,7 @@ static int rt61pci_validate_eeprom(struc
45 u32 reg;
46 u16 word;
47 u8 *mac;
48 + const u8 *pdata_mac;
49 s8 value;
50
51 rt2x00pci_register_read(rt2x00dev, E2PROM_CSR, &reg);
52 @@ -2413,7 +2414,11 @@ static int rt61pci_validate_eeprom(struc
53 /*
54 * Start validation of the data that has been read.
55 */
56 + pdata_mac = rt2x00lib_get_mac_address(rt2x00dev);
57 mac = rt2x00_eeprom_addr(rt2x00dev, EEPROM_MAC_ADDR_0);
58 + if (pdata_mac)
59 + memcpy(mac, pdata_mac, 6);
60 +
61 if (!is_valid_ether_addr(mac)) {
62 random_ether_addr(mac);
63 EEPROM(rt2x00dev, "MAC: %pM\n", mac);