340-brcmfmac-always-perform-cores-checks.patch 2.0 KB

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