add chaos_calmer branch
[15.05/openwrt.git] / package / kernel / mac80211 / patches / 378-brcmfmac-allow-NVRAM-values-to-contain-spaces.patch
1 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>
2 Date: Sat, 23 May 2015 09:15:33 +0200
3 Subject: [PATCH] brcmfmac: allow NVRAM values to contain spaces
4 MIME-Version: 1.0
5 Content-Type: text/plain; charset=UTF-8
6 Content-Transfer-Encoding: 8bit
7
8 Platform NVRAMs often contain values with spaces. Even if right now most
9 firmware-supported entries are simple values, we shouldn't reject these
10 with spaces. It was semi-confirmed by Broadcom in the early patch adding
11 support for platform NVRAMs.
12
13 Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
14 Acked-by: Arend van Spriel <arend@broadcom.com>
15 Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
16 ---
17
18 --- a/drivers/net/wireless/brcm80211/brcmfmac/firmware.c
19 +++ b/drivers/net/wireless/brcm80211/brcmfmac/firmware.c
20 @@ -66,6 +66,12 @@ struct nvram_parser {
21         bool multi_dev_v2;
22  };
23  
24 +/**
25 + * is_nvram_char() - check if char is a valid one for NVRAM entry
26 + *
27 + * It accepts all printable ASCII chars except for '#' which opens a comment.
28 + * Please note that ' ' (space) while accepted is not a valid key name char.
29 + */
30  static bool is_nvram_char(char c)
31  {
32         /* comment marker excluded */
33 @@ -73,7 +79,7 @@ static bool is_nvram_char(char c)
34                 return false;
35  
36         /* key and value may have any other readable character */
37 -       return (c > 0x20 && c < 0x7f);
38 +       return (c >= 0x20 && c < 0x7f);
39  }
40  
41  static bool is_whitespace(char c)
42 @@ -120,7 +126,7 @@ static enum nvram_parser_state brcmf_nvr
43                         nvp->multi_dev_v1 = true;
44                 if (strncmp(&nvp->fwnv->data[nvp->entry], "pcie/", 5) == 0)
45                         nvp->multi_dev_v2 = true;
46 -       } else if (!is_nvram_char(c)) {
47 +       } else if (!is_nvram_char(c) || c == ' ') {
48                 brcmf_dbg(INFO, "warning: ln=%d:col=%d: '=' expected, skip invalid key entry\n",
49                           nvp->line, nvp->column);
50                 return COMMENT;