Skip to contentSkip to conversation

brcmfmac: modify __brcmf_err() to take bus as a parameter

PATCH In review Rafał Miłecki 2 participants 4 messages Feb 6, 2019 – Feb 8, 2019 Broadcom BRCM80211 IEEE802.11 wireless drivers

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/2 brcmfmac: modify __brcmf_err() to take bus as a parameter

From: Rafał Miłecki <[email protected]>

So far __brcmf_err() was using pr_err() which didn't allow identifying device that was affected by an error. It's crucial for systems with more than 1 device supported by brcmfmac (a common case for home routers).

This change allows passing struct brcmf_bus to the __brcmf_err(). That struct has been agreed to be the most common one. It allows accessing struct device easily & using dev_err() printing helper.

---
V2: Add missing #include <linux/device.h>
V3: Add #include "bus.h" to fix CONFIG_BRCM_TRACING=y compilation error:
error: dereferencing pointer to incomplete type 'struct brcmf_bus'

---
 .../net/wireless/broadcom/brcm80211/brcmfmac/common.c    | 7 +++++--
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.h | 8 +++++---
 .../wireless/broadcom/brcm80211/brcmfmac/tracepoint.c    | 9 +++++++--
 3 files changed, 17 insertions(+), 7 deletions(-)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c +5 -2
index 0ce1d8174e6d..c62009a06617 100644
@@ -350,7 +350,7 @@ int brcmf_c_preinit_dcmds(struct brcmf_if *ifp)
 }
 
 #ifndef CONFIG_BRCM_TRACING
-void __brcmf_err(const char *func, const char *fmt, ...)
+void __brcmf_err(struct brcmf_bus *bus, const char *func, const char *fmt, ...)
 {
 	struct va_format vaf;
 	va_list args;
@@ -359,7 +359,10 @@ void __brcmf_err(const char *func, const char *fmt, ...)
 
 	vaf.fmt = fmt;
 	vaf.va = &args;
-	pr_err("%s: %pV", func, &vaf);
+	if (bus)
+		dev_err(bus->dev, "%s: %pV", func, &vaf);
+	else
+		pr_err("%s: %pV", func, &vaf);
 
 	va_end(args);
 }
drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.h +5 -3
index cfed0626bf5a..b499f90d94f6 100644
@@ -45,8 +45,10 @@
 #undef pr_fmt
 #define pr_fmt(fmt)		KBUILD_MODNAME ": " fmt
 
-__printf(2, 3)
-void __brcmf_err(const char *func, const char *fmt, ...);
+struct brcmf_bus;
+
+__printf(3, 4)
+void __brcmf_err(struct brcmf_bus *bus, const char *func, const char *fmt, ...);
 /* Macro for error messages. When debugging / tracing the driver all error
  * messages are important to us.
  */
@@ -55,7 +57,7 @@ void __brcmf_err(const char *func, const char *fmt, ...);
 		if (IS_ENABLED(CONFIG_BRCMDBG) ||			\
 		    IS_ENABLED(CONFIG_BRCM_TRACING) ||			\
 		    net_ratelimit())					\
