7bbd57e15ed3e9b28443c52a02cccac9780de634
[openwrt/staging/yousong.git] / package / kernel / mac80211 / patches / 380-brcmfmac-support-NVRAMs-containing-pci-devpaths-inst.patch
1 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>
2 Date: Thu, 28 May 2015 14:19:21 +0200
3 Subject: [PATCH] brcmfmac: support NVRAMs containing pci devpaths (instead of
4 pcie)
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 Recently Broadcom added support for NVRAMs with entries for multiple
10 PCIe devices. One of the supported formats is based on prefixes defined
11 like: devpath0=pcie/1/4/ and entries like 0:foo=bar 0:baz=qux etc.
12
13 Unfortunately there are also a bit older devices using different way of
14 defining prefixes, e.g. SmartRG SR400ac (2 x BCM43602) with entries:
15 devpath0=pci/1/1/
16 devpath1=pci/2/1
17 Broadcom stated this old format will never be used/supported by brcmfmac
18 but given the simplicity of this patch I'll insist on supporting it.
19
20 Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
21 Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
22 ---
23
24 --- a/drivers/net/wireless/brcm80211/brcmfmac/firmware.c
25 +++ b/drivers/net/wireless/brcm80211/brcmfmac/firmware.c
26 @@ -232,6 +232,8 @@ static void brcmf_fw_strip_multi_v1(stru
27 u16 bus_nr)
28 {
29 /* Device path with a leading '=' key-value separator */
30 + char pci_path[] = "=pci/?/?";
31 + size_t pci_len;
32 char pcie_path[] = "=pcie/?/?";
33 size_t pcie_len;
34
35 @@ -251,6 +253,9 @@ static void brcmf_fw_strip_multi_v1(stru
36 /* First search for the devpathX and see if it is the configuration
37 * for domain_nr/bus_nr. Search complete nvp
38 */
39 + snprintf(pci_path, sizeof(pci_path), "=pci/%d/%d", domain_nr,
40 + bus_nr);
41 + pci_len = strlen(pci_path);
42 snprintf(pcie_path, sizeof(pcie_path), "=pcie/%d/%d", domain_nr,
43 bus_nr);
44 pcie_len = strlen(pcie_path);
45 @@ -260,8 +265,9 @@ static void brcmf_fw_strip_multi_v1(stru
46 /* Format: devpathX=pcie/Y/Z/
47 * Y = domain_nr, Z = bus_nr, X = virtual ID
48 */
49 - if ((strncmp(&nvp->nvram[i], "devpath", 7) == 0) &&
50 - (strncmp(&nvp->nvram[i + 8], pcie_path, pcie_len) == 0)) {
51 + if (strncmp(&nvp->nvram[i], "devpath", 7) == 0 &&
52 + (!strncmp(&nvp->nvram[i + 8], pci_path, pci_len) ||
53 + !strncmp(&nvp->nvram[i + 8], pcie_path, pcie_len))) {
54 id = nvp->nvram[i + 7] - '0';
55 found = true;
56 break;