ath9k: add a few calibration related fixes
[openwrt/svn-archive/archive.git] / package / kernel / mac80211 / patches / 335-ath9k-use-a-random-MAC-address-if-the-EEPROM-address.patch
1 From: Felix Fietkau <nbd@openwrt.org>
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
6 Based on OpenWrt patch by Gabor Juhos
7
8 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
9 ---
10
11 --- a/drivers/net/wireless/ath/ath9k/hw.c
12 +++ b/drivers/net/wireless/ath/ath9k/hw.c
13 @@ -19,6 +19,7 @@
14 #include <linux/module.h>
15 #include <linux/time.h>
16 #include <linux/bitops.h>
17 +#include <linux/etherdevice.h>
18 #include <asm/unaligned.h>
19
20 #include "hw.h"
21 @@ -446,8 +447,16 @@ static int ath9k_hw_init_macaddr(struct
22 common->macaddr[2 * i] = eeval >> 8;
23 common->macaddr[2 * i + 1] = eeval & 0xff;
24 }
25 - if (sum == 0 || sum == 0xffff * 3)
26 - return -EADDRNOTAVAIL;
27 + if (!is_valid_ether_addr(common->macaddr)) {
28 + ath_err(common,
29 + "eeprom contains invalid mac address: %pM\n",
30 + common->macaddr);
31 +
32 + random_ether_addr(common->macaddr);
33 + ath_err(common,
34 + "random mac address will be used: %pM\n",
35 + common->macaddr);
36 + }
37
38 return 0;
39 }