-			__brcmf_err(__func__, fmt, ##__VA_ARGS__);	\
+			__brcmf_err(NULL, __func__, fmt, ##__VA_ARGS__);\
 	} while (0)
 
 #if defined(DEBUG) || defined(CONFIG_BRCM_TRACING)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/tracepoint.c +7 -2
index fe6755944b7b..a5c271bff446 100644
@@ -14,14 +14,16 @@
  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
+#include <linux/device.h>
 #include <linux/module.h> /* bug in tracepoint.h, it should include this */
 
 #ifndef __CHECKER__
 #define CREATE_TRACE_POINTS
+#include "bus.h"
 #include "tracepoint.h"
 #include "debug.h"
 
-void __brcmf_err(const char *func, const char *fmt, ...)
+void __brcmf_err(struct brcmf_bus *bus, const char *func, const char *fmt, ...)
 {
 	struct va_format vaf = {
 		.fmt = fmt,
@@ -30,7 +32,10 @@ void __brcmf_err(const char *func, const char *fmt, ...)
 
 	va_start(args, fmt);
 	vaf.va = &args;
-	pr_err("%s: %pV", func, &vaf);
+	if (bus)
+		dev_err(bus->dev, "%s: %pV", func, &vaf);
+	else
+		pr_err("%s: %pV", func, &vaf);
 	trace_brcmf_err(func, &vaf);
 	va_end(args);
 }
Signature · 1 line
2.20.1
#1 lore raw

PATCH v3 2/2 brcmfmac: pass bus to the __brcmf_err() in pcie.c

From: Rafał Miłecki <[email protected]>

This enables dev_err() usage (instead of pr_err()) in the __brcmf_err(). It makes error messages more meaningful and is important for debugging errors/bugs on systems with multiple brcmfmac supported devices.

All bus files should follow & get updated similarly (soon).

---
V2: Modify pcie.c & not cfg80211.c. The later should use wiphy_err()
V3: Fix CONFIG_PM=y compliation errors:
error: redeclaration of 'bus' with no linkage

---
 .../broadcom/brcm80211/brcmfmac/debug.h       |  2 +
 .../broadcom/brcm80211/brcmfmac/pcie.c        | 59 +++++++++++--------
 2 files changed, 38 insertions(+), 23 deletions(-)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.h +2 -0
index b499f90d94f6..c1f260718c8e 100644
@@ -52,6 +52,7 @@ void __brcmf_err(struct brcmf_bus *bus, const char *func, const char *fmt, ...);
 /* Macro for error messages. When debugging / tracing the driver all error
  * messages are important to us.
  */
+#ifndef brcmf_err
 #define brcmf_err(fmt, ...)						\
 	do {								\
 		if (IS_ENABLED(CONFIG_BRCMDBG) ||			\
@@ -59,6 +60,7 @@ void __brcmf_err(struct brcmf_bus *bus, const char *func, const char *fmt, ...);
 		    net_ratelimit())					\
 			__brcmf_err(NULL, __func__, fmt, ##__VA_ARGS__);\
 	} while (0)
+#endif
 
 #if defined(DEBUG) || defined(CONFIG_BRCM_TRACING)
 
drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c +36 -23

203 lines not on this page · raw message

Signature · 1 line
2.20.1
#2 lore raw
In reply to Rafał Miłecki
Quoted 10 lines · Rafał Miłecki

From: Rafał Miłecki <[email protected]>

So far __brcmf_err() was using pr_err() which didn't allow identifying device that was affected by an error. It's crucial for systems with more than 1 device supported by brcmfmac (a common case for home routers).

This change allows passing struct brcmf_bus to the __brcmf_err(). That struct has been agreed to be the most common one. It allows accessing struct device easily & using dev_err() printing helper.

Quoted 6 lines

---
V2: Add missing #include <linux/device.h>
V3: Add #include "bus.h" to fix CONFIG_BRCM_TRACING=y compilation error:
error: dereferencing pointer to incomplete type 'struct brcmf_bus'

Thanks, this compiles for me now. I also pushed this to w-d-next pending branch to get more build coverage from kbuild bot.

Signature · 1 line
Kalle Valo
#3 lore raw
In reply to Rafał Miłecki
Quoted 6 lines · " wrote:

From: Rafał Miłecki <[email protected]>

So far __brcmf_err() was using pr_err() which didn't allow identifying device that was affected by an error. It's crucial for systems with more than 1 device supported by brcmfmac (a common case for home routers).

Quoted 6 lines

This change allows passing struct brcmf_bus to the __brcmf_err(). That struct has been agreed to be the most common one. It allows accessing struct device easily & using dev_err() printing helper.

2 patches applied to wireless-drivers-next.git, thanks.

5cc898fbcb35 brcmfmac: modify __brcmf_err() to take bus as a parameter 8602e62441ab brcmfmac: pass bus to the __brcmf_err() in pcie.c

Signature · 3 lines
https://patchwork.kernel.org/patch/10799163/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches