1 --- a/drivers/net/wireless/ath/ath5k/ath5k.h
2 +++ b/drivers/net/wireless/ath/ath5k/ath5k.h
3 @@ -1159,6 +1159,7 @@ struct ath_bus_ops {
4 enum ath_bus_type ath_bus_type;
5 void (*read_cachesize)(struct ath_common *common, int *csz);
6 bool (*eeprom_read)(struct ath_common *common, u32 off, u16 *data);
7 + int (*eeprom_read_mac)(struct ath5k_hw *ah, u8 *mac);
11 @@ -1244,7 +1245,6 @@ int ath5k_hw_dma_stop(struct ath5k_hw *a
12 /* EEPROM access functions */
13 int ath5k_eeprom_init(struct ath5k_hw *ah);
14 void ath5k_eeprom_detach(struct ath5k_hw *ah);
15 -int ath5k_eeprom_read_mac(struct ath5k_hw *ah, u8 *mac);
18 /* Protocol Control Unit Functions */
19 --- a/drivers/net/wireless/ath/ath5k/eeprom.c
20 +++ b/drivers/net/wireless/ath/ath5k/eeprom.c
21 @@ -1723,46 +1723,6 @@ ath5k_eeprom_read_spur_chans(struct ath5
26 - * Read the MAC address from eeprom or platform_data
28 -int ath5k_eeprom_read_mac(struct ath5k_hw *ah, u8 *mac)
30 - u8 mac_d[ETH_ALEN] = {};
34 - struct ath5k_platform_data *pdata = NULL;
36 - if (ah->ah_sc->pdev)
37 - pdata = ah->ah_sc->pdev->dev.platform_data;
39 - if (pdata && pdata->macaddr)
41 - memcpy(mac, pdata->macaddr, ETH_ALEN);
45 - AR5K_EEPROM_READ(0x20, data);
47 - for (offset = 0x1f, octet = 0, total = 0; offset >= 0x1d; offset--) {
48 - AR5K_EEPROM_READ(offset, data);
51 - mac_d[octet + 1] = data & 0xff;
52 - mac_d[octet] = data >> 8;
56 - if (!total || total == 3 * 0xffff)
59 - memcpy(mac, mac_d, ETH_ALEN);
65 /***********************\
66 * Init/Detach functions *
67 \***********************/
68 --- a/drivers/net/wireless/ath/ath5k/pci.c
69 +++ b/drivers/net/wireless/ath/ath5k/pci.c
71 #include <linux/pci.h>
72 #include <linux/pci-aspm.h>
73 #include <linux/ath5k_platform.h>
74 +#include <linux/etherdevice.h>
78 @@ -122,11 +123,52 @@ int ath5k_hw_read_srev(struct ath5k_hw *
83 + * Read the MAC address from eeprom or platform_data
85 +static int ath5k_pci_eeprom_read_mac(struct ath5k_hw *ah, u8 *mac)
87 + u8 mac_d[ETH_ALEN] = {};
91 + struct ath5k_platform_data *pdata = NULL;
93 + if (ah->ah_sc->pdev)
94 + pdata = ah->ah_sc->pdev->dev.platform_data;
96 + if (pdata && pdata->macaddr)
98 + memcpy(mac, pdata->macaddr, ETH_ALEN);
102 + AR5K_EEPROM_READ(0x20, data);
104 + for (offset = 0x1f, octet = 0, total = 0; offset >= 0x1d; offset--) {
105 + AR5K_EEPROM_READ(offset, data);
108 + mac_d[octet + 1] = data & 0xff;
109 + mac_d[octet] = data >> 8;
113 + if (!total || total == 3 * 0xffff)
116 + memcpy(mac, mac_d, ETH_ALEN);
122 /* Common ath_bus_opts structure */
123 static const struct ath_bus_ops ath_pci_bus_ops = {
124 .ath_bus_type = ATH_PCI,
125 .read_cachesize = ath5k_pci_read_cachesize,
126 .eeprom_read = ath5k_pci_eeprom_read,
127 + .eeprom_read_mac = ath5k_pci_eeprom_read_mac,
130 /********************\
131 --- a/drivers/net/wireless/ath/ath5k/ahb.c
132 +++ b/drivers/net/wireless/ath/ath5k/ahb.c
135 #include <linux/nl80211.h>
136 #include <linux/platform_device.h>
137 +#include <linux/etherdevice.h>
138 #include <ar231x_platform.h>
141 @@ -62,10 +63,27 @@ int ath5k_hw_read_srev(struct ath5k_hw *
145 +static int ath5k_ahb_eeprom_read_mac(struct ath5k_hw *ah, u8 *mac)
147 + struct ath5k_softc *sc = ah->ah_sc;
148 + struct platform_device *pdev = to_platform_device(sc->dev);
149 + struct ar231x_board_config *bcfg = pdev->dev.platform_data;
152 + if (to_platform_device(sc->dev)->id == 0)
153 + cfg_mac = bcfg->config->wlan0_mac;
155 + cfg_mac = bcfg->config->wlan1_mac;
157 + memcpy(mac, cfg_mac, ETH_ALEN);
161 static const struct ath_bus_ops ath_ahb_bus_ops = {
162 .ath_bus_type = ATH_AHB,
163 .read_cachesize = ath5k_ahb_read_cachesize,
164 .eeprom_read = ath5k_ahb_eeprom_read,
165 + .eeprom_read_mac = ath5k_ahb_eeprom_read_mac,
169 --- a/drivers/net/wireless/ath/ath5k/base.c
170 +++ b/drivers/net/wireless/ath/ath5k/base.c
171 @@ -2880,7 +2880,7 @@ ath5k_init(struct ieee80211_hw *hw)
172 INIT_WORK(&sc->reset_work, ath5k_reset_work);
173 INIT_DELAYED_WORK(&sc->tx_complete_work, ath5k_tx_complete_poll_work);
175 - ret = ath5k_eeprom_read_mac(ah, mac);
176 + ret = ath5k_hw_common(ah)->bus_ops->eeprom_read_mac(ah, mac);
178 ATH5K_ERR(sc, "unable to read address from EEPROM\n");