405-ath9k-read-eeprom-data-from-platform-data-on-pci-bus.patch 1.6 KB

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