335-ath9k-use-a-random-MAC-address-if-the-EEPROM-address.patch 1013 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. From: Felix Fietkau <[email protected]>
  2. Date: Sat, 18 Oct 2014 18:31:49 +0200
  3. Subject: [PATCH] ath9k: use a random MAC address if the EEPROM address
  4. is invalid
  5. Based on OpenWrt patch by Gabor Juhos
  6. Signed-off-by: Felix Fietkau <[email protected]>
  7. ---
  8. --- a/drivers/net/wireless/ath/ath9k/hw.c
  9. +++ b/drivers/net/wireless/ath/ath9k/hw.c
  10. @@ -19,6 +19,7 @@
  11. #include <linux/module.h>
  12. #include <linux/time.h>
  13. #include <linux/bitops.h>
  14. +#include <linux/etherdevice.h>
  15. #include <asm/unaligned.h>
  16. #include "hw.h"
  17. @@ -446,8 +447,16 @@ static int ath9k_hw_init_macaddr(struct
  18. common->macaddr[2 * i] = eeval >> 8;
  19. common->macaddr[2 * i + 1] = eeval & 0xff;
  20. }
  21. - if (sum == 0 || sum == 0xffff * 3)
  22. - return -EADDRNOTAVAIL;
  23. + if (!is_valid_ether_addr(common->macaddr)) {
  24. + ath_err(common,
  25. + "eeprom contains invalid mac address: %pM\n",
  26. + common->macaddr);
  27. +
  28. + random_ether_addr(common->macaddr);
  29. + ath_err(common,
  30. + "random mac address will be used: %pM\n",
  31. + common->macaddr);
  32. + }
  33. return 0;
  34. }