OpenWrt – Blame information for rev 4
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | ath9k: Avoid OF no-EEPROM quirks without qca,no-eeprom |
2 | |||
3 | ath9k_of_init() function[0] was initially written on the assumption that |
||
4 | if someone had an explicit ath9k OF node that "there must be something |
||
5 | wrong, why would someone add an OF node if everything is fine"[1] |
||
6 | (Quoting Martin Blumenstingl) |
||
7 | |||
8 | "it turns out it's not that simple. with your requirements I'm now aware |
||
9 | of two use-cases where the current code in ath9k_of_init() doesn't work |
||
10 | without modifications"[1] |
||
11 | |||
12 | The "your requirements" Martin speaks of is the result of the fact that I |
||
13 | have a device (PowerCloud Systems CR5000) that uses the EEPROM for |
||
14 | caldata and firmware but for which the MAC address is take from the MTD |
||
15 | "art" partition[2], or more succinctly: |
||
16 | |||
17 | "some cards come with a physical EEPROM chip so "qca,no-eeprom" should not |
||
18 | be set (your use-case). in this case AH_USE_EEPROM should be set (which |
||
19 | is the default when there is no OF node)"[1] |
||
20 | |||
21 | The other use case is: |
||
22 | |||
23 | the firmware on some PowerMac G5 seems to add a OF node for the ath9k |
||
24 | card automatically. depending on the EEPROM on the card AH_NO_EEP_SWAP |
||
25 | should be unset (which is the default when there is no OF node). see [3] |
||
26 | |||
27 | After this patch to ath9k_of_init() the new behavior will be: |
||
28 | |||
29 | if there's no OF node then everything is the same as before |
||
30 | if there's an empty OF node then ath9k will use the hardware EEPROM |
||
31 | (before ath9k would fail to initialize because no EEPROM data was |
||
32 | provided by userspace) |
||
33 | if there's an OF node with only a MAC address then ath9k will use |
||
34 | the MAC address and the hardware EEPROM (see the case above) |
||
35 | with "qca,no-eeprom" EEPROM data from userspace will be requested. |
||
36 | the behavior here will not change |
||
37 | [1] |
||
38 | |||
39 | Martin provides additional background on EEPROM swapping[1] which I have |
||
40 | included in the patch annotation but not the commit message. |
||
41 | |||
42 | Thanks to Christian Lampartar <chunkeey@gmail.com> for all his help on |
||
43 | troubleshooting this issue and the basis for this patch. |
||
44 | |||
45 | Fixes: 138b41253d9c ("ath9k: parse the device configuration from an OF node") |
||
46 | |||
47 | [0]https://elixir.bootlin.com/linux/v4.20-rc7/source/drivers/net/wireless/ath/ath9k/init.c#L615 |
||
48 | [1]https://github.com/openwrt/openwrt/pull/1645#issuecomment-448027058 |
||
49 | [2]https://github.com/openwrt/openwrt/pull/1613 |
||
50 | [3]https://patchwork.kernel.org/patch/10241731/ |
||
51 | |||
52 | Signed-off-by: Daniel F. Dickinson <cshored@thecshore.com> |
||
53 | --- a/drivers/net/wireless/ath/ath9k/init.c |
||
54 | +++ b/drivers/net/wireless/ath/ath9k/init.c |
||
55 | @@ -642,15 +642,15 @@ static int ath9k_of_init(struct ath_soft |
||
56 | ret = ath9k_eeprom_request(sc, eeprom_name); |
||
57 | if (ret) |
||
58 | return ret; |
||
59 | + |
||
60 | + ah->ah_flags &= ~AH_USE_EEPROM; |
||
61 | + ah->ah_flags |= AH_NO_EEP_SWAP; |
||
62 | } |
||
63 | |||
64 | mac = of_get_mac_address(np); |
||
65 | if (mac) |
||
66 | ether_addr_copy(common->macaddr, mac); |
||
67 | |||
68 | - ah->ah_flags &= ~AH_USE_EEPROM; |
||
69 | - ah->ah_flags |= AH_NO_EEP_SWAP; |
||
70 | - |
||
71 | return 0; |
||
72 | } |
||
73 |