| 1 | --- a/drivers/net/wireless/ath/ath9k/pci.c |
| 2 | +++ b/drivers/net/wireless/ath/ath9k/pci.c |
| 3 | @@ -16,6 +16,7 @@ |
| 4 | |
| 5 | #include <linux/nl80211.h> |
| 6 | #include <linux/pci.h> |
| 7 | +#include <linux/ath9k_platform.h> |
| 8 | #include "ath9k.h" |
| 9 | |
| 10 | static DEFINE_PCI_DEVICE_TABLE(ath_pci_id_table) = { |
| 11 | @@ -53,21 +54,36 @@ static void ath_pci_read_cachesize(struc |
| 12 | |
| 13 | static bool ath_pci_eeprom_read(struct ath_common *common, u32 off, u16 *data) |
| 14 | { |
| 15 | - struct ath_hw *ah = (struct ath_hw *) common->ah; |
| 16 | + struct ath_softc *sc = (struct ath_softc *) common->priv; |
| 17 | + struct ath9k_platform_data *pdata = sc->dev->platform_data; |
| 18 | |
| 19 | - common->ops->read(ah, AR5416_EEPROM_OFFSET + (off << AR5416_EEPROM_S)); |
| 20 | + if (pdata) { |
| 21 | + if (off >= (ARRAY_SIZE(pdata->eeprom_data))) { |
| 22 | + ath_print(common, ATH_DBG_FATAL, |
| 23 | + "%s: eeprom read failed, offset %08x " |
| 24 | + "is out of range\n", |
| 25 | + __func__, off); |
| 26 | + } |
| 27 | + |
| 28 | + *data = pdata->eeprom_data[off]; |
| 29 | + } else { |
| 30 | + struct ath_hw *ah = (struct ath_hw *) common->ah; |
| 31 | + |
| 32 | + common->ops->read(ah, AR5416_EEPROM_OFFSET + |
| 33 | + (off << AR5416_EEPROM_S)); |
| 34 | + |
| 35 | + if (!ath9k_hw_wait(ah, |
| 36 | + AR_EEPROM_STATUS_DATA, |
| 37 | + AR_EEPROM_STATUS_DATA_BUSY | |
| 38 | + AR_EEPROM_STATUS_DATA_PROT_ACCESS, 0, |
| 39 | + AH_WAIT_TIMEOUT)) { |
| 40 | + return false; |
| 41 | + } |
| 42 | |
| 43 | - if (!ath9k_hw_wait(ah, |
| 44 | - AR_EEPROM_STATUS_DATA, |
| 45 | - AR_EEPROM_STATUS_DATA_BUSY | |
| 46 | - AR_EEPROM_STATUS_DATA_PROT_ACCESS, 0, |
| 47 | - AH_WAIT_TIMEOUT)) { |
| 48 | - return false; |
| 49 | + *data = MS(common->ops->read(ah, AR_EEPROM_STATUS_DATA), |
| 50 | + AR_EEPROM_STATUS_DATA_VAL); |
| 51 | } |
| 52 | |
| 53 | - *data = MS(common->ops->read(ah, AR_EEPROM_STATUS_DATA), |
| 54 | - AR_EEPROM_STATUS_DATA_VAL); |
| 55 | - |
| 56 | return true; |
| 57 | } |
| 58 | |
| 59 | |