407-ath9k-override-mac-address-from-platform-data.patch 1.5 KB

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