add chaos_calmer branch
[15.05/openwrt.git] / package / kernel / mac80211 / patches / 340-brcmfmac-always-perform-cores-checks.patch
1 From: Arend van Spriel <arend@broadcom.com>
2 Date: Wed, 11 Mar 2015 16:11:28 +0100
3 Subject: [PATCH] brcmfmac: always perform cores checks
4
5 Instead of checking the cores in the chip only if CONFIG_BRCMDBG
6 is selected perform the check always and extend it with more sanity
7 checking.
8
9 Reviewed-by: Hante Meuleman <meuleman@broadcom.com>
10 Reviewed-by: Pieter-Paul Giesberts <pieterpg@broadcom.com>
11 Signed-off-by: Arend van Spriel <arend@broadcom.com>
12 Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
13 ---
14
15 --- a/drivers/net/wireless/brcm80211/brcmfmac/chip.c
16 +++ b/drivers/net/wireless/brcm80211/brcmfmac/chip.c
17 @@ -419,13 +419,13 @@ static struct brcmf_core *brcmf_chip_add
18         return &core->pub;
19  }
20  
21 -#ifdef DEBUG
22  /* safety check for chipinfo */
23  static int brcmf_chip_cores_check(struct brcmf_chip_priv *ci)
24  {
25         struct brcmf_core_priv *core;
26         bool need_socram = false;
27         bool has_socram = false;
28 +       bool cpu_found = false;
29         int idx = 1;
30  
31         list_for_each_entry(core, &ci->cores, list) {
32 @@ -435,12 +435,14 @@ static int brcmf_chip_cores_check(struct
33  
34                 switch (core->pub.id) {
35                 case BCMA_CORE_ARM_CM3:
36 +                       cpu_found = true;
37                         need_socram = true;
38                         break;
39                 case BCMA_CORE_INTERNAL_MEM:
40                         has_socram = true;
41                         break;
42                 case BCMA_CORE_ARM_CR4:
43 +                       cpu_found = true;
44                         if (ci->pub.rambase == 0) {
45                                 brcmf_err("RAM base not provided with ARM CR4 core\n");
46                                 return -ENOMEM;
47 @@ -451,19 +453,21 @@ static int brcmf_chip_cores_check(struct
48                 }
49         }
50  
51 +       if (!cpu_found) {
52 +               brcmf_err("CPU core not detected\n");
53 +               return -ENXIO;
54 +       }
55         /* check RAM core presence for ARM CM3 core */
56         if (need_socram && !has_socram) {
57                 brcmf_err("RAM core not provided with ARM CM3 core\n");
58                 return -ENODEV;
59         }
60 +       if (!ci->pub.ramsize) {
61 +               brcmf_err("RAM size is undetermined\n");
62 +               return -ENOMEM;
63 +       }
64         return 0;
65  }
66 -#else  /* DEBUG */
67 -static inline int brcmf_chip_cores_check(struct brcmf_chip_priv *ci)
68 -{
69 -       return 0;
70 -}
71 -#endif
72  
73  static void brcmf_chip_get_raminfo(struct brcmf_chip_priv *ci)
74  {