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