339-v5.1-0001-brcmfmac-modify-__brcmf_err-to-take-bus-as-a-paramet.patch 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. From 5cc898fbcb352b764f8d51c16e10e2eb0056173d Mon Sep 17 00:00:00 2001
  2. From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
  3. Date: Wed, 6 Feb 2019 12:28:15 +0100
  4. Subject: [PATCH] brcmfmac: modify __brcmf_err() to take bus as a parameter
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. So far __brcmf_err() was using pr_err() which didn't allow identifying
  9. device that was affected by an error. It's crucial for systems with more
  10. than 1 device supported by brcmfmac (a common case for home routers).
  11. This change allows passing struct brcmf_bus to the __brcmf_err(). That
  12. struct has been agreed to be the most common one. It allows accessing
  13. struct device easily & using dev_err() printing helper.
  14. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
  15. Acked-by: Arend van Spriel <arend.vanspriel@broadcom.com>
  16. Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
  17. ---
  18. .../net/wireless/broadcom/brcm80211/brcmfmac/common.c | 7 +++++--
  19. drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.h | 8 +++++---
  20. .../wireless/broadcom/brcm80211/brcmfmac/tracepoint.c | 9 +++++++--
  21. 3 files changed, 17 insertions(+), 7 deletions(-)
  22. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
  23. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
  24. @@ -221,7 +221,7 @@ done:
  25. }
  26. #ifndef CPTCFG_BRCM_TRACING
  27. -void __brcmf_err(const char *func, const char *fmt, ...)
  28. +void __brcmf_err(struct brcmf_bus *bus, const char *func, const char *fmt, ...)
  29. {
  30. struct va_format vaf;
  31. va_list args;
  32. @@ -230,7 +230,10 @@ void __brcmf_err(const char *func, const
  33. vaf.fmt = fmt;
  34. vaf.va = &args;
  35. - pr_err("%s: %pV", func, &vaf);
  36. + if (bus)
  37. + dev_err(bus->dev, "%s: %pV", func, &vaf);
  38. + else
  39. + pr_err("%s: %pV", func, &vaf);
  40. va_end(args);
  41. }
  42. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.h
  43. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.h
  44. @@ -45,8 +45,10 @@
  45. #undef pr_fmt
  46. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  47. -__printf(2, 3)
  48. -void __brcmf_err(const char *func, const char *fmt, ...);
  49. +struct brcmf_bus;
  50. +
  51. +__printf(3, 4)
  52. +void __brcmf_err(struct brcmf_bus *bus, const char *func, const char *fmt, ...);
  53. /* Macro for error messages. When debugging / tracing the driver all error
  54. * messages are important to us.
  55. */
  56. @@ -55,7 +57,7 @@ void __brcmf_err(const char *func, const
  57. if (IS_ENABLED(CPTCFG_BRCMDBG) || \
  58. IS_ENABLED(CPTCFG_BRCM_TRACING) || \
  59. net_ratelimit()) \
  60. - __brcmf_err(__func__, fmt, ##__VA_ARGS__); \
  61. + __brcmf_err(NULL, __func__, fmt, ##__VA_ARGS__);\
  62. } while (0)
  63. #if defined(DEBUG) || defined(CPTCFG_BRCM_TRACING)
  64. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/tracepoint.c
  65. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/tracepoint.c
  66. @@ -14,14 +14,16 @@
  67. * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  68. */
  69. +#include <linux/device.h>
  70. #include <linux/module.h> /* bug in tracepoint.h, it should include this */
  71. #ifndef __CHECKER__
  72. #define CREATE_TRACE_POINTS
  73. +#include "bus.h"
  74. #include "tracepoint.h"
  75. #include "debug.h"
  76. -void __brcmf_err(const char *func, const char *fmt, ...)
  77. +void __brcmf_err(struct brcmf_bus *bus, const char *func, const char *fmt, ...)
  78. {
  79. struct va_format vaf = {
  80. .fmt = fmt,
  81. @@ -30,7 +32,10 @@ void __brcmf_err(const char *func, const
  82. va_start(args, fmt);
  83. vaf.va = &args;
  84. - pr_err("%s: %pV", func, &vaf);
  85. + if (bus)
  86. + dev_err(bus->dev, "%s: %pV", func, &vaf);
  87. + else
  88. + pr_err("%s: %pV", func, &vaf);
  89. trace_brcmf_err(func, &vaf);
  90. va_end(args);
  91. }