Skip to contentSkip to conversation

brcmfmac: switch to C function (__brcmf_err) for printing errors

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

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/7 brcmfmac: switch to C function (__brcmf_err) for printing errors

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

This will allow extending code and using more detailed messages e.g. with the help of dev_err. Note that *two separated* brcmf_err macros were replaced thanks to using a simple CONFIG_BRCMDBG symbol check in the body.

---
 .../net/wireless/broadcom/brcm80211/brcmfmac/common.c | 19 +++++++++++++++++++
 .../net/wireless/broadcom/brcm80211/brcmfmac/debug.h  | 16 ----------------
 2 files changed, 19 insertions(+), 16 deletions(-)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c +19 -0
index f7c8c2e80349..05fb778ddd0f 100644
@@ -218,6 +218,25 @@ int brcmf_c_preinit_dcmds(struct brcmf_if *ifp)
 	return err;
 }
 
+#ifndef CONFIG_BRCM_TRACING
+void __brcmf_err(const char *func, const char *fmt, ...)
+{
+	struct va_format vaf;
+	va_list args;
+
+	if (!net_ratelimit() && !IS_ENABLED(CONFIG_BRCMDBG))
+		return;
+
+	va_start(args, fmt);
+
+	vaf.fmt = fmt;
+	vaf.va = &args;
+	pr_err("%s: %pV", func, &vaf);
+
+	va_end(args);
+}
+#endif
+
 #if defined(CONFIG_BRCM_TRACING) || defined(CONFIG_BRCMDBG)
 void __brcmf_dbg(u32 level, const char *func, const char *fmt, ...)
 {
drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.h +0 -16
index 6687812770cc..5fef79473c87 100644
@@ -45,26 +45,10 @@
 #undef pr_fmt
 #define pr_fmt(fmt)		KBUILD_MODNAME ": " fmt
 
-/* Macro for error messages. net_ratelimit() is used when driver
- * debugging is not selected. When debugging the driver error
- * messages are as important as other tracing or even more so.
- */
-#ifndef CONFIG_BRCM_TRACING
-#ifdef CONFIG_BRCMDBG
-#define brcmf_err(fmt, ...)	pr_err("%s: " fmt, __func__, ##__VA_ARGS__)
-#else
-#define brcmf_err(fmt, ...)						\
-	do {								\
-		if (net_ratelimit())					\
-			pr_err("%s: " fmt, __func__, ##__VA_ARGS__);	\
-	} while (0)
-#endif
-#else
 __printf(2, 3)
 void __brcmf_err(const char *func, const char *fmt, ...);
 #define brcmf_err(fmt, ...) \
 	__brcmf_err(__func__, fmt, ##__VA_ARGS__)
-#endif
 
 #if defined(DEBUG) || defined(CONFIG_BRCM_TRACING)
 __printf(3, 4)
Signature · 1 line
2.11.0
#1 lore raw

PATCH v2 2/7 brcmfmac: add struct brcmf_pub parameter to the __brcmf_err

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

This will allow getting struct device reference from the passed brcmf_pub for the needs of dev_err. More detailed messages are really important for home routers which frequently have 2 (or even 3) wireless cards supported by brcmfmac.

Note that all calls are yet to be updated as for now brcmf_err macro always passes NULL. This will be handled in following patch to make this change easier to review.

---
V2: Add missing include

---
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/bus.h        | 2 ++
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c     | 2 +-
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.h      | 9 +++++----
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/tracepoint.c | 4 +++-
 4 files changed, 11 insertions(+), 6 deletions(-)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/bus.h +2 -0
index 76693df34742..35d4801a62e6 100644
@@ -17,6 +17,8 @@
 #ifndef BRCMFMAC_BUS_H
 #define BRCMFMAC_BUS_H
 
+#include <linux/device.h>
+
 #include "debug.h"
 
 /* IDs of the 6 default common rings of msgbuf protocol */
drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c +1 -1
index 05fb778ddd0f..0978fb4c9066 100644
@@ -219,7 +219,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_pub *pub, const char *func, const char *fmt, ...)
 {
 	struct va_format vaf;
 	va_list args;
drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.h +5 -4
index 5fef79473c87..012401e6be74 100644
@@ -19,6 +19,8 @@
 
 #include <linux/net.h>	/* net_ratelimit() */
 
+struct brcmf_pub;
+
 /* message levels */
 #define BRCMF_TRACE_VAL		0x00000002
 #define BRCMF_INFO_VAL		0x00000004
@@ -45,10 +47,10 @@
 #undef pr_fmt
 #define pr_fmt(fmt)		KBUILD_MODNAME ": " fmt
 
-__printf(2, 3)
-void __brcmf_err(const char *func, const char *fmt, ...);
+__printf(3, 4)
+void __brcmf_err(struct brcmf_pub *pub, const char *func, const char *fmt, ...);
 #define brcmf_err(fmt, ...) \
-	__brcmf_err(__func__, fmt, ##__VA_ARGS__)
+	__brcmf_err(NULL, __func__, fmt, ##__VA_ARGS__)
 
 #if defined(DEBUG) || defined(CONFIG_BRCM_TRACING)
 __printf(3, 4)
@@ -91,7 +93,6 @@ do {									\
 
 extern int brcmf_msg_level;
 
-struct brcmf_pub;
 #ifdef DEBUG
 void brcmf_debugfs_init(void);
 void brcmf_debugfs_exit(void);
drivers/net/wireless/broadcom/brcm80211/brcmfmac/tracepoint.c +3 -1
index fe6755944b7b..329cb65eb78b 100644
@@ -18,10 +18,12 @@
 
 #ifndef __CHECKER__
 #define CREATE_TRACE_POINTS
+#include "bus.h"
+#include "core.h"
 #include "tracepoint.h"
 #include "debug.h"
 
-void __brcmf_err(const char *func, const char *fmt, ...)
+void __brcmf_err(struct brcmf_pub *pub, const char *func, const char *fmt, ...)
 {
 	struct va_format vaf = {
 		.fmt = fmt,
Signature · 1 line
2.11.0
#2 lore raw

PATCH v2 3/7 brcmfmac: pcie: store private pointer to struct brcmf_pub

In reply to Rafał Miłecki

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

Getting this pointer in PCIe code is not trivial and requires using dev_get_drvdata helper which adds extra line of code. Having access to this struct is useful for using generic stuff and e.g. improving logging messages.

---
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c +7 -2
index 6fae4cf3f6ab..8a3c6e2e4b38 100644
@@ -265,6 +265,7 @@ struct brcmf_pciedev_info {
 	void (*write_ptr)(struct brcmf_pciedev_info *devinfo, u32 mem_offset,
 			  u16 value);
 	struct brcmf_mp_device *settings;
+	struct brcmf_pub *pub;
 };
 
 struct brcmf_pcie_ringbuf {
@@ -1564,14 +1565,18 @@ static void brcmf_pcie_release_resource(struct brcmf_pciedev_info *devinfo)
 
 static int brcmf_pcie_attach_bus(struct brcmf_pciedev_info *devinfo)
 {
+	struct device *dev = &devinfo->pdev->dev;
+	struct brcmf_bus *bus = dev_get_drvdata(dev);
 	int ret;
 
 	/* Attach to the common driver interface */
-	ret = brcmf_attach(&devinfo->pdev->dev, devinfo->settings);
+	ret = brcmf_attach(dev, devinfo->settings);
 	if (ret) {
 		brcmf_err("brcmf_attach failed\n");
 	} else {
-		ret = brcmf_bus_started(&devinfo->pdev->dev);
+		devinfo->pub = bus->drvr;
+
+		ret = brcmf_bus_started(dev);
 		if (ret)
 			brcmf_err("dongle is not responding\n");
 	}
Signature · 1 line
2.11.0
#3 lore raw

PATCH v2 4/7 brcmfmac: usb: store private pointer to struct brcmf_pub

In reply to Rafał Miłecki

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

Having access to this struct is useful for using generic stuff and e.g. improving logging messages.

---
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c +8 -4
index d93ebbdc7737..523949c44861 100644
@@ -174,6 +174,7 @@ struct brcmf_usbdev_info {
 
 	bool wowl_enabled;
 	struct brcmf_mp_device *settings;
+	struct brcmf_pub *pub;
 };
 
 static void brcmf_usb_rx_refill(struct brcmf_usbdev_info *devinfo,
@@ -1135,26 +1136,29 @@ static const struct brcmf_bus_ops brcmf_usb_bus_ops = {
 
 static int brcmf_usb_bus_setup(struct brcmf_usbdev_info *devinfo)
 {
+	struct device *dev = devinfo->dev;
+	struct brcmf_bus *bus = dev_get_drvdata(dev);
 	int ret;
 
 	/* Attach to the common driver interface */
-	ret = brcmf_attach(devinfo->dev, devinfo->settings);
+	ret = brcmf_attach(dev, devinfo->settings);
 	if (ret) {
 		brcmf_err("brcmf_attach failed\n");
 		return ret;
 	}
+	devinfo->pub = bus->drvr;
 
-	ret = brcmf_usb_up(devinfo->dev);
+	ret = brcmf_usb_up(dev);
 	if (ret)
 		goto fail;
 
-	ret = brcmf_bus_started(devinfo->dev);
+	ret = brcmf_bus_started(dev);
 	if (ret)
 		goto fail;
 
 	return 0;
 fail:
-	brcmf_detach(devinfo->dev);
+	brcmf_detach(dev);
 	return ret;
 }
 
Signature · 1 line
2.11.0
#4 lore raw

PATCH v2 5/7 brcmfmac: sdio: store private pointer to struct brcmf_pub

In reply to Rafał Miłecki

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

Having access to this struct is useful for using generic stuff and e.g. improving logging messages.

---
V2: Add this (new) patch

---
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c +2 -0
index c5744b45ec8f..81a1e24852e0 100644
@@ -434,6 +434,7 @@ struct brcmf_sdio_count {
 struct brcmf_sdio {
 	struct brcmf_sdio_dev *sdiodev;	/* sdio device handler */
 	struct brcmf_chip *ci;	/* Chip info struct */
+	struct brcmf_pub *pub;	/* Bus generic struct */
 
 	u32 hostintmask;	/* Copy of Host Interrupt Mask */
 	atomic_t intstatus;	/* Intstatus bits (events) pending */
@@ -4155,6 +4156,7 @@ struct brcmf_sdio *brcmf_sdio_probe(struct brcmf_sdio_dev *sdiodev)
 		brcmf_err("brcmf_attach failed\n");
 		goto fail;
 	}
+	bus->pub = sdiodev->bus_if->drvr;
 
 	/* allocate scatter-gather table. sg support
 	 * will be disabled upon allocation failure.
Signature · 1 line
2.11.0
#5 lore raw

PATCH v2 6/7 brcmfmac: modify all brcmf_err calls adding struct brcmf_pub

In reply to Rafał Miłecki

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

This finally allows getting extra info from struct brcmf_pub in the brcmf_err and improving error messages. In places where pub struct is not available or hard to obtain NULL is passed instead. Few of these cases could be improved in the future by adding more arguments to various functions.

---
V2: Rebase on the latest tree
Fix pub variable usage in brcmf_cfg80211_vndr_cmds_dcmd_handler
Simplify sdio code thanks to [PATCH V2 5/7] brcmfmac: sdio: store private pointer to struct brcmf_pub

---
 .../wireless/broadcom/brcm80211/brcmfmac/bcdc.c    |  10 +-
 .../wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c  |  49 ++-
 .../wireless/broadcom/brcm80211/brcmfmac/btcoex.c  |   5 +-
 .../broadcom/brcm80211/brcmfmac/cfg80211.c         | 452 ++++++++++++---------
 .../wireless/broadcom/brcm80211/brcmfmac/chip.c    |  26 +-
 .../wireless/broadcom/brcm80211/brcmfmac/common.c  |  22 +-
 .../wireless/broadcom/brcm80211/brcmfmac/core.c    |  45 +-
 .../wireless/broadcom/brcm80211/brcmfmac/debug.c   |   5 +-
 .../wireless/broadcom/brcm80211/brcmfmac/debug.h   |   4 +-
 .../broadcom/brcm80211/brcmfmac/firmware.c         |   2 +-
 .../broadcom/brcm80211/brcmfmac/flowring.c         |   2 +-
 .../wireless/broadcom/brcm80211/brcmfmac/fweh.c    |  16 +-
 .../wireless/broadcom/brcm80211/brcmfmac/fwil.c    |  12 +-
 .../broadcom/brcm80211/brcmfmac/fwsignal.c         |  43 +-
 .../wireless/broadcom/brcm80211/brcmfmac/msgbuf.c  |  58 +--
 .../net/wireless/broadcom/brcm80211/brcmfmac/of.c  |   2 +-
 .../net/wireless/broadcom/brcm80211/brcmfmac/p2p.c |  80 ++--
 .../wireless/broadcom/brcm80211/brcmfmac/pcie.c    |  42 +-
 .../net/wireless/broadcom/brcm80211/brcmfmac/pno.c |  20 +-
 .../wireless/broadcom/brcm80211/brcmfmac/proto.c   |   4 +-
 .../wireless/broadcom/brcm80211/brcmfmac/sdio.c    | 213 +++++-----
 .../net/wireless/broadcom/brcm80211/brcmfmac/usb.c |  70 ++--
 .../wireless/broadcom/brcm80211/brcmfmac/vendor.c  |  17 +-
 23 files changed, 692 insertions(+), 507 deletions(-)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcdc.c +5 -5
index 384b1873e7e3..e57e189f3a6a 100644
@@ -169,7 +169,7 @@ brcmf_proto_bcdc_query_dcmd(struct brcmf_pub *drvr, int ifidx, uint cmd,
 
 	ret = brcmf_proto_bcdc_msg(drvr, ifidx, cmd, buf, len, false);
 	if (ret < 0) {
-		brcmf_err("brcmf_proto_bcdc_msg failed w/status %d\n",
+		brcmf_err(drvr, "brcmf_proto_bcdc_msg failed w/status %d\n",
 			  ret);
 		goto done;
 	}
@@ -186,7 +186,7 @@ brcmf_proto_bcdc_query_dcmd(struct brcmf_pub *drvr, int ifidx, uint cmd,
 	if ((id < bcdc->reqid) && (++retries < RETRIES))
 		goto retry;
 	if (id != bcdc->reqid) {
-		brcmf_err("%s: unexpected request id %d (expected %d)\n",
+		brcmf_err(drvr, "%s: unexpected request id %d (expected %d)\n",
 			  brcmf_ifname(brcmf_get_ifp(drvr, ifidx)), id,
 			  bcdc->reqid);
 		ret = -EINVAL;
@@ -234,7 +234,7 @@ brcmf_proto_bcdc_set_dcmd(struct brcmf_pub *drvr, int ifidx, uint cmd,
 	id = (flags & BCDC_DCMD_ID_MASK) >> BCDC_DCMD_ID_SHIFT;
 
 	if (id != bcdc->reqid) {
-		brcmf_err("%s: unexpected request id %d (expected %d)\n",
+		brcmf_err(drvr, "%s: unexpected request id %d (expected %d)\n",
 			  brcmf_ifname(brcmf_get_ifp(drvr, ifidx)), id,
 			  bcdc->reqid);
 		ret = -EINVAL;
@@ -299,7 +299,7 @@ brcmf_proto_bcdc_hdrpull(struct brcmf_pub *drvr, bool do_fws,
 	}
 	if (((h->flags & BCDC_FLAG_VER_MASK) >> BCDC_FLAG_VER_SHIFT) !=
 	    BCDC_PROTO_VER) {
-		brcmf_err("%s: non-BCDC packet received, flags 0x%x\n",
+		brcmf_err(drvr, "%s: non-BCDC packet received, flags 0x%x\n",
 			  brcmf_ifname(tmp_if), h->flags);
 		return -EBADE;
 	}
@@ -379,7 +379,7 @@ int brcmf_proto_bcdc_attach(struct brcmf_pub *drvr)
 
 	/* ensure that the msg buf directly follows the cdc msg struct */
 	if ((unsigned long)(&bcdc->msg + 1) != (unsigned long)bcdc->buf) {
-		brcmf_err("struct brcmf_proto_bcdc is not correctly defined\n");
+		brcmf_err(drvr, "struct brcmf_proto_bcdc is not correctly defined\n");
 		goto fail;
 	}
 
drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c +30 -19

227 lines not on this page · raw message

drivers/net/wireless/broadcom/brcm80211/brcmfmac/btcoex.c +3 -2
index 14a70d4b4e86..0944d7291d58 100644
@@ -215,7 +215,7 @@ static bool brcmf_btcoex_is_sco_active(struct brcmf_if *ifp)
 		ioc_res = brcmf_btcoex_params_read(ifp, 27, &param27);
 
 		if (ioc_res < 0) {
-			brcmf_err("ioc read btc params error\n");
+			brcmf_err(ifp->drvr, "ioc read btc params error\n");
 			break;
 		}
 
@@ -345,7 +345,8 @@ static void brcmf_btcoex_handler(struct work_struct *work)
 		goto idle;
 
 	default:
-		brcmf_err("invalid state=%d !!!\n", btci->bt_state);
+		brcmf_err(btci->cfg->pub, "invalid state=%d !!!\n",
+			  btci->bt_state);
 		goto idle;
 	}
 
drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c +264 -188

1,886 lines not on this page · raw message

drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c +13 -13
index 05f22ff81d60..8ae44c3fcd85 100644
@@ -313,7 +313,7 @@ static void brcmf_chip_sb_coredisable(struct brcmf_core_priv *core,
 
 		val = ci->ops->read32(ci->ctx, CORE_SB(base, sbtmstatehigh));
 		if (val & SSB_TMSHIGH_BUSY)
-			brcmf_err("core state still busy\n");
+			brcmf_err(NULL, "core state still busy\n");
 
 		val = ci->ops->read32(ci->ctx, CORE_SB(base, sbidlow));
 		if (val & SSB_IDLOW_INITIATOR) {
@@ -526,12 +526,12 @@ static int brcmf_chip_cores_check(struct brcmf_chip_priv *ci)
 	}
 
 	if (!cpu_found) {
-		brcmf_err("CPU core not detected\n");
+		brcmf_err(NULL, "CPU core not detected\n");
 		return -ENXIO;
 	}
 	/* check RAM core presence for ARM CM3 core */
 	if (need_socram && !has_socram) {
-		brcmf_err("RAM core not provided with ARM CM3 core\n");
+		brcmf_err(NULL, "RAM core not provided with ARM CM3 core\n");
 		return -ENODEV;
 	}
 	return 0;
@@ -691,7 +691,7 @@ static u32 brcmf_chip_tcm_rambase(struct brcmf_chip_priv *ci)
 	case BRCM_CC_4366_CHIP_ID:
 		return 0x200000;
 	default:
-		brcmf_err("unknown chip: %s\n", ci->pub.name);
+		brcmf_err(NULL, "unknown chip: %s\n", ci->pub.name);
 		break;
 	}
 	return 0;
@@ -708,7 +708,7 @@ static int brcmf_chip_get_raminfo(struct brcmf_chip_priv *ci)
 		ci->pub.ramsize = brcmf_chip_tcm_ramsize(mem_core);
 		ci->pub.rambase = brcmf_chip_tcm_rambase(ci);
 		if (!ci->pub.rambase) {
-			brcmf_err("RAM base not provided with ARM CR4 core\n");
+			brcmf_err(NULL, "RAM base not provided with ARM CR4 core\n");
 			return -EINVAL;
 		}
 	} else {
@@ -719,14 +719,14 @@ static int brcmf_chip_get_raminfo(struct brcmf_chip_priv *ci)
 			ci->pub.ramsize = brcmf_chip_sysmem_ramsize(mem_core);
 			ci->pub.rambase = brcmf_chip_tcm_rambase(ci);
 			if (!ci->pub.rambase) {
-				brcmf_err("RAM base not provided with ARM CA7 core\n");
+				brcmf_err(NULL, "RAM base not provided with ARM CA7 core\n");
 				return -EINVAL;
 			}
 		} else {
 			mem = brcmf_chip_get_core(&ci->pub,
 						  BCMA_CORE_INTERNAL_MEM);
 			if (!mem) {
-				brcmf_err("No memory cores found\n");
+				brcmf_err(NULL, "No memory cores found\n");
 				return -ENOMEM;
 			}
 			mem_core = container_of(mem, struct brcmf_core_priv,
@@ -740,12 +740,12 @@ static int brcmf_chip_get_raminfo(struct brcmf_chip_priv *ci)
 		  ci->pub.srsize, ci->pub.srsize);
 
 	if (!ci->pub.ramsize) {
-		brcmf_err("RAM size is undetermined\n");
+		brcmf_err(NULL, "RAM size is undetermined\n");
 		return -ENOMEM;
 	}
 
 	if (ci->pub.ramsize > BRCMF_CHIP_MAX_MEMSIZE) {
-		brcmf_err("RAM size is incorrect\n");
+		brcmf_err(NULL, "RAM size is incorrect\n");
 		return -ENOMEM;
 	}
 
@@ -929,7 +929,7 @@ static int brcmf_chip_recognition(struct brcmf_chip_priv *ci)
 
 	if (socitype == SOCI_SB) {
 		if (ci->pub.chip != BRCM_CC_4329_CHIP_ID) {
-			brcmf_err("SB chip is not supported\n");
+			brcmf_err(NULL, "SB chip is not supported\n");
 			return -ENODEV;
 		}
 		ci->iscoreup = brcmf_chip_sb_iscoreup;
@@ -958,7 +958,7 @@ static int brcmf_chip_recognition(struct brcmf_chip_priv *ci)
 
 		brcmf_chip_dmp_erom_scan(ci);
 	} else {
-		brcmf_err("chip backplane type %u is not supported\n",
+		brcmf_err(NULL, "chip backplane type %u is not supported\n",
 			  socitype);
 		return -ENODEV;
 	}
@@ -1007,7 +1007,7 @@ static void brcmf_chip_disable_arm(struct brcmf_chip_priv *chip, u16 id)
 				     ARMCR4_BCMA_IOCTL_CPUHALT);
 		break;
 	default:
-		brcmf_err("unknown id: %u\n", id);
+		brcmf_err(NULL, "unknown id: %u\n", id);
 		break;
 	}
 }
@@ -1206,7 +1206,7 @@ static bool brcmf_chip_cm3_set_active(struct brcmf_chip_priv *chip)
 
 	core = brcmf_chip_get_core(&chip->pub, BCMA_CORE_INTERNAL_MEM);
 	if (!brcmf_chip_iscoreup(core)) {
-		brcmf_err("SOCRAM core is down after reset?\n");
+		brcmf_err(NULL, "SOCRAM core is down after reset?\n");
 		return false;
 	}
 
drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c +12 -10
index 0978fb4c9066..9ad9bd652ca2 100644
@@ -86,6 +86,7 @@ struct brcmf_mp_global_t brcmf_mp_global;
 void brcmf_c_set_joinpref_default(struct brcmf_if *ifp)
 {
 	struct brcmf_join_pref_params join_pref_params[2];
+	struct brcmf_pub *pub = ifp->drvr;
 	int err;
 
 	/* Setup join_pref to select target by RSSI (boost on 5GHz) */
@@ -101,13 +102,14 @@ void brcmf_c_set_joinpref_default(struct brcmf_if *ifp)
 	err = brcmf_fil_iovar_data_set(ifp, "join_pref", join_pref_params,
 				       sizeof(join_pref_params));
 	if (err)
-		brcmf_err("Set join_pref error (%d)\n", err);
+		brcmf_err(pub, "Set join_pref error (%d)\n", err);
 }
 
 int brcmf_c_preinit_dcmds(struct brcmf_if *ifp)
 {
 	s8 eventmask[BRCMF_EVENTING_MASK_LEN];
 	u8 buf[BRCMF_DCMD_SMLEN];
+	struct brcmf_pub *pub = ifp->drvr;
 	struct brcmf_rev_info_le revinfo;
 	struct brcmf_rev_info *ri;
 	char *ptr;
@@ -117,7 +119,7 @@ int brcmf_c_preinit_dcmds(struct brcmf_if *ifp)
 	err = brcmf_fil_iovar_data_get(ifp, "cur_etheraddr", ifp->mac_addr,
 				       sizeof(ifp->mac_addr));
 	if (err < 0) {
-		brcmf_err("Retreiving cur_etheraddr failed, %d\n", err);
+		brcmf_err(pub, "Retreiving cur_etheraddr failed, %d\n", err);
 		goto done;
 	}
 	memcpy(ifp->drvr->mac, ifp->mac_addr, sizeof(ifp->drvr->mac));
@@ -126,7 +128,7 @@ int brcmf_c_preinit_dcmds(struct brcmf_if *ifp)
 				     &revinfo, sizeof(revinfo));
 	ri = &ifp->drvr->revinfo;
 	if (err < 0) {
-		brcmf_err("retrieving revision info failed, %d\n", err);
+		brcmf_err(pub, "retrieving revision info failed, %d\n", err);
 	} else {
 		ri->vendorid = le32_to_cpu(revinfo.vendorid);
 		ri->deviceid = le32_to_cpu(revinfo.deviceid);
@@ -153,7 +155,7 @@ int brcmf_c_preinit_dcmds(struct brcmf_if *ifp)
 	strcpy(buf, "ver");
 	err = brcmf_fil_iovar_data_get(ifp, "ver", buf, sizeof(buf));
 	if (err < 0) {
-		brcmf_err("Retreiving version information failed, %d\n",
+		brcmf_err(pub, "Retreiving version information failed, %d\n",
 			  err);
 		goto done;
 	}
@@ -161,7 +163,7 @@ int brcmf_c_preinit_dcmds(struct brcmf_if *ifp)
 	strsep(&ptr, "\n");
 
 	/* Print fw version info */
-	brcmf_err("Firmware version = %s\n", buf);
+	brcmf_err(pub, "Firmware version = %s\n", buf);
 
 	/* locate firmware version number for ethtool */
 	ptr = strrchr(buf, ' ') + 1;
@@ -170,7 +172,7 @@ int brcmf_c_preinit_dcmds(struct brcmf_if *ifp)
 	/* set mpc */
 	err = brcmf_fil_iovar_int_set(ifp, "mpc", 1);
 	if (err) {
-		brcmf_err("failed setting mpc\n");
+		brcmf_err(pub, "failed setting mpc\n");
 		goto done;
 	}
 
@@ -180,14 +182,14 @@ int brcmf_c_preinit_dcmds(struct brcmf_if *ifp)
 	err = brcmf_fil_iovar_data_get(ifp, "event_msgs", eventmask,
 				       BRCMF_EVENTING_MASK_LEN);
 	if (err) {
-		brcmf_err("Get event_msgs error (%d)\n", err);
+		brcmf_err(pub, "Get event_msgs error (%d)\n", err);
 		goto done;
 	}
 	setbit(eventmask, BRCMF_E_IF);
 	err = brcmf_fil_iovar_data_set(ifp, "event_msgs", eventmask,
 				       BRCMF_EVENTING_MASK_LEN);
 	if (err) {
-		brcmf_err("Set event_msgs error (%d)\n", err);
+		brcmf_err(pub, "Set event_msgs error (%d)\n", err);
 		goto done;
 	}
 
@@ -195,7 +197,7 @@ int brcmf_c_preinit_dcmds(struct brcmf_if *ifp)
 	err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_SCAN_CHANNEL_TIME,
 				    BRCMF_DEFAULT_SCAN_CHANNEL_TIME);
 	if (err) {
-		brcmf_err("BRCMF_C_SET_SCAN_CHANNEL_TIME error (%d)\n",
+		brcmf_err(pub, "BRCMF_C_SET_SCAN_CHANNEL_TIME error (%d)\n",
 			  err);
 		goto done;
 	}
@@ -204,7 +206,7 @@ int brcmf_c_preinit_dcmds(struct brcmf_if *ifp)
 	err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_SCAN_UNASSOC_TIME,
 				    BRCMF_DEFAULT_SCAN_UNASSOC_TIME);
 	if (err) {
-		brcmf_err("BRCMF_C_SET_SCAN_UNASSOC_TIME error (%d)\n",
+		brcmf_err(pub, "BRCMF_C_SET_SCAN_UNASSOC_TIME error (%d)\n",
 			  err);
 		goto done;
 	}
drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c +24 -21

182 lines not on this page · raw message

drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.c +3 -2
index f4644cf371c7..89793a0364b8 100644
@@ -58,16 +58,17 @@ static int brcmf_debug_psm_watchdog_notify(struct brcmf_if *ifp,
 					   const struct brcmf_event_msg *evtmsg,
 					   void *data)
 {
+	struct brcmf_pub *pub = ifp->drvr;
 	int err;
 
 	brcmf_dbg(TRACE, "enter: bsscfgidx=%d\n", ifp->bsscfgidx);
 
-	brcmf_err("PSM's watchdog has fired!\n");
+	brcmf_err(pub, "PSM's watchdog has fired!\n");
 
 	err = brcmf_debug_create_memdump(ifp->drvr->bus_if, data,
 					 evtmsg->datalen);
 	if (err)
-		brcmf_err("Failed to get memory dump, %d\n", err);
+		brcmf_err(pub, "Failed to get memory dump, %d\n", err);
 
 	return err;
 }
drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.h +2 -2
index 012401e6be74..058656811b90 100644
@@ -49,8 +49,8 @@ struct brcmf_pub;
 
 __printf(3, 4)
 void __brcmf_err(struct brcmf_pub *pub, const char *func, const char *fmt, ...);
-#define brcmf_err(fmt, ...) \
-	__brcmf_err(NULL, __func__, fmt, ##__VA_ARGS__)
+#define brcmf_err(pub, fmt, ...) \
+	__brcmf_err(pub, __func__, fmt, ##__VA_ARGS__)
 
 #if defined(DEBUG) || defined(CONFIG_BRCM_TRACING)
 __printf(3, 4)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c +1 -1
index c7c1e9906500..d1c0a215ef6e 100644
@@ -578,7 +578,7 @@ int brcmf_fw_map_chip_to_name(u32 chip, u32 chiprev,
 	}
 
 	if (i == table_size) {
-		brcmf_err("Unknown chipid %d [%d]\n", chip, chiprev);
+		brcmf_err(NULL, "Unknown chipid %d [%d]\n", chip, chiprev);
 		return -ENODEV;
 	}
 
drivers/net/wireless/broadcom/brcm80211/brcmfmac/flowring.c +1 -1
index d0b738da2458..a101850e7ce3 100644
@@ -343,7 +343,7 @@ void brcmf_flowring_open(struct brcmf_flowring *flow, u16 flowid)
 
 	ring = flow->rings[flowid];
 	if (!ring) {
-		brcmf_err("Ring NULL, for flowid %d\n", flowid);
+		brcmf_err(NULL, "Ring NULL, for flowid %d\n", flowid);
 		return;
 	}
 
drivers/net/wireless/broadcom/brcm80211/brcmfmac/fweh.c +9 -7
index c79306b57532..6d27c1026393 100644
@@ -107,6 +107,7 @@ static int brcmf_fweh_call_event_handler(struct brcmf_if *ifp,
 					 struct brcmf_event_msg *emsg,
 					 void *data)
 {
+	struct brcmf_pub *pub = ifp->drvr;
 	struct brcmf_fweh_info *fweh;
 	int err = -EINVAL;
 
@@ -117,9 +118,9 @@ static int brcmf_fweh_call_event_handler(struct brcmf_if *ifp,
 		if (fweh->evt_handler[code])
 			err = fweh->evt_handler[code](ifp, emsg, data);
 		else
-			brcmf_err("unhandled event %d ignored\n", code);
+			brcmf_err(pub, "unhandled event %d ignored\n", code);
 	} else {
-		brcmf_err("no interface object\n");
+		brcmf_err(pub, "no interface object\n");
 	}
 	return err;
 }
@@ -158,7 +159,8 @@ static void brcmf_fweh_handle_if_event(struct brcmf_pub *drvr,
 		return;
 	}
 	if (ifevent->ifidx >= BRCMF_MAX_IFS) {
-		brcmf_err("invalid interface index: %u\n", ifevent->ifidx);
+		brcmf_err(drvr, "invalid interface index: %u\n",
+			  ifevent->ifidx);
 		return;
 	}
 
@@ -258,7 +260,7 @@ static void brcmf_fweh_event_worker(struct work_struct *work)
 				   min_t(u32, emsg.datalen, 64),
 				   "event payload, len=%d\n", emsg.datalen);
 		if (emsg.datalen > event->datalen) {
-			brcmf_err("event invalid length header=%d, msg=%d\n",
+			brcmf_err(drvr, "event invalid length header=%d, msg=%d\n",
 				  event->datalen, emsg.datalen);
 			goto event_free;
 		}
@@ -276,7 +278,7 @@ static void brcmf_fweh_event_worker(struct work_struct *work)
 		err = brcmf_fweh_call_event_handler(ifp, event->code, &emsg,
 						    event->data);
 		if (err) {
-			brcmf_err("event handler failed (%d)\n",
+			brcmf_err(drvr, "event handler failed (%d)\n",
 				  event->code);
 			err = 0;
 		}
@@ -344,7 +346,7 @@ int brcmf_fweh_register(struct brcmf_pub *drvr, enum brcmf_fweh_event_code code,
 			brcmf_fweh_handler_t handler)
 {
 	if (drvr->fweh.evt_handler[code]) {
-		brcmf_err("event code %d already registered\n", code);
+		brcmf_err(drvr, "event code %d already registered\n", code);
 		return -ENOSPC;
 	}
 	drvr->fweh.evt_handler[code] = handler;
@@ -393,7 +395,7 @@ int brcmf_fweh_activate_events(struct brcmf_if *ifp)
 	err = brcmf_fil_iovar_data_set(ifp, "event_msgs",
 				       eventmask, BRCMF_EVENTING_MASK_LEN);
 	if (err)
-		brcmf_err("Set event_msgs error (%d)\n", err);
+		brcmf_err(ifp->drvr, "Set event_msgs error (%d)\n", err);
 
 	return err;
 }
drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil.c +6 -6
index f6a2df94dba7..b2adf08aee1e 100644
@@ -110,7 +110,7 @@ brcmf_fil_cmd_data(struct brcmf_if *ifp, u32 cmd, void *data, u32 len, bool set)
 	s32 err;
 
 	if (drvr->bus_if->state != BRCMF_BUS_UP) {
-		brcmf_err("bus is down. we have nothing to do.\n");
+		brcmf_err(drvr, "bus is down. we have nothing to do.\n");
 		return -EIO;
 	}
 
@@ -236,7 +236,7 @@ brcmf_fil_iovar_data_set(struct brcmf_if *ifp, char *name, const void *data,
 					 buflen, true);
 	} else {
 		err = -EPERM;
-		brcmf_err("Creating iovar failed\n");
+		brcmf_err(drvr, "Creating iovar failed\n");
 	}
 
 	mutex_unlock(&drvr->proto_block);
@@ -262,7 +262,7 @@ brcmf_fil_iovar_data_get(struct brcmf_if *ifp, char *name, void *data,
 			memcpy(data, drvr->proto_buf, len);
 	} else {
 		err = -EPERM;
-		brcmf_err("Creating iovar failed\n");
+		brcmf_err(drvr, "Creating iovar failed\n");
 	}
 
 	brcmf_dbg(FIL, "ifidx=%d, name=%s, len=%d\n", ifp->ifidx, name, len);
@@ -312,7 +312,7 @@ brcmf_create_bsscfg(s32 bsscfgidx, char *name, char *data, u32 datalen,
 	iolen = prefixlen + namelen + sizeof(bsscfgidx_le) + datalen;
 
 	if (buflen < iolen) {
-		brcmf_err("buffer is too short\n");
+		brcmf_err(NULL, "buffer is too short\n");
 		return 0;
 	}
 
@@ -360,7 +360,7 @@ brcmf_fil_bsscfg_data_set(struct brcmf_if *ifp, char *name,
 					 buflen, true);
 	} else {
 		err = -EPERM;
-		brcmf_err("Creating bsscfg failed\n");
+		brcmf_err(drvr, "Creating bsscfg failed\n");
 	}
 
 	mutex_unlock(&drvr->proto_block);
@@ -386,7 +386,7 @@ brcmf_fil_bsscfg_data_get(struct brcmf_if *ifp, char *name,
 			memcpy(data, drvr->proto_buf, len);
 	} else {
 		err = -EPERM;
-		brcmf_err("Creating bsscfg failed\n");
+		brcmf_err(drvr, "Creating bsscfg failed\n");
 	}
 	brcmf_dbg(FIL, "ifidx=%d, bsscfgidx=%d, name=%s, len=%d\n", ifp->ifidx,
 		  ifp->bsscfgidx, name, len);
drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.c +24 -19

174 lines not on this page · raw message

drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.c +34 -24

128 lines not on this page · raw message

drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c +1 -1
index aee6e5937c41..9fa9da87e93a 100644

Lines of this file are not shown. View the raw message.

drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c +48 -32

80 lines not on this page · raw message

drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c +26 -16

42 lines not on this page · raw message

drivers/net/wireless/broadcom/brcm80211/brcmfmac/pno.c +12 -8
index 9a25e79a46cf..532cdcc0fbbd 100644

Lines of this file are not shown. View the raw message.

drivers/net/wireless/broadcom/brcm80211/brcmfmac/proto.c +2 -2
index d26ff219ef66..a9a2ebb0a155 100644

Lines of this file are not shown. View the raw message.

drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c +121 -92

213 lines not on this page · raw message

drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c +41 -29

70 lines not on this page · raw message

drivers/net/wireless/broadcom/brcm80211/brcmfmac/vendor.c +10 -7
index 8eff2753abad..b992234a0dee 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.11.0

Part of the diff is not shown here. View the raw message.

#6 lore raw

PATCH v2 7/7 brcmfmac: use dev_err to print errors

In reply to Rafał Miłecki

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

This adds a nice prefix to all error messages making it possible to identify device they are related to. It's really useful for e.g. home routers commonly having 2 or even 3 wireless devices.

---
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c     | 3 ++-
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/tracepoint.c | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c +2 -1
index 9ad9bd652ca2..28b08cba7dbe 100644
@@ -223,6 +223,7 @@ int brcmf_c_preinit_dcmds(struct brcmf_if *ifp)
 #ifndef CONFIG_BRCM_TRACING
 void __brcmf_err(struct brcmf_pub *pub, const char *func, const char *fmt, ...)
 {
+	struct device *dev = pub && pub->bus_if ? pub->bus_if->dev : NULL;
 	struct va_format vaf;
 	va_list args;
 
@@ -233,7 +234,7 @@ void __brcmf_err(struct brcmf_pub *pub, const char *func, const char *fmt, ...)
 
 	vaf.fmt = fmt;
 	vaf.va = &args;
-	pr_err("%s: %pV", func, &vaf);
+	dev_err(dev, "%s: %pV", func, &vaf);
 
 	va_end(args);
 }
drivers/net/wireless/broadcom/brcm80211/brcmfmac/tracepoint.c +2 -1
index 329cb65eb78b..393c1b31ed28 100644
@@ -25,6 +25,7 @@
 
 void __brcmf_err(struct brcmf_pub *pub, const char *func, const char *fmt, ...)
 {
+	struct device *dev = pub && pub->bus_if ? pub->bus_if->dev : NULL;
 	struct va_format vaf = {
 		.fmt = fmt,
 	};
@@ -32,7 +33,7 @@ void __brcmf_err(struct brcmf_pub *pub, const char *func, const char *fmt, ...)
 
 	va_start(args, fmt);
 	vaf.va = &args;
-	pr_err("%s: %pV", func, &vaf);
+	dev_err(dev, "%s: %pV", func, &vaf);
 	trace_brcmf_err(func, &vaf);
 	va_end(args);
 }
Signature · 1 line
2.11.0
#7 lore raw
In reply to Rafał Miłecki
Quoted 19 lines · Rafał Miłecki

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

This will allow extending code and using more detailed messages e.g. with the help of dev_err. Note that *two separated* brcmf_err macros were replaced thanks to using a simple CONFIG_BRCMDBG symbol check in the body.

---
 .../net/wireless/broadcom/brcm80211/brcmfmac/common.c | 19 +++++++++++++++++++
 .../net/wireless/broadcom/brcm80211/brcmfmac/debug.h  | 16 ----------------
 2 files changed, 19 insertions(+), 16 deletions(-)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c +0 -0
index f7c8c2e80349..05fb778ddd0f 100644
@@ -218,6 +218,25 @@ int brcmf_c_preinit_dcmds(struct brcmf_if *ifp)
 	return err;

drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c int brcmf_c_preinit_dcmds(struct brcmf_if *ifp) · line 228

Quoted 10 lines
drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c +8 -0
 }
 
+#ifndef CONFIG_BRCM_TRACING
+void __brcmf_err(const char *func, const char *fmt, ...)
+{
+	struct va_format vaf;
+	va_list args;
+
+	if (!net_ratelimit() && !IS_ENABLED(CONFIG_BRCMDBG))
+		return;

The IS_ENABLED must not come after net_ratelimit, because net_ratelimit has side effects.
Also, please keep the IS_ENABLED(CONFIG_BRCMDBG) check inline, since it's a compile-time check, and that allows gcc to skip unnecessary calls when disabled.

- Felix