608-add_platform_data_mac_addr.patch 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. --- a/include/linux/rt2x00_platform.h
  2. +++ b/include/linux/rt2x00_platform.h
  3. @@ -14,6 +14,7 @@
  4. struct rt2x00_platform_data {
  5. char *eeprom_file_name;
  6. + const u8 *mac_address;
  7. int disable_2ghz;
  8. int disable_5ghz;
  9. --- a/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c
  10. +++ b/drivers/net/wireless/ralink/rt2x00/rt2x00dev.c
  11. @@ -931,6 +931,18 @@ static void rt2x00lib_rate(struct ieee80
  12. entry->flags |= IEEE80211_RATE_SHORT_PREAMBLE;
  13. }
  14. +const u8 *rt2x00lib_get_mac_address(struct rt2x00_dev *rt2x00dev)
  15. +{
  16. + struct rt2x00_platform_data *pdata;
  17. +
  18. + pdata = rt2x00dev->dev->platform_data;
  19. + if (!pdata)
  20. + return NULL;
  21. +
  22. + return pdata->mac_address;
  23. +}
  24. +EXPORT_SYMBOL_GPL(rt2x00lib_get_mac_address);
  25. +
  26. static int rt2x00lib_probe_hw_modes(struct rt2x00_dev *rt2x00dev,
  27. struct hw_mode_spec *spec)
  28. {
  29. --- a/drivers/net/wireless/ralink/rt2x00/rt2x00.h
  30. +++ b/drivers/net/wireless/ralink/rt2x00/rt2x00.h
  31. @@ -1416,6 +1416,7 @@ static inline void rt2x00debug_dump_fram
  32. */
  33. u32 rt2x00lib_get_bssidx(struct rt2x00_dev *rt2x00dev,
  34. struct ieee80211_vif *vif);
  35. +const u8 *rt2x00lib_get_mac_address(struct rt2x00_dev *rt2x00dev);
  36. /*
  37. * Interrupt context handlers.
  38. --- a/drivers/net/wireless/ralink/rt2x00/rt61pci.c
  39. +++ b/drivers/net/wireless/ralink/rt2x00/rt61pci.c
  40. @@ -2392,6 +2392,7 @@ static int rt61pci_validate_eeprom(struc
  41. u32 reg;
  42. u16 word;
  43. u8 *mac;
  44. + const u8 *pdata_mac;
  45. s8 value;
  46. rt2x00mmio_register_read(rt2x00dev, E2PROM_CSR, &reg);
  47. @@ -2412,7 +2413,11 @@ static int rt61pci_validate_eeprom(struc
  48. /*
  49. * Start validation of the data that has been read.
  50. */
  51. + pdata_mac = rt2x00lib_get_mac_address(rt2x00dev);
  52. mac = rt2x00_eeprom_addr(rt2x00dev, EEPROM_MAC_ADDR_0);
  53. + if (pdata_mac)
  54. + memcpy(mac, pdata_mac, 6);
  55. +
  56. if (!is_valid_ether_addr(mac)) {
  57. eth_random_addr(mac);
  58. rt2x00_eeprom_dbg(rt2x00dev, "MAC: %pM\n", mac);