[PATCH] staging: brcm80211: brcmfmac: Add and use dhd_dbg

Joe Perches joe at perches.com
Thu Apr 28 18:46:42 UTC 2011


All uses of DHD_<TYPE> macros are for debugging only.

Change the multiple uses of DHD_<TYPE>((...)) to dhd_dbg(TYPE, ...)
for a more consistent style.

Remove unnecessary parentheses from uses.
Coalesce long formats.
Add a few missing newlines.
Use print_hex_dump_bytes where appropriate.
Add KERN_DEBUG prefix to debug message output.
Remove internal single line string concatenations.
Use __func__ a few places instead of hard strings.
Reduced indent in one case label.
Fix compilation error when !BCMDBG

Signed-off-by: Joe Perches <joe at perches.com>
---
 drivers/staging/brcm80211/brcmfmac/dhd_cdc.c    |   68 +-
 drivers/staging/brcm80211/brcmfmac/dhd_common.c |  437 +++++-----
 drivers/staging/brcm80211/brcmfmac/dhd_dbg.h    |   54 +-
 drivers/staging/brcm80211/brcmfmac/dhd_linux.c  |  254 +++---
 drivers/staging/brcm80211/brcmfmac/dhd_sdio.c   | 1131 ++++++++++++-----------
 5 files changed, 1005 insertions(+), 939 deletions(-)

diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_cdc.c b/drivers/staging/brcm80211/brcmfmac/dhd_cdc.c
index 39a4d00..f0b0c12 100644
--- a/drivers/staging/brcm80211/brcmfmac/dhd_cdc.c
+++ b/drivers/staging/brcm80211/brcmfmac/dhd_cdc.c
@@ -65,7 +65,7 @@ static int dhdcdc_msg(dhd_pub_t *dhd)
 	dhd_prot_t *prot = dhd->prot;
 	int len = le32_to_cpu(prot->msg.len) + sizeof(cdc_ioctl_t);
 
-	DHD_TRACE(("%s: Enter\n", __func__));
+	dhd_dbg(TRACE, "%s: Enter\n", __func__);
 
 	/* NOTE : cdc->msg.len holds the desired length of the buffer to be
 	 *        returned. Only up to CDC_MAX_MSG_SIZE of this buffer area
@@ -83,7 +83,7 @@ static int dhdcdc_cmplt(dhd_pub_t *dhd, u32 id, u32 len)
 	int ret;
 	dhd_prot_t *prot = dhd->prot;
 
-	DHD_TRACE(("%s: Enter\n", __func__));
+	dhd_dbg(TRACE, "%s: Enter\n", __func__);
 
 	do {
 		ret =
@@ -105,8 +105,8 @@ dhdcdc_query_ioctl(dhd_pub_t *dhd, int ifidx, uint cmd, void *buf, uint len)
 	int ret = 0, retries = 0;
 	u32 id, flags = 0;
 
-	DHD_TRACE(("%s: Enter\n", __func__));
-	DHD_CTL(("%s: cmd %d len %d\n", __func__, cmd, len));
+	dhd_dbg(TRACE, "%s: Enter\n", __func__);
+	dhd_dbg(CTL, "%s: cmd %d len %d\n", __func__, cmd, len);
 
 	/* Respond "bcmerror" and "bcmerrorstr" with local cache */
 	if (cmd == WLC_GET_VAR && buf) {
@@ -133,8 +133,8 @@ dhdcdc_query_ioctl(dhd_pub_t *dhd, int ifidx, uint cmd, void *buf, uint len)
 
 	ret = dhdcdc_msg(dhd);
 	if (ret < 0) {
-		DHD_ERROR(("dhdcdc_query_ioctl: dhdcdc_msg failed w/status "
-			"%d\n", ret));
+		dhd_dbg(ERROR, "%s: dhdcdc_msg failed w/status %d\n",
+			__func__, ret);
 		goto done;
 	}
 
@@ -150,8 +150,9 @@ retry:
 	if ((id < prot->reqid) && (++retries < RETRIES))
 		goto retry;
 	if (id != prot->reqid) {
-		DHD_ERROR(("%s: %s: unexpected request id %d (expected %d)\n",
-			   dhd_ifname(dhd, ifidx), __func__, id, prot->reqid));
+		dhd_dbg(ERROR,
+			"%s: %s: unexpected request id %d (expected %d)\n",
+			dhd_ifname(dhd, ifidx), __func__, id, prot->reqid);
 		ret = -EINVAL;
 		goto done;
 	}
@@ -184,8 +185,8 @@ int dhdcdc_set_ioctl(dhd_pub_t *dhd, int ifidx, uint cmd, void *buf, uint len)
 	int ret = 0;
 	u32 flags, id;
 
-	DHD_TRACE(("%s: Enter\n", __func__));
-	DHD_CTL(("%s: cmd %d len %d\n", __func__, cmd, len));
+	dhd_dbg(TRACE, "%s: Enter\n", __func__);
+	dhd_dbg(CTL, "%s: cmd %d len %d\n", __func__, cmd, len);
 
 	memset(msg, 0, sizeof(cdc_ioctl_t));
 
@@ -210,8 +211,9 @@ int dhdcdc_set_ioctl(dhd_pub_t *dhd, int ifidx, uint cmd, void *buf, uint len)
 	id = (flags & CDCF_IOC_ID_MASK) >> CDCF_IOC_ID_SHIFT;
 
 	if (id != prot->reqid) {
-		DHD_ERROR(("%s: %s: unexpected request id %d (expected %d)\n",
-			   dhd_ifname(dhd, ifidx), __func__, id, prot->reqid));
+		dhd_dbg(ERROR,
+			"%s: %s: unexpected request id %d (expected %d)\n",
+			dhd_ifname(dhd, ifidx), __func__, id, prot->reqid);
 		ret = -EINVAL;
 		goto done;
 	}
@@ -235,13 +237,13 @@ dhd_prot_ioctl(dhd_pub_t *dhd, int ifidx, wl_ioctl_t *ioc, void *buf, int len)
 	int ret = -1;
 
 	if (dhd->busstate == DHD_BUS_DOWN) {
-		DHD_ERROR(("%s : bus is down. we have nothing to do\n",
-			   __func__));
+		dhd_dbg(ERROR, "%s : bus is down. we have nothing to do\n",
+			__func__);
 		return ret;
 	}
 	dhd_os_proto_block(dhd);
 
-	DHD_TRACE(("%s: Enter\n", __func__));
+	dhd_dbg(TRACE, "%s: Enter\n", __func__);
 
 	ASSERT(len <= WLC_IOCTL_MAXLEN);
 
@@ -249,12 +251,12 @@ dhd_prot_ioctl(dhd_pub_t *dhd, int ifidx, wl_ioctl_t *ioc, void *buf, int len)
 		goto done;
 
 	if (prot->pending == true) {
-		DHD_TRACE(("CDC packet is pending!!!! cmd=0x%x (%lu) "
-			"lastcmd=0x%x (%lu)\n",
+		dhd_dbg(TRACE,
+			"CDC packet is pending!!!! cmd=0x%x (%lu) lastcmd=0x%x (%lu)\n",
 			ioc->cmd, (unsigned long)ioc->cmd, prot->lastcmd,
-			(unsigned long)prot->lastcmd));
+			(unsigned long)prot->lastcmd);
 		if ((ioc->cmd == WLC_SET_VAR) || (ioc->cmd == WLC_GET_VAR)) {
-			DHD_TRACE(("iovar cmd=%s\n", (char *)buf));
+			dhd_dbg(TRACE, "iovar cmd=%s\n", (char *)buf);
 		}
 		goto done;
 	}
@@ -323,7 +325,7 @@ void dhd_prot_hdrpush(dhd_pub_t *dhd, int ifidx, struct sk_buff *pktbuf)
 	struct bdc_header *h;
 #endif				/* BDC */
 
-	DHD_TRACE(("%s: Enter\n", __func__));
+	dhd_dbg(TRACE, "%s: Enter\n", __func__);
 
 #ifdef BDC
 	/* Push BDC header used to convey priority for buses that don't */
@@ -349,14 +351,14 @@ int dhd_prot_hdrpull(dhd_pub_t *dhd, int *ifidx, struct sk_buff *pktbuf)
 	struct bdc_header *h;
 #endif
 
-	DHD_TRACE(("%s: Enter\n", __func__));
+	dhd_dbg(TRACE, "%s: Enter\n", __func__);
 
 #ifdef BDC
 	/* Pop BDC header used to convey priority for buses that don't */
 
 	if (pktbuf->len < BDC_HEADER_LEN) {
-		DHD_ERROR(("%s: rx data too short (%d < %d)\n", __func__,
-			   pktbuf->len, BDC_HEADER_LEN));
+		dhd_dbg(ERROR, "%s: rx data too short (%d < %d)\n",
+			__func__, pktbuf->len, BDC_HEADER_LEN);
 		return BCME_ERROR;
 	}
 
@@ -364,22 +366,22 @@ int dhd_prot_hdrpull(dhd_pub_t *dhd, int *ifidx, struct sk_buff *pktbuf)
 
 	*ifidx = BDC_GET_IF_IDX(h);
 	if (*ifidx >= DHD_MAX_IFS) {
-		DHD_ERROR(("%s: rx data ifnum out of range (%d)\n",
-			   __func__, *ifidx));
+		dhd_dbg(ERROR, "%s: rx data ifnum out of range (%d)\n",
+			__func__, *ifidx);
 		return BCME_ERROR;
 	}
 
 	if (((h->flags & BDC_FLAG_VER_MASK) >> BDC_FLAG_VER_SHIFT) !=
 	    BDC_PROTO_VER) {
-		DHD_ERROR(("%s: non-BDC packet received, flags 0x%x\n",
-			   dhd_ifname(dhd, *ifidx), h->flags));
+		dhd_dbg(ERROR, "%s: non-BDC packet received, flags 0x%x\n",
+			dhd_ifname(dhd, *ifidx), h->flags);
 		return BCME_ERROR;
 	}
 
 	if (h->flags & BDC_FLAG_SUM_GOOD) {
-		DHD_INFO(("%s: BDC packet received with good rx-csum, "
-			"flags 0x%x\n",
-			dhd_ifname(dhd, *ifidx), h->flags));
+		dhd_dbg(INFO,
+			"%s: BDC packet received with good rx-csum, flags 0x%x\n",
+			dhd_ifname(dhd, *ifidx), h->flags);
 		PKTSETSUMGOOD(pktbuf, true);
 	}
 
@@ -397,13 +399,13 @@ int dhd_prot_attach(dhd_pub_t *dhd)
 
 	cdc = kzalloc(sizeof(dhd_prot_t), GFP_ATOMIC);
 	if (!cdc) {
-		DHD_ERROR(("%s: kmalloc failed\n", __func__));
+		dhd_dbg(ERROR, "%s: kmalloc failed\n", __func__);
 		goto fail;
 	}
 
 	/* ensure that the msg buf directly follows the cdc msg struct */
 	if ((unsigned long)(&cdc->msg + 1) != (unsigned long)cdc->buf) {
-		DHD_ERROR(("dhd_prot_t is not correctly defined\n"));
+		dhd_dbg(ERROR, "dhd_prot_t is not correctly defined\n");
 		goto fail;
 	}
 
@@ -443,7 +445,7 @@ int dhd_prot_init(dhd_pub_t *dhd)
 	int ret = 0;
 	char buf[128];
 
-	DHD_TRACE(("%s: Enter\n", __func__));
+	dhd_dbg(TRACE, "%s: Enter\n", __func__);
 
 	dhd_os_proto_block(dhd);
 
diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_common.c b/drivers/staging/brcm80211/brcmfmac/dhd_common.c
index 7d349b7..b8e062c 100644
--- a/drivers/staging/brcm80211/brcmfmac/dhd_common.c
+++ b/drivers/staging/brcm80211/brcmfmac/dhd_common.c
@@ -200,7 +200,7 @@ dhd_doiovar(dhd_pub_t *dhd_pub, const bcm_iovar_t *vi, u32 actionid,
 	int bcmerror = 0;
 	s32 int_val = 0;
 
-	DHD_TRACE(("%s: Enter\n", __func__));
+	dhd_dbg(TRACE, "%s: Enter\n", __func__);
 
 	bcmerror = bcm_iovar_lencheck(vi, arg, len, IOV_ISSET(actionid));
 	if (bcmerror != 0)
@@ -341,8 +341,8 @@ bool dhd_prec_enq(dhd_pub_t *dhdp, struct pktq *q, struct sk_buff *pkt,
 		p = discard_oldest ? pktq_pdeq(q, eprec) : pktq_pdeq_tail(q,
 						  eprec);
 		if (p == NULL) {
-			DHD_ERROR(("%s: pktq_penq() failed, oldest %d.",
-				   __func__, discard_oldest));
+			dhd_dbg(ERROR, "%s: pktq_penq() failed, oldest %d\n",
+				__func__, discard_oldest);
 			ASSERT(p);
 		}
 
@@ -352,7 +352,7 @@ bool dhd_prec_enq(dhd_pub_t *dhdp, struct pktq *q, struct sk_buff *pkt,
 	/* Enqueue */
 	p = pktq_penq(q, prec, pkt);
 	if (p == NULL) {
-		DHD_ERROR(("%s: pktq_penq() failed.", __func__));
+		dhd_dbg(ERROR, "%s: pktq_penq() failed\n", __func__);
 		ASSERT(p);
 	}
 
@@ -368,7 +368,7 @@ dhd_iovar_op(dhd_pub_t *dhd_pub, const char *name,
 	const bcm_iovar_t *vi = NULL;
 	u32 actionid;
 
-	DHD_TRACE(("%s: Enter\n", __func__));
+	dhd_dbg(TRACE, "%s: Enter\n", __func__);
 
 	ASSERT(name);
 	ASSERT(len >= 0);
@@ -385,8 +385,8 @@ dhd_iovar_op(dhd_pub_t *dhd_pub, const char *name,
 		goto exit;
 	}
 
-	DHD_CTL(("%s: %s %s, len %d plen %d\n", __func__,
-		 name, (set ? "set" : "get"), len, plen));
+	dhd_dbg(CTL, "%s: %s %s, len %d plen %d\n",
+		__func__, name, (set ? "set" : "get"), len, plen);
 
 	/* set up 'params' pointer in case this is a set command so that
 	 * the convenience int and bool code can be common to set and get
@@ -417,7 +417,7 @@ int dhd_ioctl(dhd_pub_t *dhd_pub, dhd_ioctl_t *ioc, void *buf, uint buflen)
 {
 	int bcmerror = 0;
 
-	DHD_TRACE(("%s: Enter\n", __func__));
+	dhd_dbg(TRACE, "%s: Enter\n", __func__);
 
 	if (!buf)
 		return BCME_BADARG;
@@ -585,7 +585,7 @@ static void wl_show_host_event(wl_event_msg_t *event, void *event_data)
 			event_name = event_names[i].event_name;
 	}
 
-	DHD_EVENT(("EVENT: %s, event ID = %d\n", event_name, event_type));
+	dhd_dbg(EVENT, "EVENT: %s, event ID = %d\n", event_name, event_type);
 
 	if (flags & WLC_EVENT_MSG_LINK)
 		link = true;
@@ -598,35 +598,37 @@ static void wl_show_host_event(wl_event_msg_t *event, void *event_data)
 	case WLC_E_START:
 	case WLC_E_DEAUTH:
 	case WLC_E_DISASSOC:
-		DHD_EVENT(("MACEVENT: %s, MAC %s\n", event_name, eabuf));
+		dhd_dbg(EVENT, "MACEVENT: %s, MAC %s\n", event_name, eabuf);
 		break;
 
 	case WLC_E_ASSOC_IND:
 	case WLC_E_REASSOC_IND:
-		DHD_EVENT(("MACEVENT: %s, MAC %s\n", event_name, eabuf));
+		dhd_dbg(EVENT, "MACEVENT: %s, MAC %s\n", event_name, eabuf);
 		break;
 
 	case WLC_E_ASSOC:
 	case WLC_E_REASSOC:
 		if (status == WLC_E_STATUS_SUCCESS) {
-			DHD_EVENT(("MACEVENT: %s, MAC %s, SUCCESS\n",
-				   event_name, eabuf));
+			dhd_dbg(EVENT, "MACEVENT: %s, MAC %s, SUCCESS\n",
+				event_name, eabuf);
 		} else if (status == WLC_E_STATUS_TIMEOUT) {
-			DHD_EVENT(("MACEVENT: %s, MAC %s, TIMEOUT\n",
-				   event_name, eabuf));
+			dhd_dbg(EVENT, "MACEVENT: %s, MAC %s, TIMEOUT\n",
+				event_name, eabuf);
 		} else if (status == WLC_E_STATUS_FAIL) {
-			DHD_EVENT(("MACEVENT: %s, MAC %s, FAILURE, reason %d\n",
-				   event_name, eabuf, (int)reason));
+			dhd_dbg(EVENT,
+				"MACEVENT: %s, MAC %s, FAILURE, reason %d\n",
+				event_name, eabuf, (int)reason);
 		} else {
-			DHD_EVENT(("MACEVENT: %s, MAC %s, unexpected status "
-				"%d\n", event_name, eabuf, (int)status));
+			dhd_dbg(EVENT,
+				"MACEVENT: %s, MAC %s, unexpected status %d\n",
+				event_name, eabuf, (int)status);
 		}
 		break;
 
 	case WLC_E_DEAUTH_IND:
 	case WLC_E_DISASSOC_IND:
-		DHD_EVENT(("MACEVENT: %s, MAC %s, reason %d\n", event_name,
-			   eabuf, (int)reason));
+		dhd_dbg(EVENT, "MACEVENT: %s, MAC %s, reason %d\n",
+			event_name, eabuf, (int)reason);
 		break;
 
 	case WLC_E_AUTH:
@@ -640,18 +642,18 @@ static void wl_show_host_event(wl_event_msg_t *event, void *event_data)
 			auth_str = err_msg;
 		}
 		if (event_type == WLC_E_AUTH_IND) {
-			DHD_EVENT(("MACEVENT: %s, MAC %s, %s\n", event_name,
-				   eabuf, auth_str));
+			dhd_dbg(EVENT, "MACEVENT: %s, MAC %s, %s\n",
+				event_name, eabuf, auth_str);
 		} else if (status == WLC_E_STATUS_SUCCESS) {
-			DHD_EVENT(("MACEVENT: %s, MAC %s, %s, SUCCESS\n",
-				   event_name, eabuf, auth_str));
+			dhd_dbg(EVENT, "MACEVENT: %s, MAC %s, %s, SUCCESS\n",
+				event_name, eabuf, auth_str);
 		} else if (status == WLC_E_STATUS_TIMEOUT) {
-			DHD_EVENT(("MACEVENT: %s, MAC %s, %s, TIMEOUT\n",
-				   event_name, eabuf, auth_str));
+			dhd_dbg(EVENT, "MACEVENT: %s, MAC %s, %s, TIMEOUT\n",
+				event_name, eabuf, auth_str);
 		} else if (status == WLC_E_STATUS_FAIL) {
-			DHD_EVENT(("MACEVENT: %s, MAC %s, %s, FAILURE, "
-				"reason %d\n",
-				event_name, eabuf, auth_str, (int)reason));
+			dhd_dbg(EVENT,
+				"MACEVENT: %s, MAC %s, %s, FAILURE, reason %d\n",
+				event_name, eabuf, auth_str, (int)reason);
 		}
 
 		break;
@@ -660,145 +662,138 @@ static void wl_show_host_event(wl_event_msg_t *event, void *event_data)
 	case WLC_E_ROAM:
 	case WLC_E_SET_SSID:
 		if (status == WLC_E_STATUS_SUCCESS) {
-			DHD_EVENT(("MACEVENT: %s, MAC %s\n", event_name,
-				   eabuf));
+			dhd_dbg(EVENT, "MACEVENT: %s, MAC %s\n",
+				event_name, eabuf);
 		} else if (status == WLC_E_STATUS_FAIL) {
-			DHD_EVENT(("MACEVENT: %s, failed\n", event_name));
+			dhd_dbg(EVENT, "MACEVENT: %s, failed\n", event_name);
 		} else if (status == WLC_E_STATUS_NO_NETWORKS) {
-			DHD_EVENT(("MACEVENT: %s, no networks found\n",
-				   event_name));
+			dhd_dbg(EVENT, "MACEVENT: %s, no networks found\n",
+				event_name);
 		} else {
-			DHD_EVENT(("MACEVENT: %s, unexpected status %d\n",
-				   event_name, (int)status));
+			dhd_dbg(EVENT, "MACEVENT: %s, unexpected status %d\n",
+				event_name, (int)status);
 		}
 		break;
 
 	case WLC_E_BEACON_RX:
 		if (status == WLC_E_STATUS_SUCCESS) {
-			DHD_EVENT(("MACEVENT: %s, SUCCESS\n", event_name));
+			dhd_dbg(EVENT, "MACEVENT: %s, SUCCESS\n", event_name);
 		} else if (status == WLC_E_STATUS_FAIL) {
-			DHD_EVENT(("MACEVENT: %s, FAIL\n", event_name));
+			dhd_dbg(EVENT, "MACEVENT: %s, FAIL\n", event_name);
 		} else {
-			DHD_EVENT(("MACEVENT: %s, status %d\n", event_name,
-				   status));
+			dhd_dbg(EVENT, "MACEVENT: %s, status %d\n",
+				event_name, status);
 		}
 		break;
 
 	case WLC_E_LINK:
-		DHD_EVENT(("MACEVENT: %s %s\n", event_name,
-			   link ? "UP" : "DOWN"));
+		dhd_dbg(EVENT, "MACEVENT: %s %s\n",
+			event_name, link ? "UP" : "DOWN");
 		break;
 
 	case WLC_E_MIC_ERROR:
-		DHD_EVENT(("MACEVENT: %s, MAC %s, Group %d, Flush %d\n",
-			   event_name, eabuf, group, flush_txq));
+		dhd_dbg(EVENT, "MACEVENT: %s, MAC %s, Group %d, Flush %d\n",
+			event_name, eabuf, group, flush_txq);
 		break;
 
 	case WLC_E_ICV_ERROR:
 	case WLC_E_UNICAST_DECODE_ERROR:
 	case WLC_E_MULTICAST_DECODE_ERROR:
-		DHD_EVENT(("MACEVENT: %s, MAC %s\n", event_name, eabuf));
+		dhd_dbg(EVENT, "MACEVENT: %s, MAC %s\n", event_name, eabuf);
 		break;
 
 	case WLC_E_TXFAIL:
-		DHD_EVENT(("MACEVENT: %s, RA %s\n", event_name, eabuf));
+		dhd_dbg(EVENT, "MACEVENT: %s, RA %s\n", event_name, eabuf);
 		break;
 
 	case WLC_E_SCAN_COMPLETE:
 	case WLC_E_PMKID_CACHE:
-		DHD_EVENT(("MACEVENT: %s\n", event_name));
+		dhd_dbg(EVENT, "MACEVENT: %s\n", event_name);
 		break;
 
 	case WLC_E_PFN_NET_FOUND:
 	case WLC_E_PFN_NET_LOST:
 	case WLC_E_PFN_SCAN_COMPLETE:
-		DHD_EVENT(("PNOEVENT: %s\n", event_name));
+		dhd_dbg(EVENT, "PNOEVENT: %s\n", event_name);
 		break;
 
 	case WLC_E_PSK_SUP:
 	case WLC_E_PRUNE:
-		DHD_EVENT(("MACEVENT: %s, status %d, reason %d\n",
-			   event_name, (int)status, (int)reason));
+		dhd_dbg(EVENT, "MACEVENT: %s, status %d, reason %d\n",
+			event_name, (int)status, (int)reason);
 		break;
 
-	case WLC_E_TRACE:
-		{
-			static u32 seqnum_prev;
-			msgtrace_hdr_t hdr;
-			u32 nblost;
-			char *s, *p;
-
-			buf = (unsigned char *) event_data;
-			memcpy(&hdr, buf, MSGTRACE_HDRLEN);
-
-			if (hdr.version != MSGTRACE_VERSION) {
-				DHD_ERROR(
-				    ("\nMACEVENT: %s [unsupported version --> "
-				     "dhd version:%d dongle version:%d]\n",
-				     event_name, MSGTRACE_VERSION, hdr.version)
-				);
-				/* Reset datalen to avoid display below */
-				datalen = 0;
-				break;
-			}
-
-			/* There are 2 bytes available at the end of data */
-			buf[MSGTRACE_HDRLEN + be16_to_cpu(hdr.len)] = '\0';
-
-			if (be32_to_cpu(hdr.discarded_bytes)
-			    || be32_to_cpu(hdr.discarded_printf)) {
-				DHD_ERROR(
-				    ("\nWLC_E_TRACE: [Discarded traces in dongle -->"
-				     "discarded_bytes %d discarded_printf %d]\n",
-				     be32_to_cpu(hdr.discarded_bytes),
-				     be32_to_cpu(hdr.discarded_printf)));
-			}
+	case WLC_E_TRACE: {
+		static u32 seqnum_prev;
+		msgtrace_hdr_t hdr;
+		u32 nblost;
+		char *s, *p;
 
-			nblost = be32_to_cpu(hdr.seqnum) - seqnum_prev - 1;
-			if (nblost > 0) {
-				DHD_ERROR(
-				    ("\nWLC_E_TRACE: [Event lost --> seqnum %d nblost %d\n",
-				     be32_to_cpu(hdr.seqnum), nblost));
-			}
-			seqnum_prev = be32_to_cpu(hdr.seqnum);
-
-			/* Display the trace buffer. Advance from \n to \n to
-			 * avoid display big
-			 * printf (issue with Linux printk )
-			 */
-			p = (char *)&buf[MSGTRACE_HDRLEN];
-			while ((s = strstr(p, "\n")) != NULL) {
-				*s = '\0';
-				printk(KERN_DEBUG"%s\n", p);
-				p = s + 1;
-			}
-			printk(KERN_DEBUG "%s\n", p);
+		buf = (unsigned char *) event_data;
+		memcpy(&hdr, buf, MSGTRACE_HDRLEN);
 
+		if (hdr.version != MSGTRACE_VERSION) {
+			dhd_dbg(ERROR,
+				"MACEVENT: %s [unsupported version --> dhd version:%d dongle version:%d]\n",
+				event_name, MSGTRACE_VERSION, hdr.version);
 			/* Reset datalen to avoid display below */
 			datalen = 0;
+			break;
 		}
+
+		/* There are 2 bytes available at the end of data */
+		buf[MSGTRACE_HDRLEN + be16_to_cpu(hdr.len)] = '\0';
+
+		if (be32_to_cpu(hdr.discarded_bytes) ||
+		    be32_to_cpu(hdr.discarded_printf)) {
+			dhd_dbg(ERROR,
+				"WLC_E_TRACE: [Discarded traces in dongle --> discarded_bytes %d discarded_printf %d]\n",
+				be32_to_cpu(hdr.discarded_bytes),
+				be32_to_cpu(hdr.discarded_printf));
+		}
+
+		nblost = be32_to_cpu(hdr.seqnum) - seqnum_prev - 1;
+		if (nblost > 0) {
+			dhd_dbg(ERROR,
+				"WLC_E_TRACE: [Event lost --> seqnum %d nblost %d\n",
+				be32_to_cpu(hdr.seqnum), nblost);
+		}
+		seqnum_prev = be32_to_cpu(hdr.seqnum);
+
+		/* Display the trace buffer. Advance from \n to \n to
+		 * avoid display big
+		 * printf (issue with Linux printk )
+		 */
+		p = (char *)&buf[MSGTRACE_HDRLEN];
+		while ((s = strstr(p, "\n")) != NULL) {
+			*s = '\0';
+			printk(KERN_DEBUG "%s\n", p);
+			p = s + 1;
+		}
+		printk(KERN_DEBUG "%s\n", p);
+
+		/* Reset datalen to avoid display below */
+		datalen = 0;
 		break;
+	}
 
 	case WLC_E_RSSI:
-		DHD_EVENT(("MACEVENT: %s %d\n", event_name,
-			   be32_to_cpu(*((int *)event_data))));
+		dhd_dbg(EVENT, "MACEVENT: %s %d\n", event_name,
+			be32_to_cpu(*((int *)event_data)));
 		break;
 
 	default:
-		DHD_EVENT(("MACEVENT: %s %d, MAC %s, status %d, reason %d, "
-			"auth %d\n", event_name, event_type, eabuf,
-			(int)status, (int)reason, (int)auth_type));
+		dhd_dbg(EVENT,
+			"MACEVENT: %s %d, MAC %s, status %d, reason %d, auth %d\n",
+			event_name, event_type, eabuf,
+			(int)status, (int)reason, (int)auth_type);
 		break;
 	}
 
 	/* show any appended data */
-	if (datalen) {
-		buf = (unsigned char *) event_data;
-		DHD_EVENT((" data (%d) : ", datalen));
-		for (i = 0; i < datalen; i++)
-			DHD_EVENT((" 0x%02x ", *buf++));
-		DHD_EVENT(("\n"));
-	}
+	if (datalen && (dhd_msg_level & DHD_ERROR_VAL))
+		print_hex_dump_bytes("Event data: ", DUMP_PREFIX_OFFSET,
+				     event_data, datalen);
 }
 #endif				/* SHOW_EVENTS */
 
@@ -814,14 +809,14 @@ wl_host_event(struct dhd_info *dhd, int *ifidx, void *pktdata,
 	int evlen;
 
 	if (memcmp(BRCM_OUI, &pvt_data->bcm_hdr.oui[0], DOT11_OUI_LEN)) {
-		DHD_ERROR(("%s: mismatched OUI, bailing\n", __func__));
+		dhd_dbg(ERROR, "%s: mismatched OUI, bailing\n", __func__);
 		return BCME_ERROR;
 	}
 
 	/* BRCM event pkt may be unaligned - use xxx_ua to load user_subtype. */
 	if (get_unaligned_be16(&pvt_data->bcm_hdr.usr_subtype) !=
 	    BCMILCP_BCM_SUBTYPE_EVENT) {
-		DHD_ERROR(("%s: mismatched subtype, bailing\n", __func__));
+		dhd_dbg(ERROR, "%s: mismatched subtype, bailing\n", __func__);
 		return BCME_ERROR;
 	}
 
@@ -840,7 +835,7 @@ wl_host_event(struct dhd_info *dhd, int *ifidx, void *pktdata,
 	case WLC_E_IF:
 		{
 			dhd_if_event_t *ifevent = (dhd_if_event_t *) event_data;
-			DHD_TRACE(("%s: if event\n", __func__));
+			dhd_dbg(TRACE, "%s: if event\n", __func__);
 
 			if (ifevent->ifidx > 0 &&
 				 ifevent->ifidx < DHD_MAX_IFS) {
@@ -853,9 +848,9 @@ wl_host_event(struct dhd_info *dhd, int *ifidx, void *pktdata,
 				else
 					dhd_del_if(dhd, ifevent->ifidx);
 			} else {
-				DHD_ERROR(("%s: Invalid ifidx %d for %s\n",
+				dhd_dbg(ERROR, "%s: Invalid ifidx %d for %s\n",
 					   __func__, ifevent->ifidx,
-					   event->ifname));
+					event->ifname);
 			}
 		}
 		/* send up the if event: btamp user needs it */
@@ -881,15 +876,16 @@ wl_host_event(struct dhd_info *dhd, int *ifidx, void *pktdata,
 		*ifidx = dhd_ifname2idx(dhd, event->ifname);
 		/* push up to external supp/auth */
 		dhd_event(dhd, (char *)pvt_data, evlen, *ifidx);
-		DHD_TRACE(("%s: MAC event %d, flags %x, status %x\n",
-			   __func__, type, flags, status));
+		dhd_dbg(TRACE, "%s: MAC event %d, flags %x, status %x\n",
+			__func__, type, flags, status);
 
 		/* put it back to WLC_E_NDIS_LINK */
 		if (type == WLC_E_NDIS_LINK) {
 			u32 temp;
 
 			temp = get_unaligned_be32(&event->event_type);
-			DHD_TRACE(("Converted to WLC_E_LINK type %d\n", temp));
+			dhd_dbg(TRACE, "Converted to WLC_E_LINK type %d\n",
+				temp);
 
 			temp = be32_to_cpu(WLC_E_NDIS_LINK);
 			memcpy((void *)(&pvt_data->event.event_type), &temp,
@@ -910,12 +906,12 @@ static int wl_pattern_atoh(char *src, char *dst)
 {
 	int i;
 	if (strncmp(src, "0x", 2) != 0 && strncmp(src, "0X", 2) != 0) {
-		DHD_ERROR(("Mask invalid format. Needs to start with 0x\n"));
+		dhd_dbg(ERROR, "Mask invalid format. Needs to start with 0x\n");
 		return -1;
 	}
 	src = src + 2;		/* Skip past 0x */
 	if (strlen(src) % 2 != 0) {
-		DHD_ERROR(("Mask invalid format. Length must be even.\n"));
+		dhd_dbg(ERROR, "Mask invalid format. Length must be even.\n");
 		return -1;
 	}
 	for (i = 0; *src != '\0'; i++) {
@@ -945,7 +941,7 @@ dhd_pktfilter_offload_enable(dhd_pub_t *dhd, char *arg, int enable,
 
 	arg_save = kmalloc(strlen(arg) + 1, GFP_ATOMIC);
 	if (!arg_save) {
-		DHD_ERROR(("%s: kmalloc failed\n", __func__));
+		dhd_dbg(ERROR, "%s: kmalloc failed\n", __func__);
 		goto fail;
 	}
 	arg_org = arg_save;
@@ -955,7 +951,7 @@ dhd_pktfilter_offload_enable(dhd_pub_t *dhd, char *arg, int enable,
 
 	i = 0;
 	if (NULL == argv[i]) {
-		DHD_ERROR(("No args provided\n"));
+		dhd_dbg(ERROR, "No args provided\n");
 		goto fail;
 	}
 
@@ -980,11 +976,11 @@ dhd_pktfilter_offload_enable(dhd_pub_t *dhd, char *arg, int enable,
 	rc = dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, buf, buf_len);
 	rc = rc >= 0 ? 0 : rc;
 	if (rc)
-		DHD_TRACE(("%s: failed to add pktfilter %s, retcode = %d\n",
-			   __func__, arg, rc));
+		dhd_dbg(TRACE, "%s: failed to add pktfilter %s, retcode = %d\n",
+			__func__, arg, rc);
 	else
-		DHD_TRACE(("%s: successfully added pktfilter %s\n",
-			   __func__, arg));
+		dhd_dbg(TRACE, "%s: successfully added pktfilter %s\n",
+			__func__, arg);
 
 	/* Contorl the master mode */
 	bcm_mkiovar("pkt_filter_mode", (char *)&master_mode, 4, buf,
@@ -992,8 +988,8 @@ dhd_pktfilter_offload_enable(dhd_pub_t *dhd, char *arg, int enable,
 	rc = dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, buf, sizeof(buf));
 	rc = rc >= 0 ? 0 : rc;
 	if (rc)
-		DHD_TRACE(("%s: failed to add pktfilter %s, retcode = %d\n",
-			   __func__, arg, rc));
+		dhd_dbg(TRACE, "%s: failed to add pktfilter %s, retcode = %d\n",
+			__func__, arg, rc);
 
 fail:
 	kfree(arg_org);
@@ -1016,7 +1012,7 @@ void dhd_pktfilter_offload_set(dhd_pub_t *dhd, char *arg)
 
 	arg_save = kmalloc(strlen(arg) + 1, GFP_ATOMIC);
 	if (!arg_save) {
-		DHD_ERROR(("%s: kmalloc failed\n", __func__));
+		dhd_dbg(ERROR, "%s: kmalloc failed\n", __func__);
 		goto fail;
 	}
 
@@ -1024,15 +1020,15 @@ void dhd_pktfilter_offload_set(dhd_pub_t *dhd, char *arg)
 
 	buf = kmalloc(BUF_SIZE, GFP_ATOMIC);
 	if (!buf) {
-		DHD_ERROR(("%s: kmalloc failed\n", __func__));
+		dhd_dbg(ERROR, "%s: kmalloc failed\n", __func__);
 		goto fail;
 	}
 
 	memcpy(arg_save, arg, strlen(arg) + 1);
 
 	if (strlen(arg) > BUF_SIZE) {
-		DHD_ERROR(("Not enough buffer %d < %d\n", (int)strlen(arg),
-			   (int)sizeof(buf)));
+		dhd_dbg(ERROR, "Not enough buffer %d < %d\n",
+			(int)strlen(arg), (int)sizeof(buf));
 		goto fail;
 	}
 
@@ -1042,7 +1038,7 @@ void dhd_pktfilter_offload_set(dhd_pub_t *dhd, char *arg)
 
 	i = 0;
 	if (NULL == argv[i]) {
-		DHD_ERROR(("No args provided\n"));
+		dhd_dbg(ERROR, "No args provided\n");
 		goto fail;
 	}
 
@@ -1058,7 +1054,7 @@ void dhd_pktfilter_offload_set(dhd_pub_t *dhd, char *arg)
 	pkt_filter.id = simple_strtoul(argv[i], NULL, 0);
 
 	if (NULL == argv[++i]) {
-		DHD_ERROR(("Polarity not provided\n"));
+		dhd_dbg(ERROR, "Polarity not provided\n");
 		goto fail;
 	}
 
@@ -1066,7 +1062,7 @@ void dhd_pktfilter_offload_set(dhd_pub_t *dhd, char *arg)
 	pkt_filter.negate_match = simple_strtoul(argv[i], NULL, 0);
 
 	if (NULL == argv[++i]) {
-		DHD_ERROR(("Filter type not provided\n"));
+		dhd_dbg(ERROR, "Filter type not provided\n");
 		goto fail;
 	}
 
@@ -1074,7 +1070,7 @@ void dhd_pktfilter_offload_set(dhd_pub_t *dhd, char *arg)
 	pkt_filter.type = simple_strtoul(argv[i], NULL, 0);
 
 	if (NULL == argv[++i]) {
-		DHD_ERROR(("Offset not provided\n"));
+		dhd_dbg(ERROR, "Offset not provided\n");
 		goto fail;
 	}
 
@@ -1082,7 +1078,7 @@ void dhd_pktfilter_offload_set(dhd_pub_t *dhd, char *arg)
 	pkt_filter.u.pattern.offset = simple_strtoul(argv[i], NULL, 0);
 
 	if (NULL == argv[++i]) {
-		DHD_ERROR(("Bitmask not provided\n"));
+		dhd_dbg(ERROR, "Bitmask not provided\n");
 		goto fail;
 	}
 
@@ -1092,7 +1088,7 @@ void dhd_pktfilter_offload_set(dhd_pub_t *dhd, char *arg)
 		   (argv[i], (char *)pkt_filterp->u.pattern.mask_and_pattern);
 
 	if (NULL == argv[++i]) {
-		DHD_ERROR(("Pattern not provided\n"));
+		dhd_dbg(ERROR, "Pattern not provided\n");
 		goto fail;
 	}
 
@@ -1103,7 +1099,7 @@ void dhd_pktfilter_offload_set(dhd_pub_t *dhd, char *arg)
 				   mask_and_pattern[mask_size]);
 
 	if (mask_size != pattern_size) {
-		DHD_ERROR(("Mask and pattern not the same size\n"));
+		dhd_dbg(ERROR, "Mask and pattern not the same size\n");
 		goto fail;
 	}
 
@@ -1124,11 +1120,11 @@ void dhd_pktfilter_offload_set(dhd_pub_t *dhd, char *arg)
 	rc = rc >= 0 ? 0 : rc;
 
 	if (rc)
-		DHD_TRACE(("%s: failed to add pktfilter %s, retcode = %d\n",
-			   __func__, arg, rc));
+		dhd_dbg(TRACE, "%s: failed to add pktfilter %s, retcode = %d\n",
+			__func__, arg, rc);
 	else
-		DHD_TRACE(("%s: successfully added pktfilter %s\n",
-			   __func__, arg));
+		dhd_dbg(TRACE, "%s: successfully added pktfilter %s\n",
+			__func__, arg);
 
 fail:
 	kfree(arg_org);
@@ -1145,11 +1141,13 @@ void dhd_arp_offload_set(dhd_pub_t *dhd, int arp_mode)
 	retcode = dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, iovbuf, sizeof(iovbuf));
 	retcode = retcode >= 0 ? 0 : retcode;
 	if (retcode)
-		DHD_TRACE(("%s: failed to set ARP offload mode to 0x%x, "
-			"retcode = %d\n", __func__, arp_mode, retcode));
+		dhd_dbg(TRACE,
+			"%s: failed to set ARP offload mode to 0x%x, retcode = %d\n",
+			__func__, arp_mode, retcode);
 	else
-		DHD_TRACE(("%s: successfully set ARP offload mode to 0x%x\n",
-			   __func__, arp_mode));
+		dhd_dbg(TRACE,
+			"%s: successfully set ARP offload mode to 0x%x\n",
+			__func__, arp_mode);
 }
 
 void dhd_arp_offload_enable(dhd_pub_t *dhd, int arp_enable)
@@ -1161,11 +1159,12 @@ void dhd_arp_offload_enable(dhd_pub_t *dhd, int arp_enable)
 	retcode = dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, iovbuf, sizeof(iovbuf));
 	retcode = retcode >= 0 ? 0 : retcode;
 	if (retcode)
-		DHD_TRACE(("%s: failed to enabe ARP offload to %d, "
-			"retcode = %d\n", __func__, arp_enable, retcode));
+		dhd_dbg(TRACE,
+			"%s: failed to enabe ARP offload to %d, retcode = %d\n",
+			__func__, arp_enable, retcode);
 	else
-		DHD_TRACE(("%s: successfully enabed ARP offload to %d\n",
-			   __func__, arp_enable));
+		dhd_dbg(TRACE, "%s: successfully enabed ARP offload to %d\n",
+			__func__, arp_enable);
 }
 
 int dhd_preinit_ioctls(dhd_pub_t *dhd)
@@ -1200,8 +1199,8 @@ int dhd_preinit_ioctls(dhd_pub_t *dhd)
 			    buf, sizeof(buf));
 		ret = dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, buf, sizeof(buf));
 		if (ret < 0) {
-			DHD_ERROR(("%s: can't set MAC address , error=%d\n",
-				   __func__, ret));
+			dhd_dbg(ERROR, "%s: can't set MAC address , error=%d\n",
+				__func__, ret);
 		} else
 			memcpy(dhd->mac.octet, (void *)&ea_addr,
 			       ETH_ALEN);
@@ -1213,8 +1212,8 @@ int dhd_preinit_ioctls(dhd_pub_t *dhd)
 		if (dhdcdc_set_ioctl(dhd, 0, WLC_SET_COUNTRY,
 				     dhd->country_code,
 				     sizeof(dhd->country_code)) < 0) {
-			DHD_ERROR(("%s: country code setting failed\n",
-				   __func__));
+			dhd_dbg(ERROR, "%s: country code setting failed\n",
+				__func__);
 		}
 	}
 
@@ -1225,7 +1224,7 @@ int dhd_preinit_ioctls(dhd_pub_t *dhd)
 	dhdcdc_query_ioctl(dhd, 0, WLC_GET_VAR, buf, sizeof(buf));
 	strsep(&ptr, "\n");
 	/* Print fw version info */
-	DHD_ERROR(("Firmware version = %s\n", buf));
+	dhd_dbg(ERROR, "Firmware version = %s\n", buf);
 
 	/* Set PowerSave mode */
 	dhdcdc_set_ioctl(dhd, 0, WLC_SET_PM, (char *)&power_mode,
@@ -1312,13 +1311,13 @@ iscan_buf_t *dhd_iscan_allocate_buf(dhd_pub_t *dhd, iscan_buf_t **iscanbuf)
 	iscanbuf_alloc->next = NULL;
 	iscanbuf_head = *iscanbuf;
 
-	DHD_ISCAN(("%s: addr of allocated node = 0x%X"
-		   "addr of iscanbuf_head = 0x%X dhd = 0x%X\n",
-		   __func__, iscanbuf_alloc, iscanbuf_head, dhd));
+	dhd_dbg(ISCAN,
+		"%s: addr of allocated node = 0x%X addr of iscanbuf_head = 0x%X dhd = 0x%X\n",
+		__func__, iscanbuf_alloc, iscanbuf_head, dhd);
 
 	if (iscanbuf_head == NULL) {
 		*iscanbuf = iscanbuf_alloc;
-		DHD_ISCAN(("%s: Head is allocated\n", __func__));
+		dhd_dbg(ISCAN, "%s: Head is allocated\n", __func__);
 		goto fail;
 	}
 
@@ -1401,9 +1400,9 @@ int dhd_iscan_print_cache(iscan_buf_t *iscan_skip)
 			break;
 
 		if (results->version != WL_BSS_INFO_VERSION) {
-			DHD_ISCAN(("%s: results->version %d != "
-				"WL_BSS_INFO_VERSION\n",
-				__func__, results->version));
+			dhd_dbg(ISCAN,
+				"%s: results->version %d != WL_BSS_INFO_VERSION\n",
+				__func__, results->version);
 			goto done;
 		}
 
@@ -1412,11 +1411,9 @@ int dhd_iscan_print_cache(iscan_buf_t *iscan_skip)
 			if (!bi)
 				break;
 
-			DHD_ISCAN(("%s[%2.2d:%2.2d] %X:%X:%X:%X:%X:%X\n",
-				   iscan_cur != iscan_skip ? "BSS" : "bss", l,
-				   i, bi->BSSID.octet[0], bi->BSSID.octet[1],
-				   bi->BSSID.octet[2], bi->BSSID.octet[3],
-				   bi->BSSID.octet[4], bi->BSSID.octet[5]));
+			dhd_dbg(ISCAN, "%s[%2.2d:%2.2d] %pM\n",
+				iscan_cur != iscan_skip ? "BSS" : "bss", l, i,
+				bi->BSSID.octet);
 
 			bi = (wl_bss_info_t *)((unsigned long)bi + bi->length);
 		}
@@ -1444,9 +1441,7 @@ int dhd_iscan_delete_bss(void *dhdp, void *addr, iscan_buf_t *iscan_skip)
 	unsigned char *s_addr = addr;
 
 	dhd_iscan_lock();
-	DHD_ISCAN(("%s: BSS to remove %X:%X:%X:%X:%X:%X\n",
-		   __func__, s_addr[0], s_addr[1], s_addr[2],
-		   s_addr[3], s_addr[4], s_addr[5]));
+	dhd_dbg(ISCAN, "%s: BSS to remove %pM\n", __func__, s_addr);
 
 	iscan_cur = dhd_iscan_result_buf();
 
@@ -1461,9 +1456,9 @@ int dhd_iscan_delete_bss(void *dhdp, void *addr, iscan_buf_t *iscan_skip)
 				break;
 
 			if (results->version != WL_BSS_INFO_VERSION) {
-				DHD_ERROR(("%s: results->version %d != "
-					"WL_BSS_INFO_VERSION\n",
-					__func__, results->version));
+				dhd_dbg(ERROR,
+					"%s: results->version %d != WL_BSS_INFO_VERSION\n",
+					__func__, results->version);
 				goto done;
 			}
 
@@ -1472,14 +1467,11 @@ int dhd_iscan_delete_bss(void *dhdp, void *addr, iscan_buf_t *iscan_skip)
 				if (!bi)
 					break;
 
-				if (!memcmp
-				    (bi->BSSID.octet, addr, ETH_ALEN)) {
-					DHD_ISCAN(("%s: Del BSS[%2.2d:%2.2d] "
-					"%X:%X:%X:%X:%X:%X\n",
-					__func__, l, i, bi->BSSID.octet[0],
-					bi->BSSID.octet[1], bi->BSSID.octet[2],
-					bi->BSSID.octet[3], bi->BSSID.octet[4],
-					bi->BSSID.octet[5]));
+				if (!memcmp(bi->BSSID.octet, addr, ETH_ALEN)) {
+					dhd_dbg(ISCAN,
+						"%s: Del BSS[%2.2d:%2.2d] %pM\n",
+						__func__, l, i,
+						bi->BSSID.octet);
 
 					bi_new = bi;
 					bi = (wl_bss_info_t *)((unsigned long)
@@ -1496,14 +1488,10 @@ int dhd_iscan_delete_bss(void *dhdp, void *addr, iscan_buf_t *iscan_skip)
 
 					for (j = i; j < results->count; j++) {
 						if (bi && bi_new) {
-							DHD_ISCAN(("%s: Moved up BSS[%2.2d:%2.2d]" "%X:%X:%X:%X:%X:%X\n",
-							__func__, l, j,
-							bi->BSSID.octet[0],
-							bi->BSSID.octet[1],
-							bi->BSSID.octet[2],
-							bi->BSSID.octet[3],
-							bi->BSSID.octet[4],
-							bi->BSSID.octet[5]));
+							dhd_dbg(ISCAN,
+								"%s: Moved up BSS[%2.2d:%2.2d] %pM\n",
+								__func__, l, j,
+								bi->BSSID.octet);
 
 							bi_next =
 							    (wl_bss_info_t *)((unsigned long)bi +
@@ -1549,7 +1537,7 @@ int dhd_iscan_remove_duplicates(void *dhdp, iscan_buf_t *iscan_cur)
 
 	dhd_iscan_lock();
 
-	DHD_ISCAN(("%s: Scan cache before delete\n", __func__));
+	dhd_dbg(ISCAN, "%s: Scan cache before delete\n", __func__);
 	dhd_iscan_print_cache(iscan_cur);
 
 	if (!iscan_cur)
@@ -1564,8 +1552,9 @@ int dhd_iscan_remove_duplicates(void *dhdp, iscan_buf_t *iscan_cur)
 		goto done;
 
 	if (results->version != WL_BSS_INFO_VERSION) {
-		DHD_ERROR(("%s: results->version %d != WL_BSS_INFO_VERSION\n",
-			   __func__, results->version));
+		dhd_dbg(ERROR,
+			"%s: results->version %d != WL_BSS_INFO_VERSION\n",
+			__func__, results->version);
 		goto done;
 	}
 
@@ -1574,11 +1563,8 @@ int dhd_iscan_remove_duplicates(void *dhdp, iscan_buf_t *iscan_cur)
 		if (!bi)
 			break;
 
-		DHD_ISCAN(("%s: Find dups for BSS[%2.2d] %X:%X:%X:%X:%X:%X\n",
-			   __func__, i, bi->BSSID.octet[0],
-			   bi->BSSID.octet[1], bi->BSSID.octet[2],
-			   bi->BSSID.octet[3], bi->BSSID.octet[4],
-			   bi->BSSID.octet[5]));
+		dhd_dbg(ISCAN, "%s: Find dups for BSS[%2.2d] %pM\n",
+			__func__, i, bi->BSSID.octet);
 
 		dhd_iscan_delete_bss(dhdp, bi->BSSID.octet, iscan_cur);
 
@@ -1586,7 +1572,7 @@ int dhd_iscan_remove_duplicates(void *dhdp, iscan_buf_t *iscan_cur)
 	}
 
 done:
-	DHD_ISCAN(("%s: Scan cache after delete\n", __func__));
+	dhd_dbg(ISCAN, "%s: Scan cache after delete\n", __func__);
 	dhd_iscan_print_cache(iscan_cur);
 	dhd_iscan_unlock();
 	return 0;
@@ -1640,7 +1626,7 @@ static int dhd_iscan_get_partial_result(void *dhdp, uint *scan_count)
 
 	iscan_cur = dhd_iscan_allocate_buf(dhd, &iscan_chain);
 	if (!iscan_cur) {
-		DHD_ERROR(("%s: Failed to allocate node\n", __func__));
+		dhd_dbg(ERROR, "%s: Failed to allocate node\n", __func__);
 		dhd_iscan_free_buf(dhdp, 0);
 		dhd_iscan_request(dhdp, WL_SCAN_ACTION_ABORT);
 		goto fail;
@@ -1698,15 +1684,16 @@ int dhd_pno_clean(dhd_pub_t *dhd)
 			ret = dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, iovbuf,
 					iov_len);
 			if (ret < 0) {
-				DHD_ERROR(("%s failed code %d\n", __func__,
-					   ret));
+				dhd_dbg(ERROR, "%s failed code %d\n",
+					__func__, ret);
 			}
 		} else {
 			ret = -1;
-			DHD_ERROR(("%s failed code %d\n", __func__, iov_len));
+			dhd_dbg(ERROR, "%s failed code %d\n",
+				__func__, iov_len);
 		}
 	} else
-		DHD_ERROR(("%s failed code %d\n", __func__, ret));
+		dhd_dbg(ERROR, "%s failed code %d\n", __func__, ret);
 
 	return ret;
 }
@@ -1717,7 +1704,7 @@ int dhd_pno_enable(dhd_pub_t *dhd, int pfn_enabled)
 	int ret = -1;
 
 	if ((!dhd) && ((pfn_enabled != 0) || (pfn_enabled != 1))) {
-		DHD_ERROR(("%s error exit\n", __func__));
+		dhd_dbg(ERROR, "%s error exit\n", __func__);
 		return ret;
 	}
 
@@ -1728,15 +1715,16 @@ int dhd_pno_enable(dhd_pub_t *dhd, int pfn_enabled)
 		ret = dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, iovbuf,
 				sizeof(iovbuf));
 		if (ret < 0) {
-			DHD_ERROR(("%s failed for error=%d\n", __func__, ret));
+			dhd_dbg(ERROR, "%s failed for error=%d\n",
+				__func__, ret);
 			return ret;
 		} else {
 			dhd->pno_enable = pfn_enabled;
-			DHD_TRACE(("%s set pno as %d\n", __func__,
-				   dhd->pno_enable));
+			dhd_dbg(TRACE, "%s set pno as %d\n",
+				__func__, dhd->pno_enable);
 		}
 	} else
-		DHD_ERROR(("%s failed err=%d\n", __func__, ret));
+		dhd_dbg(ERROR, "%s failed err=%d\n", __func__, ret);
 
 	return ret;
 }
@@ -1751,18 +1739,19 @@ dhd_pno_set(dhd_pub_t *dhd, wlc_ssid_t *ssids_local, int nssid, unsigned char sc
 	wl_pfn_param_t pfn_param;
 	wl_pfn_t pfn_element;
 
-	DHD_TRACE(("%s nssid=%d nchan=%d\n", __func__, nssid, scan_fr));
+	dhd_dbg(TRACE, "%s nssid=%d nchan=%d\n", __func__, nssid, scan_fr);
 
 	if ((!dhd) && (!ssids_local)) {
-		DHD_ERROR(("%s error exit\n", __func__));
+		dhd_dbg(ERROR, "%s error exit\n", __func__);
 		err = -1;
 	}
 
 	/* Check for broadcast ssid */
 	for (k = 0; k < nssid; k++) {
 		if (!ssids_local[k].SSID_len) {
-			DHD_ERROR(("%d: Broadcast SSID is ilegal for PNO "
-				"setting\n", k));
+			dhd_dbg(ERROR,
+				"%d: Broadcast SSID is ilegal for PNO setting\n",
+				k);
 			return err;
 		}
 	}
@@ -1771,9 +1760,9 @@ dhd_pno_set(dhd_pub_t *dhd, wlc_ssid_t *ssids_local, int nssid, unsigned char sc
 	{
 		int j;
 		for (j = 0; j < nssid; j++) {
-			DHD_ERROR(("%d: scan  for  %s size =%d\n", j,
-				   ssids_local[j].SSID,
-				   ssids_local[j].SSID_len));
+			dhd_dbg(ERROR, "%d: scan  for  %s size =%d\n",
+				j, ssids_local[j].SSID,
+				ssids_local[j].SSID_len);
 		}
 	}
 #endif				/* PNO_DUMP */
@@ -1781,7 +1770,7 @@ dhd_pno_set(dhd_pub_t *dhd, wlc_ssid_t *ssids_local, int nssid, unsigned char sc
 	/* clean up everything */
 	err = dhd_pno_clean(dhd);
 	if (err < 0) {
-		DHD_ERROR(("%s failed error=%d\n", __func__, err));
+		dhd_dbg(ERROR, "%s failed error=%d\n", __func__, err);
 		return err;
 	}
 	memset(&pfn_param, 0, sizeof(pfn_param));
@@ -1818,12 +1807,12 @@ dhd_pno_set(dhd_pub_t *dhd, wlc_ssid_t *ssids_local, int nssid, unsigned char sc
 			err = dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, iovbuf,
 					sizeof(iovbuf));
 			if (err < 0) {
-				DHD_ERROR(("%s failed for i=%d error=%d\n",
-					   __func__, i, err));
+				dhd_dbg(ERROR, "%s failed for i=%d error=%d\n",
+					__func__, i, err);
 				return err;
 			}
 		} else
-			DHD_ERROR(("%s failed err=%d\n", __func__, err));
+			dhd_dbg(ERROR, "%s failed err=%d\n", __func__, err);
 	}
 
 	/* Enable PNO */
diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_dbg.h b/drivers/staging/brcm80211/brcmfmac/dhd_dbg.h
index 0817f13..b4db8d1 100644
--- a/drivers/staging/brcm80211/brcmfmac/dhd_dbg.h
+++ b/drivers/staging/brcm80211/brcmfmac/dhd_dbg.h
@@ -19,33 +19,19 @@
 
 #if defined(DHD_DEBUG)
 
-#define DHD_ERROR(args)	       \
-	do {if ((dhd_msg_level & DHD_ERROR_VAL) && (net_ratelimit())) \
-		printk args; } while (0)
-#define DHD_TRACE(args)		do {if (dhd_msg_level & DHD_TRACE_VAL)	\
-					printk args; } while (0)
-#define DHD_INFO(args)		do {if (dhd_msg_level & DHD_INFO_VAL)	\
-					printk args; } while (0)
-#define DHD_DATA(args)		do {if (dhd_msg_level & DHD_DATA_VAL)	\
-					printk args; } while (0)
-#define DHD_CTL(args)		do {if (dhd_msg_level & DHD_CTL_VAL)	\
-					printk args; } while (0)
-#define DHD_TIMER(args)		do {if (dhd_msg_level & DHD_TIMER_VAL)	\
-					printk args; } while (0)
-#define DHD_HDRS(args)		do {if (dhd_msg_level & DHD_HDRS_VAL)	\
-					printk args; } while (0)
-#define DHD_BYTES(args)		do {if (dhd_msg_level & DHD_BYTES_VAL)	\
-					printk args; } while (0)
-#define DHD_INTR(args)		do {if (dhd_msg_level & DHD_INTR_VAL)	\
-					printk args; } while (0)
-#define DHD_GLOM(args)		do {if (dhd_msg_level & DHD_GLOM_VAL)	\
-					printk args; } while (0)
-#define DHD_EVENT(args)		do {if (dhd_msg_level & DHD_EVENT_VAL)	\
-					printk args; } while (0)
-#define DHD_BTA(args)		do {if (dhd_msg_level & DHD_BTA_VAL)	\
-					printk args; } while (0)
-#define DHD_ISCAN(args)		do {if (dhd_msg_level & DHD_ISCAN_VAL)	\
-					printk args; } while (0)
+#define dhd_dbg(level, fmt, ...)					\
+do {									\
+	if (DHD_ERROR_VAL == DHD_##level##_VAL) {			\
+		if (dhd_msg_level & DHD_##level##_VAL) {		\
+			if (net_ratelimit())				\
+				printk(KERN_DEBUG fmt, ##__VA_ARGS__);	\
+		}							\
+	} else {							\
+		if (dhd_msg_level & DHD_##level##_VAL) {		\
+			printk(KERN_DEBUG fmt, ##__VA_ARGS__);		\
+		}							\
+	}								\
+} while (0)
 
 #define DHD_ERROR_ON()		(dhd_msg_level & DHD_ERROR_VAL)
 #define DHD_TRACE_ON()		(dhd_msg_level & DHD_TRACE_VAL)
@@ -63,20 +49,6 @@
 
 #else	/* (defined BCMDBG) || (defined DHD_DEBUG) */
 
-#define DHD_ERROR(args)  do {if (net_ratelimit()) printk args; } while (0)
-#define DHD_TRACE(args)
-#define DHD_INFO(args)
-#define DHD_DATA(args)
-#define DHD_CTL(args)
-#define DHD_TIMER(args)
-#define DHD_HDRS(args)
-#define DHD_BYTES(args)
-#define DHD_INTR(args)
-#define DHD_GLOM(args)
-#define DHD_EVENT(args)
-#define DHD_BTA(args)
-#define DHD_ISCAN(args)
-
 #define DHD_ERROR_ON()		0
 #define DHD_TRACE_ON()		0
 #define DHD_INFO_ON()		0
diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c
index 5d4b643..14228e2 100644
--- a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c
+++ b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c
@@ -131,13 +131,13 @@ static int wifi_remove(struct platform_device *pdev)
 
 static int wifi_suspend(struct platform_device *pdev, pm_message_t state)
 {
-	DHD_TRACE(("##> %s\n", __func__));
+	dhd_dbg(TRACE, "##> %s\n", __func__);
 	return 0;
 }
 
 static int wifi_resume(struct platform_device *pdev)
 {
-	DHD_TRACE(("##> %s\n", __func__));
+	dhd_dbg(TRACE, "##> %s\n", __func__);
 	return 0;
 }
 
@@ -153,13 +153,13 @@ static struct platform_driver wifi_device = {
 
 int wifi_add_dev(void)
 {
-	DHD_TRACE(("## Calling platform_driver_register\n"));
+	dhd_dbg(TRACE, "## Calling platform_driver_register\n");
 	return platform_driver_register(&wifi_device);
 }
 
 void wifi_del_dev(void)
 {
-	DHD_TRACE(("## Unregister platform_driver_register\n"));
+	dhd_dbg(TRACE, "## Unregister platform_driver_register\n");
 	platform_driver_unregister(&wifi_device);
 }
 #endif	/* defined(CUSTOMER_HW2) && defined(CONFIG_WIFI_CONTROL_FUNC) */
@@ -433,7 +433,7 @@ extern int unregister_pm_notifier(struct notifier_block *nb);
 static void dhd_set_packet_filter(int value, dhd_pub_t *dhd)
 {
 #ifdef PKT_FILTER_SUPPORT
-	DHD_TRACE(("%s: %d\n", __func__, value));
+	dhd_dbg(TRACE, "%s: %d\n", __func__, value);
 	/* 1 - Enable packet filter, only allow unicast packet to send up */
 	/* 0 - Disable packet filter */
 	if (dhd_pkt_filter_enable) {
@@ -459,15 +459,15 @@ static int dhd_set_suspend(int value, dhd_pub_t *dhd)
 	uint roamvar = 1;
 #endif				/* CUSTOMER_HW2 */
 
-	DHD_TRACE(("%s: enter, value = %d in_suspend=%d\n",
-		   __func__, value, dhd->in_suspend));
+	dhd_dbg(TRACE, "%s: enter, value = %d in_suspend=%d\n",
+		__func__, value, dhd->in_suspend);
 
 	if (dhd && dhd->up) {
 		if (value && dhd->in_suspend) {
 
 			/* Kernel suspended */
-			DHD_TRACE(("%s: force extra Suspend setting\n",
-				   __func__));
+			dhd_dbg(TRACE, "%s: force extra Suspend setting\n",
+				__func__);
 
 			dhdcdc_set_ioctl(dhd, 0, WLC_SET_PM,
 					 (char *)&power_mode,
@@ -503,8 +503,8 @@ static int dhd_set_suspend(int value, dhd_pub_t *dhd)
 		} else {
 
 			/* Kernel resumed  */
-			DHD_TRACE(("%s: Remove extra suspend setting\n",
-				   __func__));
+			dhd_dbg(TRACE, "%s: Remove extra suspend setting\n",
+				__func__);
 
 			power_mode = PM_FAST;
 			dhdcdc_set_ioctl(dhd, 0, WLC_SET_PM,
@@ -549,7 +549,7 @@ static void dhd_early_suspend(struct early_suspend *h)
 {
 	struct dhd_info *dhd = container_of(h, struct dhd_info, early_suspend);
 
-	DHD_TRACE(("%s: enter\n", __func__));
+	dhd_dbg(TRACE, "%s: enter\n", __func__);
 
 	if (dhd)
 		dhd_suspend_resume_helper(dhd, 1);
@@ -560,7 +560,7 @@ static void dhd_late_resume(struct early_suspend *h)
 {
 	struct dhd_info *dhd = container_of(h, struct dhd_info, early_suspend);
 
-	DHD_TRACE(("%s: enter\n", __func__));
+	dhd_dbg(TRACE, "%s: enter\n", __func__);
 
 	if (dhd)
 		dhd_suspend_resume_helper(dhd, 0);
@@ -653,7 +653,7 @@ int dhd_ifname2idx(dhd_info_t *dhd, char *name)
 		    && !strncmp(dhd->iflist[i]->name, name, IFNAMSIZ))
 			break;
 
-	DHD_TRACE(("%s: return idx %d for \"%s\"\n", __func__, i, name));
+	dhd_dbg(TRACE, "%s: return idx %d for \"%s\"\n", __func__, i, name);
 
 	return i;		/* default - the primary interface */
 }
@@ -665,12 +665,12 @@ char *dhd_ifname(dhd_pub_t *dhdp, int ifidx)
 	ASSERT(dhd);
 
 	if (ifidx < 0 || ifidx >= DHD_MAX_IFS) {
-		DHD_ERROR(("%s: ifidx %d out of range\n", __func__, ifidx));
+		dhd_dbg(ERROR, "%s: ifidx %d out of range\n", __func__, ifidx);
 		return "<if_bad>";
 	}
 
 	if (dhd->iflist[ifidx] == NULL) {
-		DHD_ERROR(("%s: null i/f %d\n", __func__, ifidx));
+		dhd_dbg(ERROR, "%s: null i/f %d\n", __func__, ifidx);
 		return "<if_null>";
 	}
 
@@ -703,8 +703,8 @@ static void _dhd_set_multicast_list(dhd_info_t *dhd, int ifidx)
 	buflen = sizeof("mcast_list") + sizeof(cnt) + (cnt * ETH_ALEN);
 	bufp = buf = kmalloc(buflen, GFP_ATOMIC);
 	if (!bufp) {
-		DHD_ERROR(("%s: out of memory for mcast_list, cnt %d\n",
-			   dhd_ifname(&dhd->pub, ifidx), cnt));
+		dhd_dbg(ERROR, "%s: out of memory for mcast_list, cnt %d\n",
+			dhd_ifname(&dhd->pub, ifidx), cnt);
 		return;
 	}
 
@@ -731,8 +731,8 @@ static void _dhd_set_multicast_list(dhd_info_t *dhd, int ifidx)
 
 	ret = dhd_prot_ioctl(&dhd->pub, ifidx, &ioc, ioc.buf, ioc.len);
 	if (ret < 0) {
-		DHD_ERROR(("%s: set mcast_list failed, cnt %d\n",
-			   dhd_ifname(&dhd->pub, ifidx), cnt));
+		dhd_dbg(ERROR, "%s: set mcast_list failed, cnt %d\n",
+			dhd_ifname(&dhd->pub, ifidx), cnt);
 		allmulti = cnt ? true : allmulti;
 	}
 
@@ -746,17 +746,18 @@ static void _dhd_set_multicast_list(dhd_info_t *dhd, int ifidx)
 	buflen = sizeof("allmulti") + sizeof(allmulti);
 	buf = kmalloc(buflen, GFP_ATOMIC);
 	if (!buf) {
-		DHD_ERROR(("%s: out of memory for allmulti\n",
-			   dhd_ifname(&dhd->pub, ifidx)));
+		dhd_dbg(ERROR, "%s: out of memory for allmulti\n",
+			dhd_ifname(&dhd->pub, ifidx));
 		return;
 	}
 	allmulti = cpu_to_le32(allmulti);
 
 	if (!bcm_mkiovar
 	    ("allmulti", (void *)&allmulti, sizeof(allmulti), buf, buflen)) {
-		DHD_ERROR(("%s: mkiovar failed for allmulti, datalen %d "
-			"buflen %u\n", dhd_ifname(&dhd->pub, ifidx),
-			(int)sizeof(allmulti), buflen));
+		dhd_dbg(ERROR,
+			"%s: mkiovar failed for allmulti, datalen %d buflen %u\n",
+			dhd_ifname(&dhd->pub, ifidx),
+			(int)sizeof(allmulti), buflen);
 		kfree(buf);
 		return;
 	}
@@ -769,9 +770,9 @@ static void _dhd_set_multicast_list(dhd_info_t *dhd, int ifidx)
 
 	ret = dhd_prot_ioctl(&dhd->pub, ifidx, &ioc, ioc.buf, ioc.len);
 	if (ret < 0) {
-		DHD_ERROR(("%s: set allmulti %d failed\n",
-			   dhd_ifname(&dhd->pub, ifidx),
-			   le32_to_cpu(allmulti)));
+		dhd_dbg(ERROR, "%s: set allmulti %d failed\n",
+			dhd_ifname(&dhd->pub, ifidx),
+			le32_to_cpu(allmulti));
 	}
 
 	kfree(buf);
@@ -790,9 +791,9 @@ static void _dhd_set_multicast_list(dhd_info_t *dhd, int ifidx)
 
 	ret = dhd_prot_ioctl(&dhd->pub, ifidx, &ioc, ioc.buf, ioc.len);
 	if (ret < 0) {
-		DHD_ERROR(("%s: set promisc %d failed\n",
-			   dhd_ifname(&dhd->pub, ifidx),
-			   le32_to_cpu(allmulti)));
+		dhd_dbg(ERROR, "%s: set promisc %d failed\n",
+			dhd_ifname(&dhd->pub, ifidx),
+			le32_to_cpu(allmulti));
 	}
 }
 
@@ -803,11 +804,11 @@ _dhd_set_mac_address(dhd_info_t *dhd, int ifidx, u8 *addr)
 	wl_ioctl_t ioc;
 	int ret;
 
-	DHD_TRACE(("%s enter\n", __func__));
+	dhd_dbg(TRACE, "%s enter\n", __func__);
 	if (!bcm_mkiovar
 	    ("cur_etheraddr", (char *)addr, ETH_ALEN, buf, 32)) {
-		DHD_ERROR(("%s: mkiovar failed for cur_etheraddr\n",
-			   dhd_ifname(&dhd->pub, ifidx)));
+		dhd_dbg(ERROR, "%s: mkiovar failed for cur_etheraddr\n",
+			dhd_ifname(&dhd->pub, ifidx));
 		return -1;
 	}
 	memset(&ioc, 0, sizeof(ioc));
@@ -818,8 +819,8 @@ _dhd_set_mac_address(dhd_info_t *dhd, int ifidx, u8 *addr)
 
 	ret = dhd_prot_ioctl(&dhd->pub, ifidx, &ioc, ioc.buf, ioc.len);
 	if (ret < 0) {
-		DHD_ERROR(("%s: set cur_etheraddr failed\n",
-			   dhd_ifname(&dhd->pub, ifidx)));
+		dhd_dbg(ERROR, "%s: set cur_etheraddr failed\n",
+			dhd_ifname(&dhd->pub, ifidx));
 	} else {
 		memcpy(dhd->iflist[ifidx]->net->dev_addr, addr, ETH_ALEN);
 	}
@@ -840,7 +841,8 @@ static void dhd_op_if(dhd_if_t *ifp)
 
 	dhd = ifp->info;
 
-	DHD_TRACE(("%s: idx %d, state %d\n", __func__, ifp->idx, ifp->state));
+	dhd_dbg(TRACE, "%s: idx %d, state %d\n",
+		__func__, ifp->idx, ifp->state);
 
 	switch (ifp->state) {
 	case WLC_E_IF_ADD:
@@ -849,9 +851,9 @@ static void dhd_op_if(dhd_if_t *ifp)
 		 * in case we missed the WLC_E_IF_DEL event.
 		 */
 		if (ifp->net != NULL) {
-			DHD_ERROR(("%s: ERROR: netdev:%s already exists, "
-			"try free & unregister\n",
-			__func__, ifp->net->name));
+			dhd_dbg(ERROR,
+				"%s: ERROR: netdev:%s already exists, try free & unregister\n",
+				__func__, ifp->net->name);
 			netif_stop_queue(ifp->net);
 			unregister_netdev(ifp->net);
 			free_netdev(ifp->net);
@@ -859,7 +861,7 @@ static void dhd_op_if(dhd_if_t *ifp)
 		/* Allocate etherdev, including space for private structure */
 		ifp->net = alloc_etherdev(sizeof(dhd));
 		if (!ifp->net) {
-			DHD_ERROR(("%s: OOM - alloc_etherdev\n", __func__));
+			dhd_dbg(ERROR, "%s: OOM - alloc_etherdev\n", __func__);
 			ret = -ENOMEM;
 		}
 		if (ret == 0) {
@@ -867,9 +869,9 @@ static void dhd_op_if(dhd_if_t *ifp)
 			memcpy(netdev_priv(ifp->net), &dhd, sizeof(dhd));
 			err = dhd_net_attach(&dhd->pub, ifp->idx);
 			if (err != 0) {
-				DHD_ERROR(("%s: dhd_net_attach failed, "
-					"err %d\n",
-					__func__, err));
+				dhd_dbg(ERROR,
+					"%s: dhd_net_attach failed, err %d\n",
+					__func__, err);
 				ret = -EOPNOTSUPP;
 			} else {
 #ifdef SOFTAP
@@ -884,17 +886,17 @@ static void dhd_op_if(dhd_if_t *ifp)
 					 wl0.1 is ready */
 				up(&ap_eth_sema);
 #endif
-				DHD_TRACE(("\n ==== pid:%x, net_device for "
-					"if:%s created ===\n\n",
-					current->pid, ifp->net->name));
+				dhd_dbg(TRACE,
+					" ==== pid:%x, net_device for if:%s created ===\n",
+					current->pid, ifp->net->name);
 				ifp->state = 0;
 			}
 		}
 		break;
 	case WLC_E_IF_DEL:
 		if (ifp->net != NULL) {
-			DHD_TRACE(("\n%s: got 'WLC_E_IF_DEL' state\n",
-				   __func__));
+			dhd_dbg(TRACE, "%s: got 'WLC_E_IF_DEL' state\n",
+				__func__);
 			netif_stop_queue(ifp->net);
 			unregister_netdev(ifp->net);
 			ret = DHD_DEL_IF;	/* Make sure the free_netdev()
@@ -902,7 +904,7 @@ static void dhd_op_if(dhd_if_t *ifp)
 		}
 		break;
 	default:
-		DHD_ERROR(("%s: bad op %d\n", __func__, ifp->state));
+		dhd_dbg(ERROR, "%s: bad op %d\n", __func__, ifp->state);
 		ASSERT(!ifp->state);
 		break;
 	}
@@ -943,22 +945,24 @@ static int _dhd_sysioc_thread(void *data)
 					dhd_op_if(dhd->iflist[i]);
 #ifdef SOFTAP
 				if (dhd->iflist[i] == NULL) {
-					DHD_TRACE(("\n\n %s: interface %d "
-						"removed!\n", __func__, i));
+					dhd_dbg(TRACE,
+						" %s: interface %d removed!\n",
+						__func__, i);
 					continue;
 				}
 
 				if (in_ap && dhd->set_macaddress) {
-					DHD_TRACE(("attempt to set MAC for %s "
-						"in AP Mode," "blocked. \n",
-						dhd->iflist[i]->net->name));
+					dhd_dbg(TRACE,
+						"attempt to set MAC for %s in AP Mode blocked!\n",
+						dhd->iflist[i]->net->name);
 					dhd->set_macaddress = false;
 					continue;
 				}
 
 				if (in_ap && dhd->set_multicast) {
-					DHD_TRACE(("attempt to set MULTICAST list for %s" "in AP Mode, blocked. \n",
-						dhd->iflist[i]->net->name));
+					dhd_dbg(TRACE,
+						"attempt to set MULTICAST list for %s in AP Mode blocked!\n",
+						dhd->iflist[i]->net->name);
 					dhd->set_multicast = false;
 					continue;
 				}
@@ -1068,19 +1072,19 @@ static int dhd_start_xmit(struct sk_buff *skb, struct net_device *net)
 	dhd_info_t *dhd = *(dhd_info_t **) netdev_priv(net);
 	int ifidx;
 
-	DHD_TRACE(("%s: Enter\n", __func__));
+	dhd_dbg(TRACE, "%s: Enter\n", __func__);
 
 	/* Reject if down */
 	if (!dhd->pub.up || (dhd->pub.busstate == DHD_BUS_DOWN)) {
-		DHD_ERROR(("%s: xmit rejected pub.up=%d busstate=%d\n",
-			   __func__, dhd->pub.up, dhd->pub.busstate));
+		dhd_dbg(ERROR, "%s: xmit rejected pub.up=%d busstate=%d\n",
+			__func__, dhd->pub.up, dhd->pub.busstate);
 		netif_stop_queue(net);
 		return -ENODEV;
 	}
 
 	ifidx = dhd_net2idx(dhd, net);
 	if (ifidx == DHD_BAD_IF) {
-		DHD_ERROR(("%s: bad ifidx %d\n", __func__, ifidx));
+		dhd_dbg(ERROR, "%s: bad ifidx %d\n", __func__, ifidx);
 		netif_stop_queue(net);
 		return -ENODEV;
 	}
@@ -1089,15 +1093,15 @@ static int dhd_start_xmit(struct sk_buff *skb, struct net_device *net)
 	if (skb_headroom(skb) < dhd->pub.hdrlen) {
 		struct sk_buff *skb2;
 
-		DHD_INFO(("%s: insufficient headroom\n",
-			  dhd_ifname(&dhd->pub, ifidx)));
+		dhd_dbg(INFO, "%s: insufficient headroom\n",
+			dhd_ifname(&dhd->pub, ifidx));
 		dhd->pub.tx_realloc++;
 		skb2 = skb_realloc_headroom(skb, dhd->pub.hdrlen);
 		dev_kfree_skb(skb);
 		skb = skb2;
 		if (skb == NULL) {
-			DHD_ERROR(("%s: skb_realloc_headroom failed\n",
-				   dhd_ifname(&dhd->pub, ifidx)));
+			dhd_dbg(ERROR, "%s: skb_realloc_headroom failed\n",
+				dhd_ifname(&dhd->pub, ifidx));
 			ret = -ENOMEM;
 			goto done;
 		}
@@ -1106,8 +1110,8 @@ static int dhd_start_xmit(struct sk_buff *skb, struct net_device *net)
 	/* Convert to packet */
 	pktbuf = PKTFRMNATIVE(dhd->pub.osh, skb);
 	if (!pktbuf) {
-		DHD_ERROR(("%s: PKTFRMNATIVE failed\n",
-			   dhd_ifname(&dhd->pub, ifidx)));
+		dhd_dbg(ERROR, "%s: PKTFRMNATIVE failed\n",
+			dhd_ifname(&dhd->pub, ifidx));
 		dev_kfree_skb_any(skb);
 		ret = -ENOMEM;
 		goto done;
@@ -1130,7 +1134,7 @@ void dhd_txflowcontrol(dhd_pub_t *dhdp, int ifidx, bool state)
 	struct net_device *net;
 	dhd_info_t *dhd = dhdp->info;
 
-	DHD_TRACE(("%s: Enter\n", __func__));
+	dhd_dbg(TRACE, "%s: Enter\n", __func__);
 
 	dhdp->txoff = state;
 	ASSERT(dhd && dhd->iflist[ifidx]);
@@ -1154,7 +1158,7 @@ void dhd_rx_frame(dhd_pub_t *dhdp, int ifidx, struct sk_buff *pktbuf,
 	dhd_if_t *ifp;
 	wl_event_msg_t event;
 
-	DHD_TRACE(("%s: Enter\n", __func__));
+	dhd_dbg(TRACE, "%s: Enter\n", __func__);
 
 	save_pktbuf = pktbuf;
 
@@ -1256,7 +1260,7 @@ static struct net_device_stats *dhd_get_stats(struct net_device *net)
 	dhd_if_t *ifp;
 	int ifidx;
 
-	DHD_TRACE(("%s: Enter\n", __func__));
+	dhd_dbg(TRACE, "%s: Enter\n", __func__);
 
 	ifidx = dhd_net2idx(dhd, net);
 	if (ifidx == DHD_BAD_IF)
@@ -1430,13 +1434,13 @@ static int dhd_toe_get(dhd_info_t *dhd, int ifidx, u32 *toe_ol)
 	if (ret < 0) {
 		/* Check for older dongle image that doesn't support toe_ol */
 		if (ret == -EIO) {
-			DHD_ERROR(("%s: toe not supported by device\n",
-				   dhd_ifname(&dhd->pub, ifidx)));
+			dhd_dbg(ERROR, "%s: toe not supported by device\n",
+				dhd_ifname(&dhd->pub, ifidx));
 			return -EOPNOTSUPP;
 		}
 
-		DHD_INFO(("%s: could not get toe_ol: ret=%d\n",
-			  dhd_ifname(&dhd->pub, ifidx), ret));
+		dhd_dbg(INFO, "%s: could not get toe_ol: ret=%d\n",
+			dhd_ifname(&dhd->pub, ifidx), ret);
 		return ret;
 	}
 
@@ -1466,8 +1470,8 @@ static int dhd_toe_set(dhd_info_t *dhd, int ifidx, u32 toe_ol)
 
 	ret = dhd_prot_ioctl(&dhd->pub, ifidx, &ioc, ioc.buf, ioc.len);
 	if (ret < 0) {
-		DHD_ERROR(("%s: could not set toe_ol: ret=%d\n",
-			   dhd_ifname(&dhd->pub, ifidx), ret));
+		dhd_dbg(ERROR, "%s: could not set toe_ol: ret=%d\n",
+			dhd_ifname(&dhd->pub, ifidx), ret);
 		return ret;
 	}
 
@@ -1480,8 +1484,8 @@ static int dhd_toe_set(dhd_info_t *dhd, int ifidx, u32 toe_ol)
 
 	ret = dhd_prot_ioctl(&dhd->pub, ifidx, &ioc, ioc.buf, ioc.len);
 	if (ret < 0) {
-		DHD_ERROR(("%s: could not set toe: ret=%d\n",
-			   dhd_ifname(&dhd->pub, ifidx), ret));
+		dhd_dbg(ERROR, "%s: could not set toe: ret=%d\n",
+			dhd_ifname(&dhd->pub, ifidx), ret);
 		return ret;
 	}
 
@@ -1515,7 +1519,7 @@ static int dhd_ethtool(dhd_info_t *dhd, void *uaddr)
 	int ret;
 #endif
 
-	DHD_TRACE(("%s: Enter\n", __func__));
+	dhd_dbg(TRACE, "%s: Enter\n", __func__);
 
 	/* all ethtool calls start with a cmd word */
 	if (copy_from_user(&cmd, uaddr, sizeof(u32)))
@@ -1541,7 +1545,7 @@ static int dhd_ethtool(dhd_info_t *dhd, void *uaddr)
 
 		/* otherwise, require dongle to be up */
 		else if (!dhd->pub.up) {
-			DHD_ERROR(("%s: dongle is not up\n", __func__));
+			dhd_dbg(ERROR, "%s: dongle is not up\n", __func__);
 			return -ENODEV;
 		}
 
@@ -1554,8 +1558,8 @@ static int dhd_ethtool(dhd_info_t *dhd, void *uaddr)
 		sprintf(info.version, "%lu", dhd->pub.drv_version);
 		if (copy_to_user(uaddr, &info, sizeof(info)))
 			return -EFAULT;
-		DHD_CTL(("%s: given %*s, returning %s\n", __func__,
-			 (int)sizeof(drvname), drvname, info.driver));
+		dhd_dbg(CTL, "%s: given %*s, returning %s\n",
+			__func__, (int)sizeof(drvname), drvname, info.driver);
 		break;
 
 #ifdef TOE
@@ -1676,7 +1680,7 @@ static int dhd_ioctl_entry(struct net_device *net, struct ifreq *ifr, int cmd)
 	bool is_set_key_cmd;
 
 	ifidx = dhd_net2idx(dhd, net);
-	DHD_TRACE(("%s: ifidx %d, cmd 0x%04x\n", __func__, ifidx, cmd));
+	dhd_dbg(TRACE, "%s: ifidx %d, cmd 0x%04x\n", __func__, ifidx, cmd);
 
 	if (ifidx == DHD_BAD_IF)
 		return -1;
@@ -1747,7 +1751,7 @@ static int dhd_ioctl_entry(struct net_device *net, struct ifreq *ifr, int cmd)
 
 	/* send to dongle (must be up, and wl) */
 	if ((dhd->pub.busstate != DHD_BUS_DATA)) {
-		DHD_ERROR(("%s DONGLE_DOWN,__func__\n", __func__));
+		dhd_dbg(ERROR, "%s DONGLE_DOWN\n", __func__);
 		bcmerror = BCME_DONGLE_DOWN;
 		goto done;
 	}
@@ -1792,7 +1796,7 @@ static int dhd_stop(struct net_device *net)
 #if !defined(IGNORE_ETH0_DOWN)
 	dhd_info_t *dhd = *(dhd_info_t **) netdev_priv(net);
 
-	DHD_TRACE(("%s: Enter\n", __func__));
+	dhd_dbg(TRACE, "%s: Enter\n", __func__);
 	if (IS_CFG80211_FAVORITE()) {
 		wl_cfg80211_down();
 	}
@@ -1803,8 +1807,9 @@ static int dhd_stop(struct net_device *net)
 	dhd->pub.up = 0;
 	netif_stop_queue(net);
 #else
-	DHD_ERROR(("BYPASS %s:due to BRCM compilation : under investigation\n",
-		__func__));
+	dhd_dbg(ERROR,
+		"BYPASS %s:due to BRCM compilation : under investigation\n",
+		__func__);
 #endif				/* !defined(IGNORE_ETH0_DOWN) */
 
 	return 0;
@@ -1819,14 +1824,15 @@ static int dhd_open(struct net_device *net)
 	int ifidx = dhd_net2idx(dhd, net);
 	s32 ret = 0;
 
-	DHD_TRACE(("%s: ifidx %d\n", __func__, ifidx));
+	dhd_dbg(TRACE, "%s: ifidx %d\n", __func__, ifidx);
 
 	if (ifidx == 0) {	/* do it only for primary eth0 */
 
 		/* try to bring up bus */
 		ret = dhd_bus_start(&dhd->pub);
 		if (ret != 0) {
-			DHD_ERROR(("%s: failed with code %d\n", __func__, ret));
+			dhd_dbg(ERROR, "%s: failed with code %d\n",
+				__func__, ret);
 			return -1;
 		}
 		atomic_set(&dhd->pend_8021x_cnt, 0);
@@ -1847,8 +1853,8 @@ static int dhd_open(struct net_device *net)
 	dhd->pub.up = 1;
 	if (IS_CFG80211_FAVORITE()) {
 		if (unlikely(wl_cfg80211_up())) {
-			DHD_ERROR(("%s: failed to bring up cfg80211\n",
-				   __func__));
+			dhd_dbg(ERROR, "%s: failed to bring up cfg80211\n",
+				__func__);
 			return -1;
 		}
 	}
@@ -1862,13 +1868,13 @@ dhd_add_if(dhd_info_t *dhd, int ifidx, void *handle, char *name,
 {
 	dhd_if_t *ifp;
 
-	DHD_TRACE(("%s: idx %d, handle->%p\n", __func__, ifidx, handle));
+	dhd_dbg(TRACE, "%s: idx %d, handle->%p\n", __func__, ifidx, handle);
 
 	ASSERT(dhd && (ifidx < DHD_MAX_IFS));
 
 	ifp = dhd->iflist[ifidx];
 	if (!ifp && !(ifp = kmalloc(sizeof(dhd_if_t), GFP_ATOMIC))) {
-		DHD_ERROR(("%s: OOM - dhd_if_t\n", __func__));
+		dhd_dbg(ERROR, "%s: OOM - dhd_if_t\n", __func__);
 		return -ENOMEM;
 	}
 
@@ -1894,12 +1900,12 @@ void dhd_del_if(dhd_info_t *dhd, int ifidx)
 {
 	dhd_if_t *ifp;
 
-	DHD_TRACE(("%s: idx %d\n", __func__, ifidx));
+	dhd_dbg(TRACE, "%s: idx %d\n", __func__, ifidx);
 
 	ASSERT(dhd && ifidx && (ifidx < DHD_MAX_IFS));
 	ifp = dhd->iflist[ifidx];
 	if (!ifp) {
-		DHD_ERROR(("%s: Null interface\n", __func__));
+		dhd_dbg(ERROR, "%s: Null interface\n", __func__);
 		return;
 	}
 
@@ -1914,7 +1920,7 @@ dhd_pub_t *dhd_attach(struct dhd_bus *bus, uint bus_hdrlen)
 	dhd_info_t *dhd = NULL;
 	struct net_device *net;
 
-	DHD_TRACE(("%s: Enter\n", __func__));
+	dhd_dbg(TRACE, "%s: Enter\n", __func__);
 	/* updates firmware nvram path if it was provided as module
 		 paramters */
 	if ((firmware_path != NULL) && (firmware_path[0] != '\0'))
@@ -1925,14 +1931,14 @@ dhd_pub_t *dhd_attach(struct dhd_bus *bus, uint bus_hdrlen)
 	/* Allocate etherdev, including space for private structure */
 	net = alloc_etherdev(sizeof(dhd));
 	if (!net) {
-		DHD_ERROR(("%s: OOM - alloc_etherdev\n", __func__));
+		dhd_dbg(ERROR, "%s: OOM - alloc_etherdev\n", __func__);
 		goto fail;
 	}
 
 	/* Allocate primary dhd_info */
 	dhd = kzalloc(sizeof(dhd_info_t), GFP_ATOMIC);
 	if (!dhd) {
-		DHD_ERROR(("%s: OOM - alloc dhd_info\n", __func__));
+		dhd_dbg(ERROR, "%s: OOM - alloc dhd_info\n", __func__);
 		goto fail;
 	}
 
@@ -1976,13 +1982,13 @@ dhd_pub_t *dhd_attach(struct dhd_bus *bus, uint bus_hdrlen)
 
 	/* Attach and link in the protocol */
 	if (dhd_prot_attach(&dhd->pub) != 0) {
-		DHD_ERROR(("dhd_prot_attach failed\n"));
+		dhd_dbg(ERROR, "dhd_prot_attach failed\n");
 		goto fail;
 	}
 #if defined(CONFIG_WIRELESS_EXT)
 	/* Attach and link in the iw */
 	if (wl_iw_attach(net, (void *)&dhd->pub) != 0) {
-		DHD_ERROR(("wl_iw_attach failed\n"));
+		dhd_dbg(ERROR, "wl_iw_attach failed\n");
 		goto fail;
 	}
 #endif	/* defined(CONFIG_WIRELESS_EXT) */
@@ -1990,7 +1996,7 @@ dhd_pub_t *dhd_attach(struct dhd_bus *bus, uint bus_hdrlen)
 	/* Attach and link in the cfg80211 */
 	if (IS_CFG80211_FAVORITE()) {
 		if (unlikely(wl_cfg80211_attach(net, &dhd->pub))) {
-			DHD_ERROR(("wl_cfg80211_attach failed\n"));
+			dhd_dbg(ERROR, "wl_cfg80211_attach failed\n");
 			goto fail;
 		}
 		if (!NO_FW_REQ()) {
@@ -2095,15 +2101,15 @@ int dhd_bus_start(dhd_pub_t *dhdp)
 
 	ASSERT(dhd);
 
-	DHD_TRACE(("%s:\n", __func__));
+	dhd_dbg(TRACE, "%s:\n", __func__);
 
 	/* try to download image and nvram to the dongle */
 	if (dhd->pub.busstate == DHD_BUS_DOWN) {
 		if (!(dhd_bus_download_firmware(dhd->pub.bus,
 						fw_path, nv_path))) {
-			DHD_ERROR(("%s: dhdsdio_probe_download failed. "
-				"firmware = %s nvram = %s\n",
-				__func__, fw_path, nv_path));
+			dhd_dbg(ERROR,
+				"%s: dhdsdio_probe_download failed. firmware = %s nvram = %s\n",
+				__func__, fw_path, nv_path);
 			return -1;
 		}
 	}
@@ -2115,7 +2121,7 @@ int dhd_bus_start(dhd_pub_t *dhdp)
 	/* Bring up the bus */
 	ret = dhd_bus_init(&dhd->pub, true);
 	if (ret != 0) {
-		DHD_ERROR(("%s, dhd_bus_init failed %d\n", __func__, ret));
+		dhd_dbg(ERROR, "%s, dhd_bus_init failed %d\n", __func__, ret);
 		return ret;
 	}
 #if defined(OOB_INTR_ONLY)
@@ -2123,7 +2129,8 @@ int dhd_bus_start(dhd_pub_t *dhdp)
 	if (bcmsdh_register_oob_intr(dhdp)) {
 		del_timer_sync(&dhd->timer);
 		dhd->wd_timer_valid = false;
-		DHD_ERROR(("%s Host failed to resgister for OOB\n", __func__));
+		dhd_dbg(ERROR, "%s Host failed to register for OOB\n",
+			__func__);
 		return -ENODEV;
 	}
 
@@ -2135,7 +2142,7 @@ int dhd_bus_start(dhd_pub_t *dhdp)
 	if (dhd->pub.busstate != DHD_BUS_DATA) {
 		del_timer_sync(&dhd->timer);
 		dhd->wd_timer_valid = false;
-		DHD_ERROR(("%s failed bus is not ready\n", __func__));
+		dhd_dbg(ERROR, "%s failed bus is not ready\n", __func__);
 		return -ENODEV;
 	}
 #ifdef EMBEDDED_PLATFORM
@@ -2223,7 +2230,7 @@ int dhd_net_attach(dhd_pub_t *dhdp, int ifidx)
 	u8 temp_addr[ETH_ALEN] = {
 		0x00, 0x90, 0x4c, 0x11, 0x22, 0x33};
 
-	DHD_TRACE(("%s: ifidx %d\n", __func__, ifidx));
+	dhd_dbg(TRACE, "%s: ifidx %d\n", __func__, ifidx);
 
 	ASSERT(dhd && dhd->iflist[ifidx]);
 
@@ -2243,7 +2250,7 @@ int dhd_net_attach(dhd_pub_t *dhdp, int ifidx)
 	}
 
 	if (ifidx == 1) {
-		DHD_TRACE(("%s ACCESS POINT MAC: \n", __func__));
+		dhd_dbg(TRACE, "%s ACCESS POINT MAC:\n", __func__);
 		/*  ACCESSPOINT INTERFACE CASE */
 		temp_addr[0] |= 0X02;	/* set bit 2 ,
 			 - Locally Administered address  */
@@ -2269,12 +2276,12 @@ int dhd_net_attach(dhd_pub_t *dhdp, int ifidx)
 	memcpy(net->dev_addr, temp_addr, ETH_ALEN);
 
 	if (register_netdev(net) != 0) {
-		DHD_ERROR(("%s: couldn't register the net device\n",
-			__func__));
+		dhd_dbg(ERROR, "%s: couldn't register the net device\n",
+			__func__);
 		goto fail;
 	}
 
-	DHD_INFO(("%s: Broadcom Dongle Host Driver\n", net->name));
+	dhd_dbg(INFO, "%s: Broadcom Dongle Host Driver\n", net->name);
 
 	return 0;
 
@@ -2287,7 +2294,7 @@ void dhd_bus_detach(dhd_pub_t *dhdp)
 {
 	dhd_info_t *dhd;
 
-	DHD_TRACE(("%s: Enter\n", __func__));
+	dhd_dbg(TRACE, "%s: Enter\n", __func__);
 
 	if (dhdp) {
 		dhd = (dhd_info_t *) dhdp->info;
@@ -2312,7 +2319,7 @@ void dhd_detach(dhd_pub_t *dhdp)
 {
 	dhd_info_t *dhd;
 
-	DHD_TRACE(("%s: Enter\n", __func__));
+	dhd_dbg(TRACE, "%s: Enter\n", __func__);
 
 	if (dhdp) {
 		dhd = (dhd_info_t *) dhdp->info;
@@ -2380,7 +2387,7 @@ void dhd_detach(dhd_pub_t *dhdp)
 
 static void __exit dhd_module_cleanup(void)
 {
-	DHD_TRACE(("%s: Enter\n", __func__));
+	dhd_dbg(TRACE, "%s: Enter\n", __func__);
 
 	dhd_bus_unregister();
 #if defined(CUSTOMER_HW2) && defined(CONFIG_WIFI_CONTROL_FUNC)
@@ -2394,7 +2401,7 @@ static int __init dhd_module_init(void)
 {
 	int error;
 
-	DHD_TRACE(("%s: Enter\n", __func__));
+	dhd_dbg(TRACE, "%s: Enter\n", __func__);
 
 	/* Sanity check on the module parameters */
 	do {
@@ -2407,7 +2414,7 @@ static int __init dhd_module_init(void)
 		    && dhd_deferred_tx)
 			break;
 
-		DHD_ERROR(("Invalid module parameters.\n"));
+		dhd_dbg(ERROR, "Invalid module parameters\n");
 		return -EINVAL;
 	} while (0);
 	/* Call customer gpio to turn on power with WL_REG_ON signal */
@@ -2418,7 +2425,8 @@ static int __init dhd_module_init(void)
 
 	error = wifi_add_dev();
 	if (error) {
-		DHD_ERROR(("%s: platform_driver_register failed\n", __func__));
+		dhd_dbg(ERROR, "%s: platform_driver_register failed\n",
+			__func__);
 		goto failed;
 	}
 
@@ -2436,7 +2444,7 @@ static int __init dhd_module_init(void)
 	error = dhd_bus_register();
 
 	if (error) {
-		DHD_ERROR(("%s: sdio_register_driver failed\n", __func__));
+		dhd_dbg(ERROR, "%s: sdio_register_driver failed\n", __func__);
 		goto failed;
 	}
 	return error;
@@ -2701,7 +2709,7 @@ dhd_wl_host_event(dhd_info_t *dhd, int *ifidx, void *pktdata,
 	if (!IS_CFG80211_FAVORITE()) {
 		if ((dhd->iflist[*ifidx] == NULL)
 		    || (dhd->iflist[*ifidx]->net == NULL)) {
-			DHD_ERROR(("%s Exit null pointer\n", __func__));
+			dhd_dbg(ERROR, "%s Exit null pointer\n", __func__);
 			return bcmerror;
 		}
 
@@ -2761,7 +2769,7 @@ int dhd_dev_reset(struct net_device *dev, u8 flag)
 	/* Turning on watchdog back */
 	if (!flag)
 		dhd_os_wd_timer(&dhd->pub, dhd_watchdog_ms);
-	DHD_ERROR(("%s:  WLAN OFF DONE\n", __func__));
+	dhd_dbg(ERROR, "%s:  WLAN OFF DONE\n", __func__);
 
 	return 1;
 }
@@ -2909,7 +2917,7 @@ int write_to_file(dhd_pub_t *dhd, u8 *buf, int size)
 	/* open file to write */
 	fp = filp_open("/tmp/mem_dump", O_WRONLY | O_CREAT, 0640);
 	if (!fp) {
-		DHD_ERROR(("%s: open file error\n", __func__));
+		dhd_dbg(ERROR, "%s: open file error\n", __func__);
 		ret = -1;
 		goto exit;
 	}
diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c
index 6debc1e..f641d9e 100644
--- a/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c
+++ b/drivers/staging/brcm80211/brcmfmac/dhd_sdio.c
@@ -409,8 +409,8 @@ do { \
 	if (retryvar) { \
 		bus->regfails += (retryvar-1); \
 		if (retryvar > retry_limit) { \
-			DHD_ERROR(("%s: FAILED" #regvar "READ, LINE %d\n", \
-			__func__, __LINE__)); \
+			dhd_dbg(ERROR, "%s: FAILED" #regvar "READ, LINE %d\n", \
+				__func__, __LINE__);			\
 			regvar = 0; \
 		} \
 	} \
@@ -425,8 +425,8 @@ do { \
 	if (retryvar) { \
 		bus->regfails += (retryvar-1); \
 		if (retryvar > retry_limit) \
-			DHD_ERROR(("%s: FAILED REGISTER WRITE, LINE %d\n", \
-			__func__, __LINE__)); \
+			dhd_dbg(ERROR, "%s: FAILED REGISTER WRITE, LINE %d\n", \
+				__func__, __LINE__);			\
 	} \
 } while (0)
 
@@ -490,8 +490,8 @@ static void dhd_dongle_setmemsize(struct dhd_bus *bus, int mem_size)
 {
 	s32 min_size = DONGLE_MIN_MEMSIZE;
 	/* Restrict the memsize to user specified limit */
-	DHD_ERROR(("user: Restrict the dongle ram size to %d, min %d\n",
-		dhd_dongle_memsize, min_size));
+	dhd_dbg(ERROR, "user: Restrict the dongle ram size to %d, min %d\n",
+		dhd_dongle_memsize, min_size);
 	if ((dhd_dongle_memsize > min_size) &&
 	    (dhd_dongle_memsize < (s32) bus->orig_ramsize))
 		bus->ramsize = dhd_dongle_memsize;
@@ -519,7 +519,7 @@ static int dhdsdio_htclk(dhd_bus_t *bus, bool on, bool pendok)
 	u8 clkctl, clkreq, devctl;
 	bcmsdh_info_t *sdh;
 
-	DHD_TRACE(("%s: Enter\n", __func__));
+	dhd_dbg(TRACE, "%s: Enter\n", __func__);
 
 #if defined(OOB_INTR_ONLY)
 	pendok = false;
@@ -539,8 +539,8 @@ static int dhdsdio_htclk(dhd_bus_t *bus, bool on, bool pendok)
 		bcmsdh_cfg_write(sdh, SDIO_FUNC_1, SBSDIO_FUNC1_CHIPCLKCSR,
 				 clkreq, &err);
 		if (err) {
-			DHD_ERROR(("%s: HT Avail request error: %d\n",
-				   __func__, err));
+			dhd_dbg(ERROR, "%s: HT Avail request error: %d\n",
+				__func__, err);
 			return BCME_ERROR;
 		}
 
@@ -555,8 +555,8 @@ static int dhdsdio_htclk(dhd_bus_t *bus, bool on, bool pendok)
 		    bcmsdh_cfg_read(sdh, SDIO_FUNC_1, SBSDIO_FUNC1_CHIPCLKCSR,
 				    &err);
 		if (err) {
-			DHD_ERROR(("%s: HT Avail read error: %d\n",
-				   __func__, err));
+			dhd_dbg(ERROR, "%s: HT Avail read error: %d\n",
+				__func__, err);
 			return BCME_ERROR;
 		}
 
@@ -567,15 +567,16 @@ static int dhdsdio_htclk(dhd_bus_t *bus, bool on, bool pendok)
 			    bcmsdh_cfg_read(sdh, SDIO_FUNC_1, SBSDIO_DEVICE_CTL,
 					    &err);
 			if (err) {
-				DHD_ERROR(("%s: Devctl error setting CA: %d\n",
-					__func__, err));
+				dhd_dbg(ERROR,
+					"%s: Devctl error setting CA: %d\n",
+					__func__, err);
 				return BCME_ERROR;
 			}
 
 			devctl |= SBSDIO_DEVCTL_CA_INT_ONLY;
 			bcmsdh_cfg_write(sdh, SDIO_FUNC_1, SBSDIO_DEVICE_CTL,
 					 devctl, &err);
-			DHD_INFO(("CLKCTL: set PENDING\n"));
+			dhd_dbg(INFO, "CLKCTL: set PENDING\n");
 			bus->clkstate = CLK_PENDING;
 
 			return 0;
@@ -600,32 +601,33 @@ static int dhdsdio_htclk(dhd_bus_t *bus, bool on, bool pendok)
 				       PMU_MAX_TRANSITION_DLY);
 		}
 		if (err) {
-			DHD_ERROR(("%s: HT Avail request error: %d\n",
-				   __func__, err));
+			dhd_dbg(ERROR, "%s: HT Avail request error: %d\n",
+				__func__, err);
 			return BCME_ERROR;
 		}
 		if (!SBSDIO_CLKAV(clkctl, bus->alp_only)) {
-			DHD_ERROR(("%s: HT Avail timeout (%d): clkctl 0x%02x\n",
-				   __func__, PMU_MAX_TRANSITION_DLY, clkctl));
+			dhd_dbg(ERROR,
+				"%s: HT Avail timeout (%d): clkctl 0x%02x\n",
+				__func__, PMU_MAX_TRANSITION_DLY, clkctl);
 			return BCME_ERROR;
 		}
 
 		/* Mark clock available */
 		bus->clkstate = CLK_AVAIL;
-		DHD_INFO(("CLKCTL: turned ON\n"));
+		dhd_dbg(INFO, "CLKCTL: turned ON\n");
 
 #if defined(DHD_DEBUG)
 		if (bus->alp_only == true) {
 #if !defined(BCMLXSDMMC)
 			if (!SBSDIO_ALPONLY(clkctl)) {
-				DHD_ERROR(("%s: HT Clock, when ALP Only\n",
-					   __func__));
+				dhd_dbg(ERROR, "%s: HT Clock, when ALP Only\n",
+					__func__);
 			}
 #endif				/* !defined(BCMLXSDMMC) */
 		} else {
 			if (SBSDIO_ALPONLY(clkctl)) {
-				DHD_ERROR(("%s: HT Clock should be on.\n",
-					   __func__));
+				dhd_dbg(ERROR, "%s: HT Clock should be on\n",
+					__func__);
 			}
 		}
 #endif				/* defined (DHD_DEBUG) */
@@ -647,10 +649,11 @@ static int dhdsdio_htclk(dhd_bus_t *bus, bool on, bool pendok)
 		bus->clkstate = CLK_SDONLY;
 		bcmsdh_cfg_write(sdh, SDIO_FUNC_1, SBSDIO_FUNC1_CHIPCLKCSR,
 				 clkreq, &err);
-		DHD_INFO(("CLKCTL: turned OFF\n"));
+		dhd_dbg(INFO, "CLKCTL: turned OFF\n");
 		if (err) {
-			DHD_ERROR(("%s: Failed access turning clock off: %d\n",
-				   __func__, err));
+			dhd_dbg(ERROR,
+				"%s: Failed access turning clock off: %d\n",
+				__func__, err);
 			return BCME_ERROR;
 		}
 	}
@@ -663,7 +666,7 @@ static int dhdsdio_sdclk(dhd_bus_t *bus, bool on)
 	int err;
 	s32 iovalue;
 
-	DHD_TRACE(("%s: Enter\n", __func__));
+	dhd_dbg(TRACE, "%s: Enter\n", __func__);
 
 	if (on) {
 		if (bus->idleclock == DHD_IDLE_STOP) {
@@ -672,8 +675,9 @@ static int dhdsdio_sdclk(dhd_bus_t *bus, bool on)
 			err = bcmsdh_iovar_op(bus->sdh, "sd_clock", NULL, 0,
 					      &iovalue, sizeof(iovalue), true);
 			if (err) {
-				DHD_ERROR(("%s: error enabling sd_clock: %d\n",
-					   __func__, err));
+				dhd_dbg(ERROR,
+					"%s: error enabling sd_clock: %d\n",
+					__func__, err);
 				return BCME_ERROR;
 			}
 
@@ -681,8 +685,9 @@ static int dhdsdio_sdclk(dhd_bus_t *bus, bool on)
 			err = bcmsdh_iovar_op(bus->sdh, "sd_mode", NULL, 0,
 					      &iovalue, sizeof(iovalue), true);
 			if (err) {
-				DHD_ERROR(("%s: error changing sd_mode: %d\n",
-					   __func__, err));
+				dhd_dbg(ERROR,
+					"%s: error changing sd_mode: %d\n",
+					__func__, err);
 				return BCME_ERROR;
 			}
 		} else if (bus->idleclock != DHD_IDLE_ACTIVE) {
@@ -691,8 +696,9 @@ static int dhdsdio_sdclk(dhd_bus_t *bus, bool on)
 			err = bcmsdh_iovar_op(bus->sdh, "sd_divisor", NULL, 0,
 					      &iovalue, sizeof(iovalue), true);
 			if (err) {
-				DHD_ERROR(("%s: error restoring sd_divisor: %d\n",
-					__func__, err));
+				dhd_dbg(ERROR,
+					"%s: error restoring sd_divisor: %d\n",
+					__func__, err);
 				return BCME_ERROR;
 			}
 		}
@@ -700,8 +706,9 @@ static int dhdsdio_sdclk(dhd_bus_t *bus, bool on)
 	} else {
 		/* Stop or slow the SD clock itself */
 		if ((bus->sd_divisor == -1) || (bus->sd_mode == -1)) {
-			DHD_TRACE(("%s: can't idle clock, divisor %d mode %d\n",
-				   __func__, bus->sd_divisor, bus->sd_mode));
+			dhd_dbg(TRACE,
+				"%s: can't idle clock, divisor %d mode %d\n",
+				__func__, bus->sd_divisor, bus->sd_mode);
 			return BCME_ERROR;
 		}
 		if (bus->idleclock == DHD_IDLE_STOP) {
@@ -713,8 +720,9 @@ static int dhdsdio_sdclk(dhd_bus_t *bus, bool on)
 						    0, &iovalue,
 						    sizeof(iovalue), true);
 				if (err) {
-					DHD_ERROR(("%s: error changing sd_clock: %d\n",
-						__func__, err));
+					dhd_dbg(ERROR,
+						"%s: error changing sd_clock: %d\n",
+						__func__, err);
 					return BCME_ERROR;
 				}
 			}
@@ -723,8 +731,9 @@ static int dhdsdio_sdclk(dhd_bus_t *bus, bool on)
 			err = bcmsdh_iovar_op(bus->sdh, "sd_clock", NULL, 0,
 					      &iovalue, sizeof(iovalue), true);
 			if (err) {
-				DHD_ERROR(("%s: error disabling sd_clock: %d\n",
-					   __func__, err));
+				dhd_dbg(ERROR,
+					"%s: error disabling sd_clock: %d\n",
+					__func__, err);
 				return BCME_ERROR;
 			}
 		} else if (bus->idleclock != DHD_IDLE_ACTIVE) {
@@ -733,8 +742,9 @@ static int dhdsdio_sdclk(dhd_bus_t *bus, bool on)
 			err = bcmsdh_iovar_op(bus->sdh, "sd_divisor", NULL, 0,
 					      &iovalue, sizeof(iovalue), true);
 			if (err) {
-				DHD_ERROR(("%s: error changing sd_divisor: %d\n",
-					__func__, err));
+				dhd_dbg(ERROR,
+					"%s: error changing sd_divisor: %d\n",
+					__func__, err);
 				return BCME_ERROR;
 			}
 		}
@@ -751,7 +761,7 @@ static int dhdsdio_clkctl(dhd_bus_t *bus, uint target, bool pendok)
 	uint oldstate = bus->clkstate;
 #endif				/* DHD_DEBUG */
 
-	DHD_TRACE(("%s: Enter\n", __func__));
+	dhd_dbg(TRACE, "%s: Enter\n", __func__);
 
 	/* Early exit if we're already there */
 	if (bus->clkstate == target) {
@@ -780,8 +790,8 @@ static int dhdsdio_clkctl(dhd_bus_t *bus, uint target, bool pendok)
 		else if (bus->clkstate == CLK_AVAIL)
 			dhdsdio_htclk(bus, false, false);
 		else
-			DHD_ERROR(("dhdsdio_clkctl: request for %d -> %d\n",
-				   bus->clkstate, target));
+			dhd_dbg(ERROR, "dhdsdio_clkctl: request for %d -> %d\n",
+				bus->clkstate, target);
 		dhd_os_wd_timer(bus->dhd, dhd_watchdog_ms);
 		break;
 
@@ -795,7 +805,7 @@ static int dhdsdio_clkctl(dhd_bus_t *bus, uint target, bool pendok)
 		break;
 	}
 #ifdef DHD_DEBUG
-	DHD_INFO(("dhdsdio_clkctl: %d -> %d\n", oldstate, bus->clkstate));
+	dhd_dbg(INFO, "dhdsdio_clkctl: %d -> %d\n", oldstate, bus->clkstate);
 #endif				/* DHD_DEBUG */
 
 	return 0;
@@ -807,9 +817,9 @@ int dhdsdio_bussleep(dhd_bus_t *bus, bool sleep)
 	sdpcmd_regs_t *regs = bus->regs;
 	uint retries = 0;
 
-	DHD_INFO(("dhdsdio_bussleep: request %s (currently %s)\n",
-		  (sleep ? "SLEEP" : "WAKE"),
-		  (bus->sleeping ? "SLEEP" : "WAKE")));
+	dhd_dbg(INFO, "dhdsdio_bussleep: request %s (currently %s)\n",
+		sleep ? "SLEEP" : "WAKE",
+		bus->sleeping ? "SLEEP" : "WAKE");
 
 	/* Done if we're already in the requested state */
 	if (sleep == bus->sleeping)
@@ -830,7 +840,8 @@ int dhdsdio_bussleep(dhd_bus_t *bus, bool sleep)
 		/* Tell device to start using OOB wakeup */
 		W_SDREG(SMB_USE_OOB, &regs->tosbmailbox, retries);
 		if (retries > retry_limit)
-			DHD_ERROR(("CANNOT SIGNAL CHIP, WILL NOT WAKE UP!!\n"));
+			dhd_dbg(ERROR,
+				"CANNOT SIGNAL CHIP, WILL NOT WAKE UP!!\n");
 
 		/* Turn off our contribution to the HT clock request */
 		dhdsdio_clkctl(bus, CLK_SDONLY, false);
@@ -870,7 +881,7 @@ int dhdsdio_bussleep(dhd_bus_t *bus, bool sleep)
 			W_SDREG(SMB_DEV_INT, &regs->tosbmailbox, retries);
 
 		if (retries > retry_limit)
-			DHD_ERROR(("CANNOT SIGNAL CHIP TO CLEAR OOB!!\n"));
+			dhd_dbg(ERROR, "CANNOT SIGNAL CHIP TO CLEAR OOB!!\n");
 
 		/* Make sure we have SD bus access */
 		dhdsdio_clkctl(bus, CLK_SDONLY, false);
@@ -903,7 +914,8 @@ void dhd_enable_oob_intr(struct dhd_bus *bus, bool enable)
 		/* Tell device to start using OOB wakeup */
 		W_SDREG(SMB_USE_OOB, &regs->tosbmailbox, retries);
 		if (retries > retry_limit)
-			DHD_ERROR(("CANNOT SIGNAL CHIP, WILL NOT WAKE UP!!\n"));
+			dhd_dbg(ERROR,
+				"CANNOT SIGNAL CHIP, WILL NOT WAKE UP!!\n");
 
 	} else {
 		/* Send misc interrupt to indicate OOB not needed */
@@ -938,7 +950,7 @@ static int dhdsdio_txpkt(dhd_bus_t *bus, struct sk_buff *pkt, uint chan,
 	struct sk_buff *new;
 	int i;
 
-	DHD_TRACE(("%s: Enter\n", __func__));
+	dhd_dbg(TRACE, "%s: Enter\n", __func__);
 
 	sdh = bus->sdh;
 
@@ -953,14 +965,15 @@ static int dhdsdio_txpkt(dhd_bus_t *bus, struct sk_buff *pkt, uint chan,
 	pad = ((unsigned long)frame % DHD_SDALIGN);
 	if (pad) {
 		if (skb_headroom(pkt) < pad) {
-			DHD_INFO(("%s: insufficient headroom %d for %d pad\n",
-				  __func__, skb_headroom(pkt), pad));
+			dhd_dbg(INFO,
+				"%s: insufficient headroom %d for %d pad\n",
+				__func__, skb_headroom(pkt), pad);
 			bus->dhd->tx_realloc++;
 			new = pkt_buf_get_skb(pkt->len + DHD_SDALIGN);
 			if (!new) {
-				DHD_ERROR(("%s: couldn't allocate new %d-byte "
-					"packet\n",
-					__func__, pkt->len + DHD_SDALIGN));
+				dhd_dbg(ERROR,
+					"%s: couldn't allocate new %d-byte packet\n",
+					__func__, pkt->len + DHD_SDALIGN);
 				ret = BCME_NOMEM;
 				goto done;
 			}
@@ -1030,8 +1043,8 @@ static int dhdsdio_txpkt(dhd_bus_t *bus, struct sk_buff *pkt, uint chan,
 			len = roundup(len, ALIGNMENT);
 #ifdef NOTUSED
 		else
-			DHD_ERROR(("%s: sending unrounded %d-byte packet\n",
-				   __func__, len));
+			dhd_dbg(ERROR, "%s: sending unrounded %d-byte packet\n",
+				__func__, len);
 #endif
 	}
 
@@ -1045,8 +1058,9 @@ static int dhdsdio_txpkt(dhd_bus_t *bus, struct sk_buff *pkt, uint chan,
 		if (ret < 0) {
 			/* On failure, abort the command
 			 and terminate the frame */
-			DHD_INFO(("%s: sdio error %d, abort command and "
-				"terminate frame.\n", __func__, ret));
+			dhd_dbg(INFO,
+				"%s: sdio error %d, abort command and terminate frame\n",
+				__func__, ret);
 			bus->tx_sderrs++;
 
 			bcmsdh_abort(sdh, SDIO_FUNC_2);
@@ -1092,7 +1106,7 @@ int dhd_bus_txdata(struct dhd_bus *bus, struct sk_buff *pkt)
 	int ret = BCME_ERROR;
 	uint datalen, prec;
 
-	DHD_TRACE(("%s: Enter\n", __func__));
+	dhd_dbg(TRACE, "%s: Enter\n", __func__);
 
 	datalen = pkt->len;
 
@@ -1122,8 +1136,8 @@ int dhd_bus_txdata(struct dhd_bus *bus, struct sk_buff *pkt)
 	    || bus->dpc_sched || (!DATAOK(bus))
 	    || (bus->flowcontrol & NBITVAL(prec))
 	    || (bus->clkstate != CLK_AVAIL)) {
-		DHD_TRACE(("%s: deferring pktq len %d\n", __func__,
-			   pktq_len(&bus->txq)));
+		dhd_dbg(TRACE, "%s: deferring pktq len %d\n",
+			__func__, pktq_len(&bus->txq));
 		bus->fcqueued++;
 
 		/* Priority based enq */
@@ -1132,7 +1146,7 @@ int dhd_bus_txdata(struct dhd_bus *bus, struct sk_buff *pkt)
 			skb_pull(pkt, SDPCM_HDRLEN);
 			dhd_txcomplete(bus->dhd, pkt, false);
 			pkt_buf_free_skb(pkt);
-			DHD_ERROR(("%s: out of bus->txq !!!\n", __func__));
+			dhd_dbg(ERROR, "%s: out of bus->txq !!!\n", __func__);
 			ret = BCME_NORESOURCE;
 		} else {
 			ret = 0;
@@ -1161,7 +1175,7 @@ int dhd_bus_txdata(struct dhd_bus *bus, struct sk_buff *pkt)
 		dhdsdio_clkctl(bus, CLK_AVAIL, true);
 
 #ifndef SDTEST
-		DHD_TRACE(("%s: calling txpkt\n", __func__));
+		dhd_dbg(TRACE, "%s: calling txpkt\n", __func__);
 		ret = dhdsdio_txpkt(bus, pkt, SDPCM_DATA_CHANNEL, true);
 #else
 		ret = dhdsdio_txpkt(bus, pkt,
@@ -1197,7 +1211,7 @@ static uint dhdsdio_sendfromq(dhd_bus_t *bus, uint maxframes)
 	dhd_pub_t *dhd = bus->dhd;
 	sdpcmd_regs_t *regs = bus->regs;
 
-	DHD_TRACE(("%s: Enter\n", __func__));
+	dhd_dbg(TRACE, "%s: Enter\n", __func__);
 
 	tx_prec_map = ~bus->flowcontrol;
 
@@ -1255,7 +1269,7 @@ int dhd_bus_txctl(struct dhd_bus *bus, unsigned char *msg, uint msglen)
 	int ret = -1;
 	int i;
 
-	DHD_TRACE(("%s: Enter\n", __func__));
+	dhd_dbg(TRACE, "%s: Enter\n", __func__);
 
 	if (bus->dhd->dongle_reset)
 		return -EIO;
@@ -1314,8 +1328,9 @@ int dhd_bus_txctl(struct dhd_bus *bus, unsigned char *msg, uint msglen)
 	put_unaligned_le32(0, frame + SDPCM_FRAMETAG_LEN + sizeof(swheader));
 
 	if (!DATAOK(bus)) {
-		DHD_INFO(("%s: No bus credit bus->tx_max %d, bus->tx_seq %d\n",
-			  __func__, bus->tx_max, bus->tx_seq));
+		dhd_dbg(INFO,
+			"%s: No bus credit bus->tx_max %d, bus->tx_seq %d\n",
+			__func__, bus->tx_max, bus->tx_seq);
 		bus->ctrl_frame_stat = true;
 		/* Send from dpc */
 		bus->ctrl_frame_buf = frame;
@@ -1324,10 +1339,12 @@ int dhd_bus_txctl(struct dhd_bus *bus, unsigned char *msg, uint msglen)
 		dhd_wait_for_event(bus->dhd, &bus->ctrl_frame_stat);
 
 		if (bus->ctrl_frame_stat == false) {
-			DHD_INFO(("%s: ctrl_frame_stat == false\n", __func__));
+			dhd_dbg(INFO, "%s: ctrl_frame_stat == false\n",
+				__func__);
 			ret = 0;
 		} else {
-			DHD_INFO(("%s: ctrl_frame_stat == true\n", __func__));
+			dhd_dbg(INFO, "%s: ctrl_frame_stat == true\n",
+				__func__);
 			ret = -1;
 		}
 	}
@@ -1352,8 +1369,9 @@ int dhd_bus_txctl(struct dhd_bus *bus, unsigned char *msg, uint msglen)
 			if (ret < 0) {
 				/* On failure, abort the command and
 				 terminate the frame */
-				DHD_INFO(("%s: sdio error %d, abort command and terminate frame.\n",
-					__func__, ret));
+				dhd_dbg(INFO,
+					"%s: sdio error %d, abort command and terminate frame\n",
+					__func__, ret);
 				bus->tx_sderrs++;
 
 				bcmsdh_abort(sdh, SDIO_FUNC_2);
@@ -1405,7 +1423,7 @@ int dhd_bus_rxctl(struct dhd_bus *bus, unsigned char *msg, uint msglen)
 	uint rxlen = 0;
 	bool pending;
 
-	DHD_TRACE(("%s: Enter\n", __func__));
+	dhd_dbg(TRACE, "%s: Enter\n", __func__);
 
 	if (bus->dhd->dongle_reset)
 		return -EIO;
@@ -1420,20 +1438,20 @@ int dhd_bus_rxctl(struct dhd_bus *bus, unsigned char *msg, uint msglen)
 	dhd_os_sdunlock(bus->dhd);
 
 	if (rxlen) {
-		DHD_CTL(("%s: resumed on rxctl frame, got %d expected %d\n",
-			 __func__, rxlen, msglen));
+		dhd_dbg(CTL, "%s: resumed on rxctl frame, got %d expected %d\n",
+			__func__, rxlen, msglen);
 	} else if (timeleft == 0) {
-		DHD_ERROR(("%s: resumed on timeout\n", __func__));
+		dhd_dbg(ERROR, "%s: resumed on timeout\n", __func__);
 #ifdef DHD_DEBUG
 		dhd_os_sdlock(bus->dhd);
 		dhdsdio_checkdied(bus, NULL, 0);
 		dhd_os_sdunlock(bus->dhd);
 #endif				/* DHD_DEBUG */
 	} else if (pending == true) {
-		DHD_CTL(("%s: cancelled\n", __func__));
+		dhd_dbg(CTL, "%s: cancelled\n", __func__);
 		return -ERESTARTSYS;
 	} else {
-		DHD_CTL(("%s: resumed for unknown reason?\n", __func__));
+		dhd_dbg(CTL, "%s: resumed for unknown reason?\n", __func__);
 #ifdef DHD_DEBUG
 		dhd_os_sdlock(bus->dhd);
 		dhdsdio_checkdied(bus, NULL, 0);
@@ -1734,19 +1752,21 @@ dhdsdio_membytes(dhd_bus_t *bus, bool write, u32 address, u8 *data,
 	/* Set the backplane window to include the start address */
 	bcmerror = dhdsdio_set_siaddr_window(bus, address);
 	if (bcmerror) {
-		DHD_ERROR(("%s: window change failed\n", __func__));
+		dhd_dbg(ERROR, "%s: window change failed\n", __func__);
 		goto xfer_done;
 	}
 
 	/* Do the transfer(s) */
 	while (size) {
-		DHD_INFO(("%s: %s %d bytes at offset 0x%08x in window 0x%08x\n",
-			  __func__, (write ? "write" : "read"), dsize,
-			  sdaddr, (address & SBSDIO_SBWINDOW_MASK)));
+		dhd_dbg(INFO,
+			"%s: %s %d bytes at offset 0x%08x in window 0x%08x\n",
+			__func__, (write ? "write" : "read"), dsize,
+			sdaddr, (address & SBSDIO_SBWINDOW_MASK));
 		bcmerror =
 		     bcmsdh_rwdata(bus->sdh, write, sdaddr, data, dsize);
 		if (bcmerror) {
-			DHD_ERROR(("%s: membytes transfer failed\n", __func__));
+			dhd_dbg(ERROR, "%s: membytes transfer failed\n",
+				__func__);
 			break;
 		}
 
@@ -1757,8 +1777,8 @@ dhdsdio_membytes(dhd_bus_t *bus, bool write, u32 address, u8 *data,
 			address += dsize;
 			bcmerror = dhdsdio_set_siaddr_window(bus, address);
 			if (bcmerror) {
-				DHD_ERROR(("%s: window change failed\n",
-					   __func__));
+				dhd_dbg(ERROR, "%s: window change failed\n",
+					__func__);
 				break;
 			}
 			sdaddr = 0;
@@ -1769,8 +1789,8 @@ dhdsdio_membytes(dhd_bus_t *bus, bool write, u32 address, u8 *data,
 xfer_done:
 	/* Return the window to backplane enumeration space for core access */
 	if (dhdsdio_set_siaddr_window(bus, bcmsdh_cur_sbwad(bus->sdh))) {
-		DHD_ERROR(("%s: FAILED to set window back to 0x%x\n",
-			   __func__, bcmsdh_cur_sbwad(bus->sdh)));
+		dhd_dbg(ERROR, "%s: FAILED to set window back to 0x%x\n",
+			__func__, bcmsdh_cur_sbwad(bus->sdh));
 	}
 
 	return bcmerror;
@@ -1790,15 +1810,15 @@ static int dhdsdio_readshared(dhd_bus_t *bus, sdpcm_shared_t *sh)
 
 	addr = le32_to_cpu(addr);
 
-	DHD_INFO(("sdpcm_shared address 0x%08X\n", addr));
+	dhd_dbg(INFO, "sdpcm_shared address 0x%08X\n", addr);
 
 	/*
 	 * Check if addr is valid.
 	 * NVRAM length at the end of memory should have been overwritten.
 	 */
 	if (addr == 0 || ((~addr >> 16) & 0xffff) == (addr & 0xffff)) {
-		DHD_ERROR(("%s: address (0x%08x) of sdpcm_shared invalid\n",
-			   __func__, addr));
+		dhd_dbg(ERROR, "%s: address (0x%08x) of sdpcm_shared invalid\n",
+			__func__, addr);
 		return BCME_ERROR;
 	}
 
@@ -1818,10 +1838,10 @@ static int dhdsdio_readshared(dhd_bus_t *bus, sdpcm_shared_t *sh)
 	sh->msgtrace_addr = le32_to_cpu(sh->msgtrace_addr);
 
 	if ((sh->flags & SDPCM_SHARED_VERSION_MASK) != SDPCM_SHARED_VERSION) {
-		DHD_ERROR(("%s: sdpcm_shared version %d in dhd "
-			   "is different than sdpcm_shared version %d in dongle\n",
-			   __func__, SDPCM_SHARED_VERSION,
-			   sh->flags & SDPCM_SHARED_VERSION_MASK));
+		dhd_dbg(ERROR,
+			"%s: sdpcm_shared version %d in dhd is different than sdpcm_shared version %d in dongle\n",
+			__func__, SDPCM_SHARED_VERSION,
+			sh->flags & SDPCM_SHARED_VERSION_MASK);
 		return BCME_ERROR;
 	}
 
@@ -1839,7 +1859,7 @@ static int dhdsdio_checkdied(dhd_bus_t *bus, u8 *data, uint size)
 	sdpcm_shared_t sdpcm_shared;
 	struct bcmstrbuf strbuf;
 
-	DHD_TRACE(("%s: Enter\n", __func__));
+	dhd_dbg(TRACE, "%s: Enter\n", __func__);
 
 	if (data == NULL) {
 		/*
@@ -1849,8 +1869,8 @@ static int dhdsdio_checkdied(dhd_bus_t *bus, u8 *data, uint size)
 		size = msize;
 		mbuffer = data = kmalloc(msize, GFP_ATOMIC);
 		if (mbuffer == NULL) {
-			DHD_ERROR(("%s: kmalloc(%d) failed\n", __func__,
-				   msize));
+			dhd_dbg(ERROR, "%s: kmalloc(%d) failed\n",
+				__func__, msize);
 			bcmerror = BCME_NOMEM;
 			goto done;
 		}
@@ -1858,7 +1878,7 @@ static int dhdsdio_checkdied(dhd_bus_t *bus, u8 *data, uint size)
 
 	str = kmalloc(maxstrlen, GFP_ATOMIC);
 	if (str == NULL) {
-		DHD_ERROR(("%s: kmalloc(%d) failed\n", __func__, maxstrlen));
+		dhd_dbg(ERROR, "%s: kmalloc(%d) failed\n", __func__, maxstrlen);
 		bcmerror = BCME_NOMEM;
 		goto done;
 	}
@@ -1941,7 +1961,7 @@ static int dhdsdio_checkdied(dhd_bus_t *bus, u8 *data, uint size)
 	}
 
 	if (sdpcm_shared.flags & (SDPCM_SHARED_ASSERT | SDPCM_SHARED_TRAP))
-		DHD_ERROR(("%s: %s\n", __func__, strbuf.origbuf));
+		dhd_dbg(ERROR, "%s: %s\n", __func__, strbuf.origbuf);
 
 #ifdef DHD_DEBUG
 	if (sdpcm_shared.flags & SDPCM_SHARED_TRAP) {
@@ -1969,7 +1989,8 @@ static int dhdsdio_mem_dump(dhd_bus_t *bus)
 	size = bus->ramsize;
 	buf = kmalloc(size, GFP_ATOMIC);
 	if (!buf) {
-		DHD_ERROR(("%s: Out of memory (%d bytes)\n", __func__, size));
+		dhd_dbg(ERROR, "%s: Out of memory (%d bytes)\n",
+			__func__, size);
 		return -1;
 	}
 
@@ -1980,7 +2001,8 @@ static int dhdsdio_mem_dump(dhd_bus_t *bus)
 		read_size = min(MEMBLOCK, size);
 		ret = dhdsdio_membytes(bus, false, start, databuf, read_size);
 		if (ret) {
-			DHD_ERROR(("%s: Error membytes %d\n", __func__, ret));
+			dhd_dbg(ERROR, "%s: Error membytes %d\n",
+				__func__, ret);
 			kfree(buf);
 			return -1;
 		}
@@ -1995,7 +2017,7 @@ static int dhdsdio_mem_dump(dhd_bus_t *bus)
 
 	/* free buf before return !!! */
 	if (write_to_file(bus->dhd, buf, bus->ramsize)) {
-		DHD_ERROR(("%s: Error writing to files\n", __func__));
+		dhd_dbg(ERROR, "%s: Error writing to files\n", __func__);
 		return -1;
 	}
 
@@ -2086,7 +2108,7 @@ int dhdsdio_downloadvars(dhd_bus_t *bus, void *arg, int len)
 {
 	int bcmerror = 0;
 
-	DHD_TRACE(("%s: Enter\n", __func__));
+	dhd_dbg(TRACE, "%s: Enter\n", __func__);
 
 	/* Basic sanity checks */
 	if (bus->dhd->up) {
@@ -2124,9 +2146,9 @@ dhdsdio_doiovar(dhd_bus_t *bus, const bcm_iovar_t *vi, u32 actionid,
 	s32 int_val = 0;
 	bool bool_val = 0;
 
-	DHD_TRACE(("%s: Enter, action %d name %s params %p plen %d arg %p "
-		"len %d val_size %d\n",
-		__func__, actionid, name, params, plen, arg, len, val_size));
+	dhd_dbg(TRACE,
+		"%s: Enter, action %d name %s params %p plen %d arg %p len %d val_size %d\n",
+		__func__, actionid, name, params, plen, arg, len, val_size);
 
 	bcmerror = bcm_iovar_lencheck(vi, arg, len, IOV_ISSET(actionid));
 	if (bcmerror != 0)
@@ -2175,12 +2197,13 @@ dhdsdio_doiovar(dhd_bus_t *bus, const bcm_iovar_t *vi, u32 actionid,
 		bus->intdis = false;
 		if (bus->dhd->up) {
 			if (bus->intr) {
-				DHD_INTR(("%s: enable SDIO device interrupts\n",
-					  __func__));
+				dhd_dbg(INTR,
+					"%s: enable SDIO device interrupts\n",
+					__func__);
 				bcmsdh_intr_enable(bus->sdh);
 			} else {
-				DHD_INTR(("%s: disable SDIO interrupts\n",
-					  __func__));
+				dhd_dbg(INTR, "%s: disable SDIO interrupts\n",
+					__func__);
 				bcmsdh_intr_disable(bus->sdh);
 			}
 		}
@@ -2245,25 +2268,27 @@ dhdsdio_doiovar(dhd_bus_t *bus, const bcm_iovar_t *vi, u32 actionid,
 			/* Do some validation */
 			dsize = set ? plen - (2 * sizeof(int)) : len;
 			if (dsize < size) {
-				DHD_ERROR(("%s: error on %s membytes, addr "
-				"0x%08x size %d dsize %d\n",
-				__func__, (set ? "set" : "get"),
-				address, size, dsize));
+				dhd_dbg(ERROR,
+					"%s: error on %s membytes, addr 0x%08x size %d dsize %d\n",
+					__func__, set ? "set" : "get",
+					address, size, dsize);
 				bcmerror = BCME_BADARG;
 				break;
 			}
 
-			DHD_INFO(("%s: Request to %s %d bytes at address "
-			"0x%08x\n",
-			__func__, (set ? "write" : "read"), size, address));
+			dhd_dbg(INFO,
+				"%s: Request to %s %d bytes at address 0x%08x\n",
+				__func__, set ? "write" : "read",
+				size, address);
 
 			/* If we know about SOCRAM, check for a fit */
 			if ((bus->orig_ramsize) &&
 			    ((address > bus->orig_ramsize)
 			     || (address + size > bus->orig_ramsize))) {
-				DHD_ERROR(("%s: ramsize 0x%08x doesn't have %d "
-				"bytes at 0x%08x\n",
-				__func__, bus->orig_ramsize, size, address));
+				dhd_dbg(ERROR,
+					"%s: ramsize 0x%08x doesn't have %d bytes at 0x%08x\n",
+					__func__, bus->orig_ramsize,
+					size, address);
 				bcmerror = BCME_BADARG;
 				break;
 			}
@@ -2490,17 +2515,17 @@ dhdsdio_doiovar(dhd_bus_t *bus, const bcm_iovar_t *vi, u32 actionid,
 #endif				/* SDTEST */
 
 	case IOV_SVAL(IOV_DEVRESET):
-		DHD_TRACE(("%s: Called set IOV_DEVRESET=%d dongle_reset=%d "
-			"busstate=%d\n",
+		dhd_dbg(TRACE,
+			"%s: Called set IOV_DEVRESET=%d dongle_reset=%d busstate=%d\n",
 			__func__, bool_val, bus->dhd->dongle_reset,
-			bus->dhd->busstate));
+			bus->dhd->busstate);
 
 		dhd_bus_devreset(bus->dhd, (u8) bool_val);
 
 		break;
 
 	case IOV_GVAL(IOV_DEVRESET):
-		DHD_TRACE(("%s: Called get IOV_DEVRESET\n", __func__));
+		dhd_dbg(TRACE, "%s: Called get IOV_DEVRESET\n", __func__);
 
 		/* Get its status */
 		int_val = (bool) bus->dhd->dongle_reset;
@@ -2555,7 +2580,7 @@ static int dhdsdio_write_vars(dhd_bus_t *bus)
 		    dhdsdio_membytes(bus, true, varaddr, vbuffer, varsize);
 #ifdef DHD_DEBUG
 		/* Verify NVRAM bytes */
-		DHD_INFO(("Compare NVRAM dl & ul; varsize=%d\n", varsize));
+		dhd_dbg(INFO, "Compare NVRAM dl & ul; varsize=%d\n", varsize);
 		nvram_ularray = kmalloc(varsize, GFP_ATOMIC);
 		if (!nvram_ularray)
 			return BCME_NOMEM;
@@ -2568,16 +2593,19 @@ static int dhdsdio_write_vars(dhd_bus_t *bus)
 		    dhdsdio_membytes(bus, false, varaddr, nvram_ularray,
 				     varsize);
 		if (bcmerror) {
-			DHD_ERROR(("%s: error %d on reading %d nvram bytes at "
-			"0x%08x\n", __func__, bcmerror, varsize, varaddr));
+			dhd_dbg(ERROR,
+				"%s: error %d on reading %d nvram bytes at 0x%08x\n",
+				__func__, bcmerror, varsize, varaddr);
 		}
 		/* Compare the org NVRAM with the one read from RAM */
 		if (memcmp(vbuffer, nvram_ularray, varsize)) {
-			DHD_ERROR(("%s: Downloaded NVRAM image is corrupted.\n",
-				   __func__));
+			dhd_dbg(ERROR,
+				"%s: Downloaded NVRAM image is corrupted\n",
+				__func__);
 		} else
-			DHD_ERROR(("%s: Download/Upload/Compare of NVRAM ok.\n",
-				__func__));
+			dhd_dbg(ERROR,
+				"%s: Download/Upload/Compare of NVRAM ok\n",
+				__func__);
 
 		kfree(nvram_ularray);
 #endif				/* DHD_DEBUG */
@@ -2586,9 +2614,9 @@ static int dhdsdio_write_vars(dhd_bus_t *bus)
 	}
 
 	/* adjust to the user specified RAM */
-	DHD_INFO(("Physical memory size: %d, usable memory size: %d\n",
-		  bus->orig_ramsize, bus->ramsize));
-	DHD_INFO(("Vars are at %d, orig varsize is %d\n", varaddr, varsize));
+	dhd_dbg(INFO, "Physical memory size: %d, usable memory size: %d\n",
+		bus->orig_ramsize, bus->ramsize);
+	dhd_dbg(INFO, "Vars are at %d, orig varsize is %d\n", varaddr, varsize);
 	varsize = ((bus->orig_ramsize - 4) - varaddr);
 
 	/*
@@ -2604,8 +2632,8 @@ static int dhdsdio_write_vars(dhd_bus_t *bus)
 		varsizew = cpu_to_le32(varsizew);
 	}
 
-	DHD_INFO(("New varsize is %d, length token=0x%08x\n", varsize,
-		  varsizew));
+	dhd_dbg(INFO, "New varsize is %d, length token=0x%08x\n",
+		varsize, varsizew);
 
 	/* Write the length token to the last word */
 	bcmerror = dhdsdio_membytes(bus, true, (bus->orig_ramsize - 4),
@@ -2642,15 +2670,16 @@ static int dhdsdio_download_state(dhd_bus_t *bus, bool enter)
 		regdata &= (SBTML_RESET | SBTML_REJ_MASK |
 			(SICF_CLOCK_EN << SBTML_SICF_SHIFT));
 		if ((SICF_CLOCK_EN << SBTML_SICF_SHIFT) != regdata) {
-			DHD_ERROR(("%s: SOCRAM core is down after reset?\n",
-				   __func__));
+			dhd_dbg(ERROR, "%s: SOCRAM core is down after reset?\n",
+				__func__);
 			bcmerror = BCME_ERROR;
 			goto fail;
 		}
 
 		bcmerror = dhdsdio_write_vars(bus);
 		if (bcmerror) {
-			DHD_ERROR(("%s: no vars written to RAM\n", __func__));
+			dhd_dbg(ERROR, "%s: no vars written to RAM\n",
+				__func__);
 			bcmerror = 0;
 		}
 
@@ -2677,7 +2706,7 @@ dhd_bus_iovar_op(dhd_pub_t *dhdp, const char *name,
 	int val_size;
 	u32 actionid;
 
-	DHD_TRACE(("%s: Enter\n", __func__));
+	dhd_dbg(TRACE, "%s: Enter\n", __func__);
 
 	ASSERT(name);
 	ASSERT(len >= 0);
@@ -2710,11 +2739,12 @@ dhd_bus_iovar_op(dhd_pub_t *dhdp, const char *name,
 					    &bus->sd_divisor, sizeof(s32),
 					    false) != 0) {
 				bus->sd_divisor = -1;
-				DHD_ERROR(("%s: fail on %s get\n", __func__,
-					   name));
+				dhd_dbg(ERROR, "%s: fail on %s get\n",
+					__func__, name);
 			} else {
-				DHD_INFO(("%s: noted %s update, value now %d\n",
-					  __func__, name, bus->sd_divisor));
+				dhd_dbg(INFO,
+					"%s: noted %s update, value now %d\n",
+					__func__, name, bus->sd_divisor);
 			}
 		}
 		/* If it was a mode change, read the new one */
@@ -2723,11 +2753,12 @@ dhd_bus_iovar_op(dhd_pub_t *dhdp, const char *name,
 					    &bus->sd_mode, sizeof(s32),
 					    false) != 0) {
 				bus->sd_mode = -1;
-				DHD_ERROR(("%s: fail on %s get\n", __func__,
-					   name));
+				dhd_dbg(ERROR, "%s: fail on %s get\n",
+					__func__, name);
 			} else {
-				DHD_INFO(("%s: noted %s update, value now %d\n",
-					  __func__, name, bus->sd_mode));
+				dhd_dbg(INFO,
+					"%s: noted %s update, value now %d\n",
+					__func__, name, bus->sd_mode);
 			}
 		}
 		/* Similar check for blocksize change */
@@ -2738,12 +2769,13 @@ dhd_bus_iovar_op(dhd_pub_t *dhdp, const char *name,
 			     &bus->blocksize, sizeof(s32),
 			     false) != 0) {
 				bus->blocksize = 0;
-				DHD_ERROR(("%s: fail on %s get\n", __func__,
-					   "sd_blocksize"));
+				dhd_dbg(ERROR, "%s: fail on %s get\n",
+					__func__, "sd_blocksize");
 			} else {
-				DHD_INFO(("%s: noted %s update, value now %d\n",
-					  __func__, "sd_blocksize",
-					  bus->blocksize));
+				dhd_dbg(INFO,
+					"%s: noted %s update, value now %d\n",
+					__func__, "sd_blocksize",
+					bus->blocksize);
 			}
 		}
 		bus->roundup = min(max_roundup, bus->blocksize);
@@ -2757,8 +2789,8 @@ dhd_bus_iovar_op(dhd_pub_t *dhdp, const char *name,
 		goto exit;
 	}
 
-	DHD_CTL(("%s: %s %s, len %d plen %d\n", __func__,
-		 name, (set ? "set" : "get"), len, plen));
+	dhd_dbg(CTL, "%s: %s %s, len %d plen %d\n",
+		__func__, name, (set ? "set" : "get"), len, plen);
 
 	/* set up 'params' pointer in case this is a set command so that
 	 * the convenience int and bool code can be common to set and get
@@ -2792,7 +2824,7 @@ void dhd_bus_stop(struct dhd_bus *bus, bool enforce_mutex)
 	uint retries;
 	int err;
 
-	DHD_TRACE(("%s: Enter\n", __func__));
+	dhd_dbg(TRACE, "%s: Enter\n", __func__);
 
 	if (enforce_mutex)
 		dhd_os_sdlock(bus->dhd);
@@ -2819,12 +2851,12 @@ void dhd_bus_stop(struct dhd_bus *bus, bool enforce_mutex)
 				 (saveclk | SBSDIO_FORCE_HT), &err);
 	}
 	if (err) {
-		DHD_ERROR(("%s: Failed to force clock for F2: err %d\n",
-			   __func__, err));
+		dhd_dbg(ERROR, "%s: Failed to force clock for F2: err %d\n",
+			__func__, err);
 	}
 
 	/* Turn off the bus (F2), free any pending packets */
-	DHD_INTR(("%s: disable SDIO interrupts\n", __func__));
+	dhd_dbg(INTR, "%s: disable SDIO interrupts\n", __func__);
 	bcmsdh_intr_disable(bus->sdh);
 	bcmsdh_cfg_write(bus->sdh, SDIO_FUNC_0, SDIOD_CCCR_IOEN,
 			 SDIO_FUNC_ENABLE_1, NULL);
@@ -2868,7 +2900,7 @@ int dhd_bus_init(dhd_pub_t *dhdp, bool enforce_mutex)
 	int err, ret = 0;
 	u8 saveclk;
 
-	DHD_TRACE(("%s: Enter\n", __func__));
+	dhd_dbg(TRACE, "%s: Enter\n", __func__);
 
 	ASSERT(bus->dhd);
 	if (!bus->dhd)
@@ -2891,8 +2923,8 @@ int dhd_bus_init(dhd_pub_t *dhdp, bool enforce_mutex)
 				 (saveclk | SBSDIO_FORCE_HT), &err);
 	}
 	if (err) {
-		DHD_ERROR(("%s: Failed to force clock for F2: err %d\n",
-			   __func__, err));
+		dhd_dbg(ERROR, "%s: Failed to force clock for F2: err %d\n",
+			__func__, err);
 		goto exit;
 	}
 
@@ -2912,8 +2944,8 @@ int dhd_bus_init(dhd_pub_t *dhdp, bool enforce_mutex)
 		    bcmsdh_cfg_read(bus->sdh, SDIO_FUNC_0, SDIOD_CCCR_IORDY,
 				    NULL);
 
-	DHD_INFO(("%s: enable 0x%02x, ready 0x%02x (waited %uus)\n",
-		  __func__, enable, ready, tmo.elapsed));
+	dhd_dbg(INFO, "%s: enable 0x%02x, ready 0x%02x (waited %uus)\n",
+		__func__, enable, ready, tmo.elapsed);
 
 	/* If F2 successfully enabled, set core and enable interrupts */
 	if (ready == enable) {
@@ -2933,11 +2965,12 @@ int dhd_bus_init(dhd_pub_t *dhdp, bool enforce_mutex)
 
 		bus->intdis = false;
 		if (bus->intr) {
-			DHD_INTR(("%s: enable SDIO device interrupts\n",
-				  __func__));
+			dhd_dbg(INTR, "%s: enable SDIO device interrupts\n",
+				__func__);
 			bcmsdh_intr_enable(bus->sdh);
 		} else {
-			DHD_INTR(("%s: disable SDIO interrupts\n", __func__));
+			dhd_dbg(INTR, "%s: disable SDIO interrupts\n",
+				__func__);
 			bcmsdh_intr_disable(bus->sdh);
 		}
 
@@ -2974,9 +3007,10 @@ static void dhdsdio_rxfail(dhd_bus_t *bus, bool abort, bool rtx)
 	u8 hi, lo;
 	int err;
 
-	DHD_ERROR(("%s: %sterminate frame%s\n", __func__,
-		   (abort ? "abort command, " : ""),
-		   (rtx ? ", send NAK" : "")));
+	dhd_dbg(ERROR, "%s: %sterminate frame%s\n",
+		__func__,
+		abort ? "abort command, " : "",
+		rtx ? ", send NAK" : "");
 
 	if (abort)
 		bcmsdh_abort(sdh, SDIO_FUNC_2);
@@ -2997,19 +3031,19 @@ static void dhdsdio_rxfail(dhd_bus_t *bus, bool abort, bool rtx)
 			break;
 
 		if ((hi > (lastrbc >> 8)) && (lo > (lastrbc & 0x00ff))) {
-			DHD_ERROR(("%s: count growing: last 0x%04x now "
-				"0x%04x\n",
-				__func__, lastrbc, ((hi << 8) + lo)));
+			dhd_dbg(ERROR,
+				"%s: count growing: last 0x%04x now 0x%04x\n",
+				__func__, lastrbc, ((hi << 8) + lo));
 		}
 		lastrbc = (hi << 8) + lo;
 	}
 
 	if (!retries) {
-		DHD_ERROR(("%s: count never zeroed: last 0x%04x\n",
-			   __func__, lastrbc));
+		dhd_dbg(ERROR, "%s: count never zeroed: last 0x%04x\n",
+			__func__, lastrbc);
 	} else {
-		DHD_INFO(("%s: flush took %d iterations\n", __func__,
-			  (0xffff - retries)));
+		dhd_dbg(INFO, "%s: flush took %d iterations\n",
+			__func__, (0xffff - retries));
 	}
 
 	if (rtx) {
@@ -3036,7 +3070,7 @@ dhdsdio_read_control(dhd_bus_t *bus, u8 *hdr, uint len, uint doff)
 
 	int sdret;
 
-	DHD_TRACE(("%s: Enter\n", __func__));
+	dhd_dbg(TRACE, "%s: Enter\n", __func__);
 
 	/* Control data already received in aligned rxctl */
 	if ((bus->bus == SPI_BUS) && (!bus->usebufpool))
@@ -3082,17 +3116,18 @@ dhdsdio_read_control(dhd_bus_t *bus, u8 *hdr, uint len, uint doff)
 
 	/* Drop if the read is too big or it exceeds our maximum */
 	if ((rdlen + firstread) > bus->dhd->maxctl) {
-		DHD_ERROR(("%s: %d-byte control read exceeds %d-byte buffer\n",
-			   __func__, rdlen, bus->dhd->maxctl));
+		dhd_dbg(ERROR,
+			"%s: %d-byte control read exceeds %d-byte buffer\n",
+			__func__, rdlen, bus->dhd->maxctl);
 		bus->dhd->rx_errors++;
 		dhdsdio_rxfail(bus, false, false);
 		goto done;
 	}
 
 	if ((len - doff) > bus->dhd->maxctl) {
-		DHD_ERROR(("%s: %d-byte ctl frame (%d-byte ctl data) exceeds "
-			"%d-byte limit\n",
-			__func__, len, (len - doff), bus->dhd->maxctl));
+		dhd_dbg(ERROR,
+			"%s: %d-byte ctl frame (%d-byte ctl data) exceeds %d-byte limit\n",
+			__func__, len, (len - doff), bus->dhd->maxctl);
 		bus->dhd->rx_errors++;
 		bus->rx_toolong++;
 		dhdsdio_rxfail(bus, false, false);
@@ -3109,8 +3144,8 @@ dhdsdio_read_control(dhd_bus_t *bus, u8 *hdr, uint len, uint doff)
 
 	/* Control frame failures need retransmission */
 	if (sdret < 0) {
-		DHD_ERROR(("%s: read %d control bytes failed: %d\n",
-			   __func__, rdlen, sdret));
+		dhd_dbg(ERROR, "%s: read %d control bytes failed: %d\n",
+			__func__, rdlen, sdret);
 		bus->rxc_errors++;	/* dhd.rx_ctlerrs is higher level */
 		dhdsdio_rxfail(bus, true, true);
 		goto done;
@@ -3150,8 +3185,8 @@ static u8 dhdsdio_rxglom(dhd_bus_t *bus, u8 rxseq)
 	/* If packets, issue read(s) and send up packet chain */
 	/* Return sequence numbers consumed? */
 
-	DHD_TRACE(("dhdsdio_rxglom: start: glomd %p glom %p\n", bus->glomd,
-		   bus->glom));
+	dhd_dbg(TRACE, "%s: start: glomd %p glom %p\n",
+		__func__, bus->glomd, bus->glom);
 
 	/* If there's a descriptor, generate the packet chain */
 	if (bus->glomd) {
@@ -3161,8 +3196,9 @@ static u8 dhdsdio_rxglom(dhd_bus_t *bus, u8 rxseq)
 		dlen = (u16) (bus->glomd->len);
 		dptr = bus->glomd->data;
 		if (!dlen || (dlen & 1)) {
-			DHD_ERROR(("%s: bad glomd len(%d), ignore descriptor\n",
-			__func__, dlen));
+			dhd_dbg(ERROR,
+				"%s: bad glomd len(%d), ignore descriptor\n",
+				__func__, dlen);
 			dlen = 0;
 		}
 
@@ -3173,14 +3209,16 @@ static u8 dhdsdio_rxglom(dhd_bus_t *bus, u8 rxseq)
 			dptr += sizeof(u16);
 			if ((sublen < SDPCM_HDRLEN) ||
 			    ((num == 0) && (sublen < (2 * SDPCM_HDRLEN)))) {
-				DHD_ERROR(("%s: descriptor len %d bad: %d\n",
-					   __func__, num, sublen));
+				dhd_dbg(ERROR,
+					"%s: descriptor len %d bad: %d\n",
+					__func__, num, sublen);
 				pnext = NULL;
 				break;
 			}
 			if (sublen % DHD_SDALIGN) {
-				DHD_ERROR(("%s: sublen %d not multiple of %d\n",
-				__func__, sublen, DHD_SDALIGN));
+				dhd_dbg(ERROR,
+					"%s: sublen %d not multiple of %d\n",
+					__func__, sublen, DHD_SDALIGN);
 				usechain = false;
 			}
 			totlen += sublen;
@@ -3196,8 +3234,9 @@ static u8 dhdsdio_rxglom(dhd_bus_t *bus, u8 rxseq)
 			/* Allocate/chain packet for next subframe */
 			pnext = pkt_buf_get_skb(sublen + DHD_SDALIGN);
 			if (pnext == NULL) {
-				DHD_ERROR(("%s: pkt_buf_get_skb failed, num %d len %d\n",
-					   __func__, num, sublen));
+				dhd_dbg(ERROR,
+					"%s: pkt_buf_get_skb failed, num %d len %d\n",
+					__func__, num, sublen);
 				break;
 			}
 			ASSERT(!(pnext->prev));
@@ -3217,13 +3256,15 @@ static u8 dhdsdio_rxglom(dhd_bus_t *bus, u8 rxseq)
 		/* If all allocations succeeded, save packet chain
 			 in bus structure */
 		if (pnext) {
-			DHD_GLOM(("%s: allocated %d-byte packet chain for %d "
-				"subframes\n", __func__, totlen, num));
+			dhd_dbg(GLOM,
+				"%s: allocated %d-byte packet chain for %d subframes\n",
+				__func__, totlen, num);
 			if (DHD_GLOM_ON() && bus->nextlen) {
 				if (totlen != bus->nextlen) {
-					DHD_GLOM(("%s: glomdesc mismatch: nextlen %d glomdesc %d " "rxseq %d\n",
+					dhd_dbg(GLOM,
+						"%s: glomdesc mismatch: nextlen %d glomdesc %d rxseq %d\n",
 						__func__, bus->nextlen,
-						totlen, rxseq));
+						totlen, rxseq);
 				}
 			}
 			bus->glom = pfirst;
@@ -3247,12 +3288,14 @@ static u8 dhdsdio_rxglom(dhd_bus_t *bus, u8 rxseq)
 		 or had one from before */
 	if (bus->glom) {
 		if (DHD_GLOM_ON()) {
-			DHD_GLOM(("%s: try superframe read, packet chain:\n",
-				__func__));
+			dhd_dbg(GLOM,
+				"%s: try superframe read, packet chain:\n",
+				__func__);
 			for (pnext = bus->glom; pnext; pnext = pnext->next) {
-				DHD_GLOM(("    %p: %p len 0x%04x (%d)\n",
-					  pnext, (u8 *) (pnext->data),
-					  pnext->len, pnext->len));
+				dhd_dbg(GLOM,
+					"    %p: %p len 0x%04x (%d)\n",
+					pnext, (u8 *) (pnext->data),
+					pnext->len, pnext->len);
 			}
 		}
 
@@ -3280,14 +3323,16 @@ static u8 dhdsdio_rxglom(dhd_bus_t *bus, u8 rxseq)
 			    (u16) pktfrombuf(pfirst, 0, dlen,
 						bus->dataptr);
 			if (sublen != dlen) {
-				DHD_ERROR(("%s: FAILED TO COPY, dlen %d sublen %d\n",
-					__func__, dlen, sublen));
+				dhd_dbg(ERROR,
+					"%s: FAILED TO COPY, dlen %d sublen %d\n",
+					__func__, dlen, sublen);
 				errcode = -1;
 			}
 			pnext = NULL;
 		} else {
-			DHD_ERROR(("COULDN'T ALLOC %d-BYTE GLOM, FORCE FAILURE\n",
-				dlen));
+			dhd_dbg(ERROR,
+				"COULDN'T ALLOC %d-BYTE GLOM, FORCE FAILURE\n",
+				dlen);
 			errcode = -1;
 		}
 		bus->f2rxdata++;
@@ -3295,8 +3340,8 @@ static u8 dhdsdio_rxglom(dhd_bus_t *bus, u8 rxseq)
 
 		/* On failure, kill the superframe, allow a couple retries */
 		if (errcode < 0) {
-			DHD_ERROR(("%s: glom read of %d bytes failed: %d\n",
-				   __func__, dlen, errcode));
+			dhd_dbg(ERROR, "%s: glom read of %d bytes failed: %d\n",
+				__func__, dlen, errcode);
 			bus->dhd->rx_errors++;
 
 			if (bus->glomerr++ < 3) {
@@ -3328,8 +3373,8 @@ static u8 dhdsdio_rxglom(dhd_bus_t *bus, u8 rxseq)
 		seq = SDPCM_PACKET_SEQUENCE(&dptr[SDPCM_FRAMETAG_LEN]);
 		bus->nextlen = dptr[SDPCM_FRAMETAG_LEN + SDPCM_NEXTLEN_OFFSET];
 		if ((bus->nextlen << 4) > MAX_RX_DATASZ) {
-			DHD_INFO(("%s: nextlen too large (%d) seq %d\n",
-				__func__, bus->nextlen, seq));
+			dhd_dbg(INFO, "%s: nextlen too large (%d) seq %d\n",
+				__func__, bus->nextlen, seq);
 			bus->nextlen = 0;
 		}
 		doff = SDPCM_DOFFSET_VALUE(&dptr[SDPCM_FRAMETAG_LEN]);
@@ -3337,47 +3382,51 @@ static u8 dhdsdio_rxglom(dhd_bus_t *bus, u8 rxseq)
 
 		errcode = 0;
 		if ((u16)~(sublen ^ check)) {
-			DHD_ERROR(("%s (superframe): HW hdr error: len/check "
-				"0x%04x/0x%04x\n", __func__, sublen, check));
+			dhd_dbg(ERROR,
+				"%s (superframe): HW hdr error: len/check 0x%04x/0x%04x\n",
+				__func__, sublen, check);
 			errcode = -1;
 		} else if (roundup(sublen, bus->blocksize) != dlen) {
-			DHD_ERROR(("%s (superframe): len 0x%04x, rounded "
-				"0x%04x, expect 0x%04x\n",
+			dhd_dbg(ERROR,
+				"%s (superframe): len 0x%04x, rounded 0x%04x, expect 0x%04x\n",
 				__func__, sublen,
-				roundup(sublen, bus->blocksize), dlen));
+				roundup(sublen, bus->blocksize), dlen);
 			errcode = -1;
 		} else if (SDPCM_PACKET_CHANNEL(&dptr[SDPCM_FRAMETAG_LEN]) !=
 			   SDPCM_GLOM_CHANNEL) {
-			DHD_ERROR(("%s (superframe): bad channel %d\n",
-				   __func__,
-				   SDPCM_PACKET_CHANNEL(&dptr
-							[SDPCM_FRAMETAG_LEN])));
+			dhd_dbg(ERROR, "%s (superframe): bad channel %d\n",
+				__func__,
+				SDPCM_PACKET_CHANNEL(&dptr
+						     [SDPCM_FRAMETAG_LEN]));
 			errcode = -1;
 		} else if (SDPCM_GLOMDESC(&dptr[SDPCM_FRAMETAG_LEN])) {
-			DHD_ERROR(("%s (superframe): got second descriptor?\n",
-				   __func__));
+			dhd_dbg(ERROR,
+				"%s (superframe): got second descriptor?\n",
+				__func__);
 			errcode = -1;
 		} else if ((doff < SDPCM_HDRLEN) ||
 			   (doff > (pfirst->len - SDPCM_HDRLEN))) {
-			DHD_ERROR(("%s (superframe): Bad data offset %d: HW %d "
-				"pkt %d min %d\n",
-				__func__, doff, sublen,
-				pfirst->len, SDPCM_HDRLEN));
+			dhd_dbg(ERROR,
+				"%s (superframe): Bad data offset %d: HW %d pkt %d min %d\n",
+				__func__, doff, sublen, pfirst->len,
+				SDPCM_HDRLEN);
 			errcode = -1;
 		}
 
 		/* Check sequence number of superframe SW header */
 		if (rxseq != seq) {
-			DHD_INFO(("%s: (superframe) rx_seq %d, expected %d\n",
-				  __func__, seq, rxseq));
+			dhd_dbg(INFO,
+				"%s: (superframe) rx_seq %d, expected %d\n",
+				__func__, seq, rxseq);
 			bus->rx_badseq++;
 			rxseq = seq;
 		}
 
 		/* Check window for sanity */
 		if ((u8) (txmax - bus->tx_seq) > 0x40) {
-			DHD_ERROR(("%s: unlikely tx max %d with tx_seq %d\n",
-				__func__, txmax, bus->tx_seq));
+			dhd_dbg(ERROR,
+				"%s: unlikely tx max %d with tx_seq %d\n",
+				__func__, txmax, bus->tx_seq);
 			txmax = bus->tx_seq + 2;
 		}
 		bus->tx_max = txmax;
@@ -3401,24 +3450,26 @@ static u8 dhdsdio_rxglom(dhd_bus_t *bus, u8 rxseq)
 #endif
 
 			if ((u16)~(sublen ^ check)) {
-				DHD_ERROR(("%s (subframe %d): HW hdr error: "
-					   "len/check 0x%04x/0x%04x\n",
-					   __func__, num, sublen, check));
+				dhd_dbg(ERROR,
+					"%s (subframe %d): HW hdr error: len/check 0x%04x/0x%04x\n",
+					__func__, num, sublen, check);
 				errcode = -1;
 			} else if ((sublen > dlen) || (sublen < SDPCM_HDRLEN)) {
-				DHD_ERROR(("%s (subframe %d): length mismatch: "
-					   "len 0x%04x, expect 0x%04x\n",
-					   __func__, num, sublen, dlen));
+				dhd_dbg(ERROR,
+					"%s (subframe %d): length mismatch: len 0x%04x, expect 0x%04x\n",
+					__func__, num, sublen, dlen);
 				errcode = -1;
 			} else if ((chan != SDPCM_DATA_CHANNEL) &&
 				   (chan != SDPCM_EVENT_CHANNEL)) {
-				DHD_ERROR(("%s (subframe %d): bad channel %d\n",
-					   __func__, num, chan));
+				dhd_dbg(ERROR,
+					"%s (subframe %d): bad channel %d\n",
+					__func__, num, chan);
 				errcode = -1;
 			} else if ((doff < SDPCM_HDRLEN) || (doff > sublen)) {
-				DHD_ERROR(("%s (subframe %d): Bad data offset %d: HW %d min %d\n",
+				dhd_dbg(ERROR,
+					"%s (subframe %d): Bad data offset %d: HW %d min %d\n",
 					__func__, num, doff, sublen,
-					SDPCM_HDRLEN));
+					SDPCM_HDRLEN);
 				errcode = -1;
 			}
 		}
@@ -3459,17 +3510,17 @@ static u8 dhdsdio_rxglom(dhd_bus_t *bus, u8 rxseq)
 			seq = SDPCM_PACKET_SEQUENCE(&dptr[SDPCM_FRAMETAG_LEN]);
 			doff = SDPCM_DOFFSET_VALUE(&dptr[SDPCM_FRAMETAG_LEN]);
 
-			DHD_GLOM(("%s: Get subframe %d, %p(%p/%d), sublen %d "
-				"chan %d seq %d\n",
+			dhd_dbg(GLOM,
+				"%s: Get subframe %d, %p(%p/%d), sublen %d chan %d seq %d\n",
 				__func__, num, pfirst, pfirst->data,
-				pfirst->len, sublen, chan, seq));
+				pfirst->len, sublen, chan, seq);
 
 			ASSERT((chan == SDPCM_DATA_CHANNEL)
 			       || (chan == SDPCM_EVENT_CHANNEL));
 
 			if (rxseq != seq) {
-				DHD_GLOM(("%s: rx_seq %d, expected %d\n",
-					  __func__, seq, rxseq));
+				dhd_dbg(GLOM, "%s: rx_seq %d, expected %d\n",
+					__func__, seq, rxseq);
 				bus->rx_badseq++;
 				rxseq = seq;
 			}
@@ -3492,8 +3543,8 @@ static u8 dhdsdio_rxglom(dhd_bus_t *bus, u8 rxseq)
 				continue;
 			} else if (dhd_prot_hdrpull(bus->dhd, &ifidx, pfirst) !=
 				   0) {
-				DHD_ERROR(("%s: rx protocol error\n",
-					   __func__));
+				dhd_dbg(ERROR, "%s: rx protocol error\n",
+					__func__);
 				bus->dhd->rx_errors++;
 				pkt_buf_free_skb(pfirst);
 				if (plast) {
@@ -3513,11 +3564,11 @@ static u8 dhdsdio_rxglom(dhd_bus_t *bus, u8 rxseq)
 
 #ifdef DHD_DEBUG
 			if (DHD_GLOM_ON()) {
-				DHD_GLOM(("%s subframe %d to stack, %p(%p/%d) "
-				"nxt/lnk %p/%p\n",
-				__func__, num, pfirst, pfirst->data,
-				pfirst->len, pfirst->next,
-				pfirst->prev));
+				dhd_dbg(GLOM,
+					"%s subframe %d to stack, %p(%p/%d) nxt/lnk %p/%p\n",
+					__func__, num, pfirst, pfirst->data,
+					pfirst->len, pfirst->next,
+					pfirst->prev);
 				prhex("", (u8 *) pfirst->data,
 				      min_t(int, pfirst->len, 32));
 			}
@@ -3563,7 +3614,7 @@ static uint dhdsdio_readframes(dhd_bus_t *bus, uint maxframes, bool *finished)
 	bool sdtest = false;	/* To limit message spew from test mode */
 #endif
 
-	DHD_TRACE(("%s: Enter\n", __func__));
+	dhd_dbg(TRACE, "%s: Enter\n", __func__);
 
 	ASSERT(maxframes);
 
@@ -3585,10 +3636,11 @@ static uint dhdsdio_readframes(dhd_bus_t *bus, uint maxframes, bool *finished)
 		/* Handle glomming separately */
 		if (bus->glom || bus->glomd) {
 			u8 cnt;
-			DHD_GLOM(("%s: calling rxglom: glomd %p, glom %p\n",
-				  __func__, bus->glomd, bus->glom));
+			dhd_dbg(GLOM, "%s: calling rxglom: glomd %p, glom %p\n",
+				__func__, bus->glomd, bus->glom);
 			cnt = dhdsdio_rxglom(bus, rxseq);
-			DHD_GLOM(("%s: rxglom returned %d\n", __func__, cnt));
+			dhd_dbg(GLOM, "%s: rxglom returned %d\n",
+				__func__, cnt);
 			rxseq += cnt - 1;
 			rxleft = (rxleft > cnt) ? (rxleft - cnt) : 1;
 			continue;
@@ -3664,9 +3716,9 @@ static uint dhdsdio_readframes(dhd_bus_t *bus, uint maxframes, bool *finished)
 					/* Control frame failures need
 					 retransmission */
 					if (sdret < 0) {
-						DHD_ERROR(("%s: read %d control bytes failed: %d\n",
-							__func__,
-							rdlen, sdret));
+						dhd_dbg(ERROR,
+							"%s: read %d control bytes failed: %d\n",
+							__func__, rdlen, sdret);
 						/* dhd.rx_ctlerrs is higher */
 						bus->rxc_errors++;
 						dhd_os_sdunlock_rxq(bus->dhd);
@@ -3679,8 +3731,9 @@ static uint dhdsdio_readframes(dhd_bus_t *bus, uint maxframes, bool *finished)
 				} else {
 					/* Give up on data,
 					request rtx of events */
-					DHD_ERROR(("%s (nextlen): pkt_buf_get_skb failed: len %d rdlen %d " "expected rxseq %d\n",
-						__func__, len, rdlen, rxseq));
+					dhd_dbg(ERROR,
+						"%s (nextlen): pkt_buf_get_skb failed: len %d rdlen %d expected rxseq %d\n",
+						__func__, len, rdlen, rxseq);
 					/* Just go try again w/normal
 					header read */
 					dhd_os_sdunlock_rxq(bus->dhd);
@@ -3704,8 +3757,9 @@ static uint dhdsdio_readframes(dhd_bus_t *bus, uint maxframes, bool *finished)
 				ASSERT(sdret != BCME_PENDING);
 
 				if (sdret < 0) {
-					DHD_ERROR(("%s (nextlen): read %d bytes failed: %d\n",
-						__func__, rdlen, sdret));
+					dhd_dbg(ERROR,
+						"%s (nextlen): read %d bytes failed: %d\n",
+						__func__, rdlen, sdret);
 					pkt_buf_free_skb(pkt);
 					bus->dhd->rx_errors++;
 					dhd_os_sdunlock_rxq(bus->dhd);
@@ -3731,8 +3785,9 @@ static uint dhdsdio_readframes(dhd_bus_t *bus, uint maxframes, bool *finished)
 
 			/* All zeros means readahead info was bad */
 			if (!(len | check)) {
-				DHD_INFO(("%s (nextlen): read zeros in HW "
-					"header???\n", __func__));
+				dhd_dbg(INFO,
+					"%s (nextlen): read zeros in HW header???\n",
+					__func__);
 				dhd_os_sdlock_rxq(bus->dhd);
 				PKTFREE2();
 				dhd_os_sdunlock_rxq(bus->dhd);
@@ -3742,8 +3797,9 @@ static uint dhdsdio_readframes(dhd_bus_t *bus, uint maxframes, bool *finished)
 
 			/* Validate check bytes */
 			if ((u16)~(len ^ check)) {
-				DHD_ERROR(("%s (nextlen): HW hdr error: nextlen/len/check" " 0x%04x/0x%04x/0x%04x\n",
-					__func__, nextlen, len, check));
+				dhd_dbg(ERROR,
+					"%s (nextlen): HW hdr error: nextlen/len/check 0x%04x/0x%04x/0x%04x\n",
+					__func__, nextlen, len, check);
 				dhd_os_sdlock_rxq(bus->dhd);
 				PKTFREE2();
 				dhd_os_sdunlock_rxq(bus->dhd);
@@ -3755,8 +3811,9 @@ static uint dhdsdio_readframes(dhd_bus_t *bus, uint maxframes, bool *finished)
 
 			/* Validate frame length */
 			if (len < SDPCM_HDRLEN) {
-				DHD_ERROR(("%s (nextlen): HW hdr length "
-					"invalid: %d\n", __func__, len));
+				dhd_dbg(ERROR,
+					"%s (nextlen): HW hdr length invalid: %d\n",
+					__func__, len);
 				dhd_os_sdlock_rxq(bus->dhd);
 				PKTFREE2();
 				dhd_os_sdunlock_rxq(bus->dhd);
@@ -3769,9 +3826,10 @@ static uint dhdsdio_readframes(dhd_bus_t *bus, uint maxframes, bool *finished)
 			if (len_consistent) {
 				/* Mismatch, force retry w/normal
 					header (may be >4K) */
-				DHD_ERROR(("%s (nextlen): mismatch, nextlen %d len %d rnd %d; " "expected rxseq %d\n",
+				dhd_dbg(ERROR,
+					"%s (nextlen): mismatch, nextlen %d len %d rnd %d; expected rxseq %d\n",
 					__func__, nextlen,
-					len, roundup(len, 16), rxseq));
+					len, roundup(len, 16), rxseq);
 				dhd_os_sdlock_rxq(bus->dhd);
 				PKTFREE2();
 				dhd_os_sdunlock_rxq(bus->dhd);
@@ -3799,8 +3857,9 @@ static uint dhdsdio_readframes(dhd_bus_t *bus, uint maxframes, bool *finished)
 			    bus->rxhdr[SDPCM_FRAMETAG_LEN +
 				       SDPCM_NEXTLEN_OFFSET];
 			if ((bus->nextlen << 4) > MAX_RX_DATASZ) {
-				DHD_INFO(("%s (nextlen): got frame w/nextlen too large" " (%d), seq %d\n",
-					__func__, bus->nextlen, seq));
+				dhd_dbg(INFO,
+					"%s (nextlen): got frame w/nextlen too large (%d), seq %d\n",
+					__func__, bus->nextlen, seq);
 				bus->nextlen = 0;
 			}
 
@@ -3826,17 +3885,18 @@ static uint dhdsdio_readframes(dhd_bus_t *bus, uint maxframes, bool *finished)
 
 			/* Check and update sequence number */
 			if (rxseq != seq) {
-				DHD_INFO(("%s (nextlen): rx_seq %d, expected "
-					"%d\n", __func__, seq, rxseq));
+				dhd_dbg(INFO,
+					"%s (nextlen): rx_seq %d, expected %d\n",
+					__func__, seq, rxseq);
 				bus->rx_badseq++;
 				rxseq = seq;
 			}
 
 			/* Check window for sanity */
 			if ((u8) (txmax - bus->tx_seq) > 0x40) {
-				DHD_ERROR(("%s: got unlikely tx max %d with "
-					"tx_seq %d\n",
-					__func__, txmax, bus->tx_seq));
+				dhd_dbg(ERROR,
+					"%s: got unlikely tx max %d with tx_seq %d\n",
+					__func__, txmax, bus->tx_seq);
 				txmax = bus->tx_seq + 2;
 			}
 			bus->tx_max = txmax;
@@ -3859,8 +3919,9 @@ static uint dhdsdio_readframes(dhd_bus_t *bus, uint maxframes, bool *finished)
 					}
 					continue;
 				} else {
-					DHD_ERROR(("%s (nextlen): readahead on control" " packet %d?\n",
-						__func__, seq));
+					dhd_dbg(ERROR,
+						"%s (nextlen): readahead on control packet %d?\n",
+						__func__, seq);
 					/* Force retry w/normal header read */
 					bus->nextlen = 0;
 					dhdsdio_rxfail(bus, false, true);
@@ -3872,15 +3933,17 @@ static uint dhdsdio_readframes(dhd_bus_t *bus, uint maxframes, bool *finished)
 			}
 
 			if ((bus->bus == SPI_BUS) && !bus->usebufpool) {
-				DHD_ERROR(("Received %d bytes on %d channel. Running out of " "rx pktbuf's or not yet malloced.\n",
-					len, chan));
+				dhd_dbg(ERROR,
+					"Received %d bytes on %d channel. Running out of rx pktbuf's or not yet malloced.\n",
+					len, chan);
 				continue;
 			}
 
 			/* Validate data offset */
 			if ((doff < SDPCM_HDRLEN) || (doff > len)) {
-				DHD_ERROR(("%s (nextlen): bad data offset %d: HW len %d min %d\n",
-					__func__, doff, len, SDPCM_HDRLEN));
+				dhd_dbg(ERROR,
+					"%s (nextlen): bad data offset %d: HW len %d min %d\n",
+					__func__, doff, len, SDPCM_HDRLEN);
 				dhd_os_sdlock_rxq(bus->dhd);
 				PKTFREE2();
 				dhd_os_sdunlock_rxq(bus->dhd);
@@ -3905,8 +3968,8 @@ static uint dhdsdio_readframes(dhd_bus_t *bus, uint maxframes, bool *finished)
 		ASSERT(sdret != BCME_PENDING);
 
 		if (sdret < 0) {
-			DHD_ERROR(("%s: RXHEADER FAILED: %d\n", __func__,
-				   sdret));
+			dhd_dbg(ERROR, "%s: RXHEADER FAILED: %d\n",
+				__func__, sdret);
 			bus->rx_hdrfail++;
 			dhdsdio_rxfail(bus, true, true);
 			continue;
@@ -3928,8 +3991,9 @@ static uint dhdsdio_readframes(dhd_bus_t *bus, uint maxframes, bool *finished)
 
 		/* Validate check bytes */
 		if ((u16) ~(len ^ check)) {
-			DHD_ERROR(("%s: HW hdr err: len/check 0x%04x/0x%04x\n",
-				__func__, len, check));
+			dhd_dbg(ERROR,
+				"%s: HW hdr err: len/check 0x%04x/0x%04x\n",
+				__func__, len, check);
 			bus->rx_badhdr++;
 			dhdsdio_rxfail(bus, false, false);
 			continue;
@@ -3937,8 +4001,8 @@ static uint dhdsdio_readframes(dhd_bus_t *bus, uint maxframes, bool *finished)
 
 		/* Validate frame length */
 		if (len < SDPCM_HDRLEN) {
-			DHD_ERROR(("%s: HW hdr length invalid: %d\n",
-				   __func__, len));
+			dhd_dbg(ERROR, "%s: HW hdr length invalid: %d\n",
+				__func__, len);
 			continue;
 		}
 
@@ -3950,9 +4014,9 @@ static uint dhdsdio_readframes(dhd_bus_t *bus, uint maxframes, bool *finished)
 
 		/* Validate data offset */
 		if ((doff < SDPCM_HDRLEN) || (doff > len)) {
-			DHD_ERROR(("%s: Bad data offset %d: HW len %d, min %d "
-				"seq %d\n",
-				__func__, doff, len, SDPCM_HDRLEN, seq));
+			dhd_dbg(ERROR,
+				"%s: Bad data offset %d: HW len %d, min %d seq %d\n",
+				__func__, doff, len, SDPCM_HDRLEN, seq);
 			bus->rx_badhdr++;
 			ASSERT(0);
 			dhdsdio_rxfail(bus, false, false);
@@ -3963,9 +4027,9 @@ static uint dhdsdio_readframes(dhd_bus_t *bus, uint maxframes, bool *finished)
 		bus->nextlen =
 		    bus->rxhdr[SDPCM_FRAMETAG_LEN + SDPCM_NEXTLEN_OFFSET];
 		if ((bus->nextlen << 4) > MAX_RX_DATASZ) {
-			DHD_INFO(("%s (nextlen): got frame w/nextlen too large "
-				"(%d), seq %d\n",
-				__func__, bus->nextlen, seq));
+			dhd_dbg(INFO,
+				"%s (nextlen): got frame w/nextlen too large (%d), seq %d\n",
+				__func__, bus->nextlen, seq);
 			bus->nextlen = 0;
 		}
 
@@ -3989,16 +4053,17 @@ static uint dhdsdio_readframes(dhd_bus_t *bus, uint maxframes, bool *finished)
 
 		/* Check and update sequence number */
 		if (rxseq != seq) {
-			DHD_INFO(("%s: rx_seq %d, expected %d\n", __func__,
-				  seq, rxseq));
+			dhd_dbg(INFO, "%s: rx_seq %d, expected %d\n",
+				__func__, seq, rxseq);
 			bus->rx_badseq++;
 			rxseq = seq;
 		}
 
 		/* Check window for sanity */
 		if ((u8) (txmax - bus->tx_seq) > 0x40) {
-			DHD_ERROR(("%s: unlikely tx max %d with tx_seq %d\n",
-				__func__, txmax, bus->tx_seq));
+			dhd_dbg(ERROR,
+				"%s: unlikely tx max %d with tx_seq %d\n",
+				__func__, txmax, bus->tx_seq);
 			txmax = bus->tx_seq + 2;
 		}
 		bus->tx_max = txmax;
@@ -4034,8 +4099,8 @@ static uint dhdsdio_readframes(dhd_bus_t *bus, uint maxframes, bool *finished)
 
 		if ((rdlen + firstread) > MAX_RX_DATASZ) {
 			/* Too long -- skip this frame */
-			DHD_ERROR(("%s: too long: len %d rdlen %d\n",
-				   __func__, len, rdlen));
+			dhd_dbg(ERROR, "%s: too long: len %d rdlen %d\n",
+				__func__, len, rdlen);
 			bus->dhd->rx_errors++;
 			bus->rx_toolong++;
 			dhdsdio_rxfail(bus, false, false);
@@ -4046,8 +4111,9 @@ static uint dhdsdio_readframes(dhd_bus_t *bus, uint maxframes, bool *finished)
 		pkt = pkt_buf_get_skb(rdlen + firstread + DHD_SDALIGN);
 		if (!pkt) {
 			/* Give up on data, request rtx of events */
-			DHD_ERROR(("%s: pkt_buf_get_skb failed: rdlen %d chan %d\n",
-				   __func__, rdlen, chan));
+			dhd_dbg(ERROR,
+				"%s: pkt_buf_get_skb failed: rdlen %d chan %d\n",
+				__func__, rdlen, chan);
 			bus->dhd->rx_dropped++;
 			dhd_os_sdunlock_rxq(bus->dhd);
 			dhdsdio_rxfail(bus, false, RETRYCHAN(chan));
@@ -4071,13 +4137,11 @@ static uint dhdsdio_readframes(dhd_bus_t *bus, uint maxframes, bool *finished)
 		ASSERT(sdret != BCME_PENDING);
 
 		if (sdret < 0) {
-			DHD_ERROR(("%s: read %d %s bytes failed: %d\n",
-				   __func__, rdlen,
-				   ((chan ==
-				     SDPCM_EVENT_CHANNEL) ? "event" : ((chan ==
-					SDPCM_DATA_CHANNEL)
-				       ? "data" : "test")),
-				   sdret));
+			dhd_dbg(ERROR, "%s: read %d %s bytes failed: %d\n",
+				__func__, rdlen,
+				chan == SDPCM_EVENT_CHANNEL ? "event" :
+				chan == SDPCM_DATA_CHANNEL ? "data" : "test",
+				sdret);
 			dhd_os_sdlock_rxq(bus->dhd);
 			pkt_buf_free_skb(pkt);
 			dhd_os_sdunlock_rxq(bus->dhd);
@@ -4099,8 +4163,9 @@ deliver:
 		/* Save superframe descriptor and allocate packet frame */
 		if (chan == SDPCM_GLOM_CHANNEL) {
 			if (SDPCM_GLOMDESC(&bus->rxhdr[SDPCM_FRAMETAG_LEN])) {
-				DHD_GLOM(("%s: glom descriptor, %d bytes:\n",
-					__func__, len));
+				dhd_dbg(GLOM,
+					"%s: glom descriptor, %d bytes:\n",
+					__func__, len);
 #ifdef DHD_DEBUG
 				if (DHD_GLOM_ON()) {
 					prhex("Glom Data", pkt->data, len);
@@ -4111,8 +4176,9 @@ deliver:
 				skb_pull(pkt, SDPCM_HDRLEN);
 				bus->glomd = pkt;
 			} else {
-				DHD_ERROR(("%s: glom superframe w/o "
-					"descriptor!\n", __func__));
+				dhd_dbg(ERROR,
+					"%s: glom superframe w/o descriptor!\n",
+					__func__);
 				dhdsdio_rxfail(bus, false, false);
 			}
 			continue;
@@ -4136,7 +4202,7 @@ deliver:
 			dhd_os_sdunlock_rxq(bus->dhd);
 			continue;
 		} else if (dhd_prot_hdrpull(bus->dhd, &ifidx, pkt) != 0) {
-			DHD_ERROR(("%s: rx protocol error\n", __func__));
+			dhd_dbg(ERROR, "%s: rx protocol error\n", __func__);
 			dhd_os_sdlock_rxq(bus->dhd);
 			pkt_buf_free_skb(pkt);
 			dhd_os_sdunlock_rxq(bus->dhd);
@@ -4153,11 +4219,11 @@ deliver:
 #ifdef DHD_DEBUG
 	/* Message if we hit the limit */
 	if (!rxleft && !sdtest)
-		DHD_DATA(("%s: hit rx limit of %d frames\n", __func__,
-			  maxframes));
+		dhd_dbg(DATA, "%s: hit rx limit of %d frames\n",
+			__func__, maxframes);
 	else
 #endif				/* DHD_DEBUG */
-		DHD_DATA(("%s: processed %d frames\n", __func__, rxcount));
+		dhd_dbg(DATA, "%s: processed %d frames\n", __func__, rxcount);
 	/* Back off rxseq if awaiting rtx, update rx_seq */
 	if (bus->rxskip)
 		rxseq--;
@@ -4174,7 +4240,7 @@ static u32 dhdsdio_hostmail(dhd_bus_t *bus)
 	u8 fcbits;
 	uint retries = 0;
 
-	DHD_TRACE(("%s: Enter\n", __func__));
+	dhd_dbg(TRACE, "%s: Enter\n", __func__);
 
 	/* Read mailbox data and ack that we did so */
 	R_SDREG(hmb_data, &regs->tohostmailboxdata, retries);
@@ -4184,10 +4250,11 @@ static u32 dhdsdio_hostmail(dhd_bus_t *bus)
 
 	/* Dongle recomposed rx frames, accept them again */
 	if (hmb_data & HMB_DATA_NAKHANDLED) {
-		DHD_INFO(("Dongle reports NAK handled, expect rtx of %d\n",
-			  bus->rx_seq));
+		dhd_dbg(INFO, "Dongle reports NAK handled, expect rtx of %d\n",
+			bus->rx_seq);
 		if (!bus->rxskip)
-			DHD_ERROR(("%s: unexpected NAKHANDLED!\n", __func__));
+			dhd_dbg(ERROR, "%s: unexpected NAKHANDLED!\n",
+				__func__);
 
 		bus->rxskip = false;
 		intstatus |= I_HMB_FRAME_IND;
@@ -4201,12 +4268,12 @@ static u32 dhdsdio_hostmail(dhd_bus_t *bus)
 		    (hmb_data & HMB_DATA_VERSION_MASK) >>
 		    HMB_DATA_VERSION_SHIFT;
 		if (bus->sdpcm_ver != SDPCM_PROT_VERSION)
-			DHD_ERROR(("Version mismatch, dongle reports %d, "
-				"expecting %d\n",
-				bus->sdpcm_ver, SDPCM_PROT_VERSION));
+			dhd_dbg(ERROR,
+				"Version mismatch, dongle reports %d, expecting %d\n",
+				bus->sdpcm_ver, SDPCM_PROT_VERSION);
 		else
-			DHD_INFO(("Dongle ready, protocol version %d\n",
-				  bus->sdpcm_ver));
+			dhd_dbg(INFO, "Dongle ready, protocol version %d\n",
+				bus->sdpcm_ver);
 	}
 
 	/*
@@ -4234,7 +4301,8 @@ static u32 dhdsdio_hostmail(dhd_bus_t *bus)
 			 HMB_DATA_FC |
 			 HMB_DATA_FWREADY |
 			 HMB_DATA_FCDATA_MASK | HMB_DATA_VERSION_MASK)) {
-		DHD_ERROR(("Unknown mailbox data content: 0x%02x\n", hmb_data));
+		dhd_dbg(ERROR, "Unknown mailbox data content: 0x%02x\n",
+			hmb_data);
 	}
 
 	return intstatus;
@@ -4252,7 +4320,7 @@ bool dhdsdio_dpc(dhd_bus_t *bus)
 	bool rxdone = true;	/* Flag for no more read data */
 	bool resched = false;	/* Flag indicating resched wanted */
 
-	DHD_TRACE(("%s: Enter\n", __func__));
+	dhd_dbg(TRACE, "%s: Enter\n", __func__);
 
 	/* Start with leftover status bits */
 	intstatus = bus->intstatus;
@@ -4269,8 +4337,8 @@ bool dhdsdio_dpc(dhd_bus_t *bus)
 		devctl =
 		    bcmsdh_cfg_read(sdh, SDIO_FUNC_1, SBSDIO_DEVICE_CTL, &err);
 		if (err) {
-			DHD_ERROR(("%s: error reading DEVCTL: %d\n",
-				   __func__, err));
+			dhd_dbg(ERROR, "%s: error reading DEVCTL: %d\n",
+				__func__, err);
 			bus->dhd->busstate = DHD_BUS_DOWN;
 		} else {
 			ASSERT(devctl & SBSDIO_DEVCTL_CA_INT_ONLY);
@@ -4282,29 +4350,29 @@ bool dhdsdio_dpc(dhd_bus_t *bus)
 		    bcmsdh_cfg_read(sdh, SDIO_FUNC_1, SBSDIO_FUNC1_CHIPCLKCSR,
 				    &err);
 		if (err) {
-			DHD_ERROR(("%s: error reading CSR: %d\n", __func__,
-				   err));
+			dhd_dbg(ERROR, "%s: error reading CSR: %d\n",
+				__func__, err);
 			bus->dhd->busstate = DHD_BUS_DOWN;
 		}
 
-		DHD_INFO(("DPC: PENDING, devctl 0x%02x clkctl 0x%02x\n", devctl,
-			  clkctl));
+		dhd_dbg(INFO, "DPC: PENDING, devctl 0x%02x clkctl 0x%02x\n",
+			devctl, clkctl);
 
 		if (SBSDIO_HTAV(clkctl)) {
 			devctl =
 			    bcmsdh_cfg_read(sdh, SDIO_FUNC_1, SBSDIO_DEVICE_CTL,
 					    &err);
 			if (err) {
-				DHD_ERROR(("%s: error reading DEVCTL: %d\n",
-					   __func__, err));
+				dhd_dbg(ERROR, "%s: error reading DEVCTL: %d\n",
+					__func__, err);
 				bus->dhd->busstate = DHD_BUS_DOWN;
 			}
 			devctl &= ~SBSDIO_DEVCTL_CA_INT_ONLY;
 			bcmsdh_cfg_write(sdh, SDIO_FUNC_1, SBSDIO_DEVICE_CTL,
 					 devctl, &err);
 			if (err) {
-				DHD_ERROR(("%s: error writing DEVCTL: %d\n",
-					   __func__, err));
+				dhd_dbg(ERROR, "%s: error writing DEVCTL: %d\n",
+					__func__, err);
 				bus->dhd->busstate = DHD_BUS_DOWN;
 			}
 			bus->clkstate = CLK_AVAIL;
@@ -4361,23 +4429,23 @@ bool dhdsdio_dpc(dhd_bus_t *bus)
 
 	/* Generally don't ask for these, can get CRC errors... */
 	if (intstatus & I_WR_OOSYNC) {
-		DHD_ERROR(("Dongle reports WR_OOSYNC\n"));
+		dhd_dbg(ERROR, "Dongle reports WR_OOSYNC\n");
 		intstatus &= ~I_WR_OOSYNC;
 	}
 
 	if (intstatus & I_RD_OOSYNC) {
-		DHD_ERROR(("Dongle reports RD_OOSYNC\n"));
+		dhd_dbg(ERROR, "Dongle reports RD_OOSYNC\n");
 		intstatus &= ~I_RD_OOSYNC;
 	}
 
 	if (intstatus & I_SBINT) {
-		DHD_ERROR(("Dongle reports SBINT\n"));
+		dhd_dbg(ERROR, "Dongle reports SBINT\n");
 		intstatus &= ~I_SBINT;
 	}
 
 	/* Would be active due to wake-wlan in gSPI */
 	if (intstatus & I_CHIPACTIVE) {
-		DHD_INFO(("Dongle reports CHIPACTIVE\n"));
+		dhd_dbg(INFO, "Dongle reports CHIPACTIVE\n");
 		intstatus &= ~I_CHIPACTIVE;
 	}
 
@@ -4405,8 +4473,9 @@ clkwait:
 	 * (Unless register access seems hosed, as we may not be able to ACK...)
 	 */
 	if (bus->intr && bus->intdis && !bcmsdh_regfail(sdh)) {
-		DHD_INTR(("%s: enable SDIO interrupts, rxdone %d framecnt %d\n",
-			  __func__, rxdone, framecnt));
+		dhd_dbg(INTR,
+			"%s: enable SDIO interrupts, rxdone %d framecnt %d\n",
+			__func__, rxdone, framecnt);
 		bus->intdis = false;
 		bcmsdh_intr_enable(sdh);
 	}
@@ -4425,8 +4494,9 @@ clkwait:
 		if (ret < 0) {
 			/* On failure, abort the command and
 				terminate the frame */
-			DHD_INFO(("%s: sdio error %d, abort command and "
-				"terminate frame.\n", __func__, ret));
+			dhd_dbg(INFO,
+				"%s: sdio error %d, abort command and terminate frame\n",
+				__func__, ret);
 			bus->tx_sderrs++;
 
 			bcmsdh_abort(sdh, SDIO_FUNC_2);
@@ -4453,7 +4523,7 @@ clkwait:
 		if (ret == 0)
 			bus->tx_seq = (bus->tx_seq + 1) % SDPCM_SEQUENCE_WRAP;
 
-		DHD_INFO(("Return_dpc value is : %d\n", ret));
+		dhd_dbg(INFO, "Return_dpc value is : %d\n", ret);
 		bus->ctrl_frame_stat = false;
 		dhd_wait_event_wakeup(bus->dhd);
 	}
@@ -4471,13 +4541,15 @@ clkwait:
 	/* On failed register access, all bets are off:
 		 no resched or interrupts */
 	if ((bus->dhd->busstate == DHD_BUS_DOWN) || bcmsdh_regfail(sdh)) {
-		DHD_ERROR(("%s: failed backplane access over SDIO, halting "
-			"operation %d\n", __func__, bcmsdh_regfail(sdh)));
+		dhd_dbg(ERROR,
+			"%s: failed backplane access over SDIO, halting operation %d\n",
+			__func__, bcmsdh_regfail(sdh));
 		bus->dhd->busstate = DHD_BUS_DOWN;
 		bus->intstatus = 0;
 	} else if (bus->clkstate == CLK_PENDING) {
-		DHD_INFO(("%s: rescheduled due to CLK_PENDING awaiting "
-			"I_CHIPACTIVE interrupt\n", __func__));
+		dhd_dbg(INFO,
+			"%s: rescheduled due to CLK_PENDING awaiting I_CHIPACTIVE interrupt\n",
+			__func__);
 		resched = true;
 	} else if (bus->intstatus || bus->ipend ||
 		(!bus->fcstate && pktq_mlen(&bus->txq, ~bus->flowcontrol) &&
@@ -4504,7 +4576,7 @@ bool dhd_bus_dpc(struct dhd_bus *bus)
 	bool resched;
 
 	/* Call the DPC directly. */
-	DHD_TRACE(("Calling dhdsdio_dpc() from %s\n", __func__));
+	dhd_dbg(TRACE, "Calling dhdsdio_dpc() from %s\n", __func__);
 	resched = dhdsdio_dpc(bus);
 
 	return resched;
@@ -4515,17 +4587,17 @@ void dhdsdio_isr(void *arg)
 	dhd_bus_t *bus = (dhd_bus_t *) arg;
 	bcmsdh_info_t *sdh;
 
-	DHD_TRACE(("%s: Enter\n", __func__));
+	dhd_dbg(TRACE, "%s: Enter\n", __func__);
 
 	if (!bus) {
-		DHD_ERROR(("%s : bus is null pointer , exit\n", __func__));
+		dhd_dbg(ERROR, "%s: bus is null pointer, exit\n", __func__);
 		return;
 	}
 	sdh = bus->sdh;
 
 	if (bus->dhd->busstate == DHD_BUS_DOWN) {
-		DHD_ERROR(("%s : bus is down. we have nothing to do\n",
-			   __func__));
+		dhd_dbg(ERROR, "%s: bus is down. we have nothing to do\n",
+			__func__);
 		return;
 	}
 	/* Count the interrupt call */
@@ -4534,21 +4606,21 @@ void dhdsdio_isr(void *arg)
 
 	/* Shouldn't get this interrupt if we're sleeping? */
 	if (bus->sleeping) {
-		DHD_ERROR(("INTERRUPT WHILE SLEEPING??\n"));
+		dhd_dbg(ERROR, "INTERRUPT WHILE SLEEPING??\n");
 		return;
 	}
 
 	/* Disable additional interrupts (is this needed now)? */
 	if (bus->intr)
-		DHD_INTR(("%s: disable SDIO interrupts\n", __func__));
+		dhd_dbg(INTR, "%s: disable SDIO interrupts\n", __func__);
 	else
-		DHD_ERROR(("dhdsdio_isr() w/o interrupt configured!\n"));
+		dhd_dbg(ERROR, "dhdsdio_isr() w/o interrupt configured!\n");
 
 	bcmsdh_intr_disable(sdh);
 	bus->intdis = true;
 
 #if defined(SDIO_ISR_THREAD)
-	DHD_TRACE(("Calling dhdsdio_dpc() from %s\n", __func__));
+	dhd_dbg(TRACE, "Calling dhdsdio_dpc() from %s\n", __func__);
 	while (dhdsdio_dpc(bus))
 		;
 #else
@@ -4618,7 +4690,8 @@ static void dhdsdio_pktgen(dhd_bus_t *bus)
 			(len + SDPCM_HDRLEN + SDPCM_TEST_HDRLEN + DHD_SDALIGN),
 			true);
 		if (!pkt) {
-			DHD_ERROR(("%s: pkt_buf_get_skb failed!\n", __func__));
+			dhd_dbg(ERROR, "%s: pkt_buf_get_skb failed!\n",
+				__func__);
 			break;
 		}
 		PKTALIGN(pkt, (len + SDPCM_HDRLEN + SDPCM_TEST_HDRLEN),
@@ -4643,8 +4716,8 @@ static void dhdsdio_pktgen(dhd_bus_t *bus)
 			break;
 
 		default:
-			DHD_ERROR(("Unrecognized pktgen mode %d\n",
-				   bus->pktgen_mode));
+			dhd_dbg(ERROR, "Unrecognized pktgen mode %d\n",
+				bus->pktgen_mode);
 			pkt_buf_free_skb(pkt, true);
 			bus->pktgen_count = 0;
 			return;
@@ -4696,7 +4769,7 @@ static void dhdsdio_sdtest_set(dhd_bus_t *bus, bool start)
 	pkt = pkt_buf_get_skb(SDPCM_HDRLEN + SDPCM_TEST_HDRLEN + DHD_SDALIGN,
 			true);
 	if (!pkt) {
-		DHD_ERROR(("%s: pkt_buf_get_skb failed!\n", __func__));
+		dhd_dbg(ERROR, "%s: pkt_buf_get_skb failed!\n", __func__);
 		return;
 	}
 	PKTALIGN(pkt, (SDPCM_HDRLEN + SDPCM_TEST_HDRLEN), DHD_SDALIGN);
@@ -4726,8 +4799,8 @@ static void dhdsdio_testrcv(dhd_bus_t *bus, struct sk_buff *pkt, uint seq)
 	/* Check for min length */
 	pktlen = pkt->len;
 	if (pktlen < SDPCM_TEST_HDRLEN) {
-		DHD_ERROR(("dhdsdio_restrcv: toss runt frame, pktlen %d\n",
-			   pktlen));
+		dhd_dbg(ERROR, "%s: toss runt frame, pktlen %d\n",
+			__func__, pktlen);
 		pkt_buf_free_skb(pkt, false);
 		return;
 	}
@@ -4743,9 +4816,9 @@ static void dhdsdio_testrcv(dhd_bus_t *bus, struct sk_buff *pkt, uint seq)
 	if (cmd == SDPCM_TEST_DISCARD || cmd == SDPCM_TEST_ECHOREQ
 	    || cmd == SDPCM_TEST_ECHORSP) {
 		if (pktlen != len + SDPCM_TEST_HDRLEN) {
-			DHD_ERROR(("dhdsdio_testrcv: frame length mismatch, "
-				"pktlen %d seq %d" " cmd %d extra %d len %d\n",
-				pktlen, seq, cmd, extra, len));
+			dhd_dbg(ERROR,
+				"%s: frame length mismatch, pktlen %d seq %d cmd %d extra %d len %d\n",
+				__func__, pktlen, seq, cmd, extra, len);
 			pkt_buf_free_skb(pkt, false);
 			return;
 		}
@@ -4775,9 +4848,10 @@ static void dhdsdio_testrcv(dhd_bus_t *bus, struct sk_buff *pkt, uint seq)
 
 		for (offset = 0; offset < len; offset++, data++) {
 			if (*data != SDPCM_TEST_FILL(offset, extra)) {
-				DHD_ERROR(("dhdsdio_testrcv: echo data mismatch: " "offset %d (len %d) expect 0x%02x rcvd 0x%02x\n",
-					offset, len,
-					SDPCM_TEST_FILL(offset, extra), *data));
+				dhd_dbg(ERROR,
+					"%s: echo data mismatch: offset %d (len %d) expect 0x%02x rcvd 0x%02x\n",
+					__func__, offset, len,
+					SDPCM_TEST_FILL(offset, extra), *data);
 				break;
 			}
 		}
@@ -4793,14 +4867,14 @@ static void dhdsdio_testrcv(dhd_bus_t *bus, struct sk_buff *pkt, uint seq)
 	case SDPCM_TEST_BURST:
 	case SDPCM_TEST_SEND:
 	default:
-		DHD_INFO(("dhdsdio_testrcv: unsupported or unknown command, "
-			"pktlen %d seq %d" " cmd %d extra %d len %d\n",
-			pktlen, seq, cmd, extra, len));
+		dhd_dbg(INFO,
+			"%s: unsupported or unknown command, pktlen %d seq %d cmd %d extra %d len %d\n",
+			__func__, pktlen, seq, cmd, extra, len);
 		pkt_buf_free_skb(pkt, false);
 		break;
 	}
 
-	/* For recv mode, stop at limie (and tell dongle to stop sending) */
+	/* For recv mode, stop at limit (and tell dongle to stop sending) */
 	if (bus->pktgen_mode == DHD_PKTGEN_RECV) {
 		if (bus->pktgen_total
 		    && (bus->pktgen_rcvd >= bus->pktgen_total)) {
@@ -4815,7 +4889,7 @@ extern bool dhd_bus_watchdog(dhd_pub_t *dhdp)
 {
 	dhd_bus_t *bus;
 
-	DHD_TIMER(("%s: Enter\n", __func__));
+	dhd_dbg(TIMER, "%s: Enter\n", __func__);
 
 	bus = dhdp->bus;
 
@@ -4977,14 +5051,15 @@ done:
 static void dhd_dump_cis(uint fn, u8 *cis)
 {
 	uint byte, tag, tdata;
-	DHD_INFO(("Function %d CIS:\n", fn));
+
+	dhd_dbg(INFO, "Function %d CIS:\n", fn);
 
 	for (tdata = byte = 0; byte < SBSDIO_CIS_SIZE_LIMIT; byte++) {
 		if ((byte % 16) == 0)
-			DHD_INFO(("    "));
-		DHD_INFO(("%02x ", cis[byte]));
+			dhd_dbg(INFO, "    ");
+		dhd_dbg(INFO, "%02x ", cis[byte]);
 		if ((byte % 16) == 15)
-			DHD_INFO(("\n"));
+			dhd_dbg(INFO, "\n");
 		if (!tdata--) {
 			tag = cis[byte];
 			if (tag == 0xff)
@@ -4994,11 +5069,11 @@ static void dhd_dump_cis(uint fn, u8 *cis)
 			else if ((byte + 1) < SBSDIO_CIS_SIZE_LIMIT)
 				tdata = cis[byte + 1] + 1;
 			else
-				DHD_INFO(("]"));
+				dhd_dbg(INFO, "]");
 		}
 	}
 	if ((byte % 16) != 15)
-		DHD_INFO(("\n"));
+		dhd_dbg(INFO, "\n");
 }
 #endif				/* DHD_DEBUG */
 
@@ -5041,8 +5116,9 @@ static void *dhdsdio_probe(u16 venid, u16 devid, u16 bus_no,
 
 	dhd_common_init();
 
-	DHD_TRACE(("%s: Enter\n", __func__));
-	DHD_INFO(("%s: venid 0x%04x devid 0x%04x\n", __func__, venid, devid));
+	dhd_dbg(TRACE, "%s: Enter\n", __func__);
+	dhd_dbg(INFO, "%s: venid 0x%04x devid 0x%04x\n",
+		__func__, venid, devid);
 
 	/* We make assumptions about address window mappings */
 	ASSERT((unsigned long)regsva == SI_ENUM_BASE);
@@ -5058,7 +5134,7 @@ static void *dhdsdio_probe(u16 venid, u16 devid, u16 bus_no,
 	case PCI_VENDOR_ID_BROADCOM:
 		break;
 	default:
-		DHD_ERROR(("%s: unknown vendor: 0x%04x\n", __func__, venid));
+		dhd_dbg(ERROR, "%s: unknown vendor: 0x%04x\n", __func__, venid);
 		return NULL;
 	}
 
@@ -5067,34 +5143,35 @@ static void *dhdsdio_probe(u16 venid, u16 devid, u16 bus_no,
 	case BCM4325_D11DUAL_ID:	/* 4325 802.11a/g id */
 	case BCM4325_D11G_ID:	/* 4325 802.11g 2.4Ghz band id */
 	case BCM4325_D11A_ID:	/* 4325 802.11a 5Ghz band id */
-		DHD_INFO(("%s: found 4325 Dongle\n", __func__));
+		dhd_dbg(INFO, "%s: found 4325 Dongle\n", __func__);
 		break;
 	case BCM4329_D11NDUAL_ID:	/* 4329 802.11n dualband device */
 	case BCM4329_D11N2G_ID:	/* 4329 802.11n 2.4G device */
 	case BCM4329_D11N5G_ID:	/* 4329 802.11n 5G device */
 	case 0x4329:
-		DHD_INFO(("%s: found 4329 Dongle\n", __func__));
+		dhd_dbg(INFO, "%s: found 4329 Dongle\n", __func__);
 		break;
 	case BCM4319_D11N_ID:	/* 4319 802.11n id */
 	case BCM4319_D11N2G_ID:	/* 4319 802.11n2g id */
 	case BCM4319_D11N5G_ID:	/* 4319 802.11n5g id */
-		DHD_INFO(("%s: found 4319 Dongle\n", __func__));
+		dhd_dbg(INFO, "%s: found 4319 Dongle\n", __func__);
 		break;
 	case 0:
-		DHD_INFO(("%s: allow device id 0, will check chip internals\n",
-			  __func__));
+		dhd_dbg(INFO,
+			"%s: allow device id 0, will check chip internals\n",
+			__func__);
 		break;
 
 	default:
-		DHD_ERROR(("%s: skipping 0x%04x/0x%04x, not a dongle\n",
-			   __func__, venid, devid));
+		dhd_dbg(ERROR, "%s: skipping 0x%04x/0x%04x, not a dongle\n",
+			__func__, venid, devid);
 		return NULL;
 	}
 
 	/* Allocate private bus interface state */
 	bus = kzalloc(sizeof(dhd_bus_t), GFP_ATOMIC);
 	if (!bus) {
-		DHD_ERROR(("%s: kmalloc of dhd_bus_t failed\n", __func__));
+		dhd_dbg(ERROR, "%s: kmalloc of dhd_bus_t failed\n", __func__);
 		goto fail;
 	}
 	bus->sdh = sdh;
@@ -5106,53 +5183,54 @@ static void *dhdsdio_probe(u16 venid, u16 devid, u16 bus_no,
 
 	/* attempt to attach to the dongle */
 	if (!(dhdsdio_probe_attach(bus, sdh, regsva, devid))) {
-		DHD_ERROR(("%s: dhdsdio_probe_attach failed\n", __func__));
+		dhd_dbg(ERROR, "%s: dhdsdio_probe_attach failed\n", __func__);
 		goto fail;
 	}
 
 	/* Attach to the dhd/OS/network interface */
 	bus->dhd = dhd_attach(bus, SDPCM_RESERVE);
 	if (!bus->dhd) {
-		DHD_ERROR(("%s: dhd_attach failed\n", __func__));
+		dhd_dbg(ERROR, "%s: dhd_attach failed\n", __func__);
 		goto fail;
 	}
 
 	/* Allocate buffers */
 	if (!(dhdsdio_probe_malloc(bus, sdh))) {
-		DHD_ERROR(("%s: dhdsdio_probe_malloc failed\n", __func__));
+		dhd_dbg(ERROR, "%s: dhdsdio_probe_malloc failed\n", __func__);
 		goto fail;
 	}
 
 	if (!(dhdsdio_probe_init(bus, sdh))) {
-		DHD_ERROR(("%s: dhdsdio_probe_init failed\n", __func__));
+		dhd_dbg(ERROR, "%s: dhdsdio_probe_init failed\n", __func__);
 		goto fail;
 	}
 
 	/* Register interrupt callback, but mask it (not operational yet). */
-	DHD_INTR(("%s: disable SDIO interrupts (not interested yet)\n",
-		  __func__));
+	dhd_dbg(INTR, "%s: disable SDIO interrupts (not interested yet)\n",
+		__func__);
 	bcmsdh_intr_disable(sdh);
 	ret = bcmsdh_intr_reg(sdh, dhdsdio_isr, bus);
 	if (ret != 0) {
-		DHD_ERROR(("%s: FAILED: bcmsdh_intr_reg returned %d\n",
-			   __func__, ret));
+		dhd_dbg(ERROR, "%s: FAILED: bcmsdh_intr_reg returned %d\n",
+			__func__, ret);
 		goto fail;
 	}
-	DHD_INTR(("%s: registered SDIO interrupt function ok\n", __func__));
+	dhd_dbg(INTR, "%s: registered SDIO interrupt function ok\n", __func__);
 
-	DHD_INFO(("%s: completed!!\n", __func__));
+	dhd_dbg(INFO, "%s: completed!!\n", __func__);
 
 	/* if firmware path present try to download and bring up bus */
 	ret = dhd_bus_start(bus->dhd);
 	if (ret != 0) {
 		if (ret == BCME_NOTUP) {
-			DHD_ERROR(("%s: dongle is not responding\n", __func__));
+			dhd_dbg(ERROR, "%s: dongle is not responding\n",
+				__func__);
 			goto fail;
 		}
 	}
 	/* Ok, have the per-port tell the stack we're open for business */
 	if (dhd_net_attach(bus->dhd, 0) != 0) {
-		DHD_ERROR(("%s: Net attach failed!!\n", __func__));
+		dhd_dbg(ERROR, "%s: Net attach failed!!\n", __func__);
 		goto fail;
 	}
 
@@ -5173,7 +5251,8 @@ dhdsdio_probe_attach(struct dhd_bus *bus, void *sdh, void *regsva, u16 devid)
 
 	/* Return the window to backplane enumeration space for core access */
 	if (dhdsdio_set_siaddr_window(bus, SI_ENUM_BASE))
-		DHD_ERROR(("%s: FAILED to return to SI_ENUM_BASE\n", __func__));
+		dhd_dbg(ERROR, "%s: FAILED to return to SI_ENUM_BASE\n",
+			__func__);
 
 #ifdef DHD_DEBUG
 	printk(KERN_DEBUG "F1 signature read @0x18000000=0x%4x\n",
@@ -5194,9 +5273,9 @@ dhdsdio_probe_attach(struct dhd_bus *bus, void *sdh, void *regsva, u16 devid)
 				    &err);
 
 	if (err || ((clkctl & ~SBSDIO_AVBITS) != DHD_INIT_CLKCTL1)) {
-		DHD_ERROR(("dhdsdio_probe: ChipClkCSR access: err %d wrote "
-			"0x%02x read 0x%02x\n",
-			err, DHD_INIT_CLKCTL1, clkctl));
+		dhd_dbg(ERROR,
+			"%s: ChipClkCSR access: err %d wrote 0x%02x read 0x%02x\n",
+			__func__, err, DHD_INIT_CLKCTL1, clkctl);
 		goto fail;
 	}
 #ifdef DHD_DEBUG
@@ -5222,16 +5301,16 @@ dhdsdio_probe_attach(struct dhd_bus *bus, void *sdh, void *regsva, u16 devid)
 		for (fn = 0; fn <= numfn; fn++) {
 			cis[fn] = kzalloc(SBSDIO_CIS_SIZE_LIMIT, GFP_ATOMIC);
 			if (!cis[fn]) {
-				DHD_INFO(("dhdsdio_probe: fn %d cis malloc "
-					"failed\n", fn));
+				dhd_dbg(INFO, "%s: fn %d cis malloc failed\n",
+					__func__, fn);
 				break;
 			}
 
 			err = bcmsdh_cis_read(sdh, fn, cis[fn],
 						SBSDIO_CIS_SIZE_LIMIT);
 			if (err) {
-				DHD_INFO(("dhdsdio_probe: fn %d cis read "
-					"err %d\n", fn, err));
+				dhd_dbg(INFO, "%s: fn %d cis read err %d\n",
+					__func__, fn, err);
 				kfree(cis[fn]);
 				break;
 			}
@@ -5244,22 +5323,23 @@ dhdsdio_probe_attach(struct dhd_bus *bus, void *sdh, void *regsva, u16 devid)
 		}
 
 		if (err) {
-			DHD_ERROR(("dhdsdio_probe: error read/parsing CIS\n"));
+			dhd_dbg(ERROR, "%s: error read/parsing CIS\n",
+				__func__);
 			goto fail;
 		}
 	}
 #endif				/* DHD_DEBUG */
 
 	if (dhdsdio_chip_attach(bus, regsva)) {
-		DHD_ERROR(("%s: dhdsdio_chip_attach failed!\n", __func__));
+		dhd_dbg(ERROR, "%s: dhdsdio_chip_attach failed!\n", __func__);
 		goto fail;
 	}
 
 	bcmsdh_chipinfo(sdh, bus->ci->chip, bus->ci->chiprev);
 
 	if (!dhdsdio_chipmatch((u16) bus->ci->chip)) {
-		DHD_ERROR(("%s: unsupported chip: 0x%04x\n",
-			   __func__, bus->ci->chip));
+		dhd_dbg(ERROR, "%s: unsupported chip: 0x%04x\n",
+			__func__, bus->ci->chip);
 		goto fail;
 	}
 
@@ -5271,16 +5351,16 @@ dhdsdio_probe_attach(struct dhd_bus *bus, void *sdh, void *regsva, u16 devid)
 			CORE_SB(bus->ci->armcorebase, sbidhigh), 4));
 		bus->orig_ramsize = bus->ci->ramsize;
 		if (!(bus->orig_ramsize)) {
-			DHD_ERROR(("%s: failed to find SOCRAM memory!\n",
-				   __func__));
+			dhd_dbg(ERROR, "%s: failed to find SOCRAM memory!\n",
+				__func__);
 			goto fail;
 		}
 		bus->ramsize = bus->orig_ramsize;
 		if (dhd_dongle_memsize)
 			dhd_dongle_setmemsize(bus, dhd_dongle_memsize);
 
-		DHD_ERROR(("DHD: dongle ram size is set to %d(orig %d)\n",
-			   bus->ramsize, bus->orig_ramsize));
+		dhd_dbg(ERROR, "DHD: dongle ram size is set to %d(orig %d)\n",
+			bus->ramsize, bus->orig_ramsize);
 	}
 
 	bus->regs = (void *)bus->ci->buscorebase;
@@ -5307,7 +5387,7 @@ fail:
 
 static bool dhdsdio_probe_malloc(dhd_bus_t *bus, void *sdh)
 {
-	DHD_TRACE(("%s: Enter\n", __func__));
+	dhd_dbg(TRACE, "%s: Enter\n", __func__);
 
 	if (bus->dhd->maxctl) {
 		bus->rxblen =
@@ -5315,8 +5395,8 @@ static bool dhdsdio_probe_malloc(dhd_bus_t *bus, void *sdh)
 			    ALIGNMENT) + DHD_SDALIGN;
 		bus->rxbuf = kmalloc(bus->rxblen, GFP_ATOMIC);
 		if (!(bus->rxbuf)) {
-			DHD_ERROR(("%s: kmalloc of %d-byte rxbuf failed\n",
-				   __func__, bus->rxblen));
+			dhd_dbg(ERROR, "%s: kmalloc of %d-byte rxbuf failed\n",
+				__func__, bus->rxblen);
 			goto fail;
 		}
 	}
@@ -5324,8 +5404,8 @@ static bool dhdsdio_probe_malloc(dhd_bus_t *bus, void *sdh)
 	/* Allocate buffer to receive glomed packet */
 	bus->databuf = kmalloc(MAX_DATA_BUF, GFP_ATOMIC);
 	if (!(bus->databuf)) {
-		DHD_ERROR(("%s: kmalloc of %d-byte databuf failed\n",
-			   __func__, MAX_DATA_BUF));
+		dhd_dbg(ERROR, "%s: kmalloc of %d-byte databuf failed\n",
+			__func__, MAX_DATA_BUF);
 		/* release rxbuf which was already located as above */
 		if (!bus->rxblen)
 			kfree(bus->rxbuf);
@@ -5350,7 +5430,7 @@ static bool dhdsdio_probe_init(dhd_bus_t *bus, void *sdh)
 {
 	s32 fnum;
 
-	DHD_TRACE(("%s: Enter\n", __func__));
+	dhd_dbg(TRACE, "%s: Enter\n", __func__);
 
 #ifdef SDTEST
 	dhdsdio_pktgen_init(bus);
@@ -5377,21 +5457,21 @@ static bool dhdsdio_probe_init(dhd_bus_t *bus, void *sdh)
 	if (bcmsdh_iovar_op(sdh, "sd_divisor", NULL, 0,
 			    &bus->sd_divisor, sizeof(s32),
 			    false) != 0) {
-		DHD_ERROR(("%s: fail on %s get\n", __func__, "sd_divisor"));
+		dhd_dbg(ERROR, "%s: fail on %s get\n", __func__, "sd_divisor");
 		bus->sd_divisor = -1;
 	} else {
-		DHD_INFO(("%s: Initial value for %s is %d\n",
-			  __func__, "sd_divisor", bus->sd_divisor));
+		dhd_dbg(INFO, "%s: Initial value for %s is %d\n",
+			__func__, "sd_divisor", bus->sd_divisor);
 	}
 
 	/* Query the SD bus mode */
 	if (bcmsdh_iovar_op(sdh, "sd_mode", NULL, 0,
 			    &bus->sd_mode, sizeof(s32), false) != 0) {
-		DHD_ERROR(("%s: fail on %s get\n", __func__, "sd_mode"));
+		dhd_dbg(ERROR, "%s: fail on %s get\n", __func__, "sd_mode");
 		bus->sd_mode = -1;
 	} else {
-		DHD_INFO(("%s: Initial value for %s is %d\n",
-			  __func__, "sd_mode", bus->sd_mode));
+		dhd_dbg(INFO, "%s: Initial value for %s is %d\n",
+			__func__, "sd_mode", bus->sd_mode);
 	}
 
 	/* Query the F2 block size, set roundup accordingly */
@@ -5399,10 +5479,11 @@ static bool dhdsdio_probe_init(dhd_bus_t *bus, void *sdh)
 	if (bcmsdh_iovar_op(sdh, "sd_blocksize", &fnum, sizeof(s32),
 			    &bus->blocksize, sizeof(s32), false) != 0) {
 		bus->blocksize = 0;
-		DHD_ERROR(("%s: fail on %s get\n", __func__, "sd_blocksize"));
+		dhd_dbg(ERROR, "%s: fail on %s get\n",
+			__func__, "sd_blocksize");
 	} else {
-		DHD_INFO(("%s: Initial value for %s is %d\n",
-			  __func__, "sd_blocksize", bus->blocksize));
+		dhd_dbg(INFO, "%s: Initial value for %s is %d\n",
+			__func__, "sd_blocksize", bus->blocksize);
 	}
 	bus->roundup = min(max_roundup, bus->blocksize);
 
@@ -5413,9 +5494,10 @@ static bool dhdsdio_probe_init(dhd_bus_t *bus, void *sdh)
 			    false) != 0) {
 		bus->sd_rxchain = false;
 	} else {
-		DHD_INFO(("%s: bus module (through bcmsdh API) %s chaining\n",
-			  __func__,
-			  (bus->sd_rxchain ? "supports" : "does not support")));
+		dhd_dbg(INFO,
+			"%s: bus module (through bcmsdh API) %s chaining\n",
+			__func__,
+			(bus->sd_rxchain ? "supports" : "does not support"));
 	}
 	bus->use_rxchain = (bool) bus->sd_rxchain;
 
@@ -5452,7 +5534,7 @@ dhdsdio_download_firmware(struct dhd_bus *bus, void *sdh)
 /* Detach and free everything */
 static void dhdsdio_release(dhd_bus_t *bus)
 {
-	DHD_TRACE(("%s: Enter\n", __func__));
+	dhd_dbg(TRACE, "%s: Enter\n", __func__);
 
 	if (bus) {
 		/* De-register interrupt handler */
@@ -5470,12 +5552,12 @@ static void dhdsdio_release(dhd_bus_t *bus)
 		kfree(bus);
 	}
 
-	DHD_TRACE(("%s: Disconnected\n", __func__));
+	dhd_dbg(TRACE, "%s: Disconnected\n", __func__);
 }
 
 static void dhdsdio_release_malloc(dhd_bus_t *bus)
 {
-	DHD_TRACE(("%s: Enter\n", __func__));
+	dhd_dbg(TRACE, "%s: Enter\n", __func__);
 
 	if (bus->dhd && bus->dhd->dongle_reset)
 		return;
@@ -5492,7 +5574,7 @@ static void dhdsdio_release_malloc(dhd_bus_t *bus)
 
 static void dhdsdio_release_dongle(dhd_bus_t *bus)
 {
-	DHD_TRACE(("%s: Enter\n", __func__));
+	dhd_dbg(TRACE, "%s: Enter\n", __func__);
 
 	if (bus->dhd && bus->dhd->dongle_reset)
 		return;
@@ -5506,21 +5588,21 @@ static void dhdsdio_release_dongle(dhd_bus_t *bus)
 		bus->vars = NULL;
 	}
 
-	DHD_TRACE(("%s: Disconnected\n", __func__));
+	dhd_dbg(TRACE, "%s: Disconnected\n", __func__);
 }
 
 static void dhdsdio_disconnect(void *ptr)
 {
 	dhd_bus_t *bus = (dhd_bus_t *)ptr;
 
-	DHD_TRACE(("%s: Enter\n", __func__));
+	dhd_dbg(TRACE, "%s: Enter\n", __func__);
 
 	if (bus) {
 		ASSERT(bus->dhd);
 		dhdsdio_release(bus);
 	}
 
-	DHD_TRACE(("%s: Disconnected\n", __func__));
+	dhd_dbg(TRACE, "%s: Disconnected\n", __func__);
 }
 
 /* Register/Unregister functions are called by the main DHD entry
@@ -5535,14 +5617,14 @@ static bcmsdh_driver_t dhd_sdio = {
 
 int dhd_bus_register(void)
 {
-	DHD_TRACE(("%s: Enter\n", __func__));
+	dhd_dbg(TRACE, "%s: Enter\n", __func__);
 
 	return bcmsdh_register(&dhd_sdio);
 }
 
 void dhd_bus_unregister(void)
 {
-	DHD_TRACE(("%s: Enter\n", __func__));
+	dhd_dbg(TRACE, "%s: Enter\n", __func__);
 
 	bcmsdh_unregister();
 }
@@ -5553,7 +5635,7 @@ static int dhdsdio_download_code_array(struct dhd_bus *bus)
 	int bcmerror = -1;
 	int offset = 0;
 
-	DHD_INFO(("%s: download embedded firmware...\n", __func__));
+	dhd_dbg(INFO, "%s: download embedded firmware...\n", __func__);
 
 	/* Download image */
 	while ((offset + MEMBLOCK) < sizeof(dlarray)) {
@@ -5561,9 +5643,9 @@ static int dhdsdio_download_code_array(struct dhd_bus *bus)
 		    dhdsdio_membytes(bus, true, offset, dlarray + offset,
 				     MEMBLOCK);
 		if (bcmerror) {
-			DHD_ERROR(("%s: error %d on writing %d membytes at "
-				"0x%08x\n",
-				__func__, bcmerror, MEMBLOCK, offset));
+			dhd_dbg(ERROR,
+				"%s: error %d on writing %d membytes at 0x%08x\n",
+				__func__, bcmerror, MEMBLOCK, offset);
 			goto err;
 		}
 
@@ -5575,9 +5657,10 @@ static int dhdsdio_download_code_array(struct dhd_bus *bus)
 					    dlarray + offset,
 					    sizeof(dlarray) - offset);
 		if (bcmerror) {
-			DHD_ERROR(("%s: error %d on writing %d membytes at "
-				"0x%08x\n", __func__, bcmerror,
-				sizeof(dlarray) - offset, offset));
+			dhd_dbg(ERROR,
+				"%s: error %d on writing %d membytes at 0x%08x\n",
+				__func__, bcmerror,
+				sizeof(dlarray) - offset, offset);
 			goto err;
 		}
 	}
@@ -5599,9 +5682,9 @@ static int dhdsdio_download_code_array(struct dhd_bus *bus)
 			    dhdsdio_membytes(bus, false, offset,
 					     ularray + offset, MEMBLOCK);
 			if (bcmerror) {
-				DHD_ERROR(("%s: error %d on reading %d membytes"
-					" at 0x%08x\n",
-					__func__, bcmerror, MEMBLOCK, offset));
+				dhd_dbg(ERROR,
+					"%s: error %d on reading %d membytes at 0x%08x\n",
+					__func__, bcmerror, MEMBLOCK, offset);
 				goto free;
 			}
 
@@ -5613,21 +5696,23 @@ static int dhdsdio_download_code_array(struct dhd_bus *bus)
 						    ularray + offset,
 						    sizeof(dlarray) - offset);
 			if (bcmerror) {
-				DHD_ERROR(("%s: error %d on reading %d membytes at 0x%08x\n",
-				__func__, bcmerror,
-				sizeof(dlarray) - offset, offset));
+				dhd_dbg(ERROR,
+					"%s: error %d on reading %d membytes at 0x%08x\n",
+					__func__, bcmerror,
+					sizeof(dlarray) - offset, offset);
 				goto free;
 			}
 		}
 
 		if (memcmp(dlarray, ularray, sizeof(dlarray))) {
-			DHD_ERROR(("%s: Downloaded image is corrupted.\n",
-				   __func__));
+			dhd_dbg(ERROR, "%s: Downloaded image is corrupted\n",
+				__func__);
 			ASSERT(0);
 			goto free;
 		} else
-			DHD_ERROR(("%s: Download/Upload/Compare succeeded.\n",
-				__func__));
+			dhd_dbg(ERROR,
+				"%s: Download/Upload/Compare succeeded\n",
+				__func__);
 free:
 		kfree(ularray);
 	}
@@ -5646,7 +5731,7 @@ static int dhdsdio_download_code_file(struct dhd_bus *bus, char *fw_path)
 	void *image = NULL;
 	u8 *memblock = NULL, *memptr;
 
-	DHD_INFO(("%s: download firmware %s\n", __func__, fw_path));
+	dhd_dbg(INFO, "%s: download firmware %s\n", __func__, fw_path);
 
 	image = dhd_os_open_image(fw_path);
 	if (image == NULL)
@@ -5654,8 +5739,8 @@ static int dhdsdio_download_code_file(struct dhd_bus *bus, char *fw_path)
 
 	memptr = memblock = kmalloc(MEMBLOCK + DHD_SDALIGN, GFP_ATOMIC);
 	if (memblock == NULL) {
-		DHD_ERROR(("%s: Failed to allocate memory %d bytes\n",
-			   __func__, MEMBLOCK));
+		dhd_dbg(ERROR, "%s: Failed to allocate memory %d bytes\n",
+			__func__, MEMBLOCK);
 		goto err;
 	}
 	if ((u32)(unsigned long)memblock % DHD_SDALIGN)
@@ -5667,8 +5752,9 @@ static int dhdsdio_download_code_file(struct dhd_bus *bus, char *fw_path)
 		dhd_os_get_image_block((char *)memptr, MEMBLOCK, image))) {
 		bcmerror = dhdsdio_membytes(bus, true, offset, memptr, len);
 		if (bcmerror) {
-			DHD_ERROR(("%s: error %d on writing %d membytes at "
-			"0x%08x\n", __func__, bcmerror, MEMBLOCK, offset));
+			dhd_dbg(ERROR,
+				"%s: error %d on writing %d membytes at 0x%08x\n",
+				__func__, bcmerror, MEMBLOCK, offset);
 			goto err;
 		}
 
@@ -5780,8 +5866,8 @@ static int dhdsdio_download_nvram(struct dhd_bus *bus)
 
 	memblock = kmalloc(MEMBLOCK, GFP_ATOMIC);
 	if (memblock == NULL) {
-		DHD_ERROR(("%s: Failed to allocate memory %d bytes\n",
-			   __func__, MEMBLOCK));
+		dhd_dbg(ERROR, "%s: Failed to allocate memory %d bytes\n",
+			__func__, MEMBLOCK);
 		goto err;
 	}
 
@@ -5805,12 +5891,12 @@ static int dhdsdio_download_nvram(struct dhd_bus *bus)
 		if (len)
 			bcmerror = dhdsdio_downloadvars(bus, memblock, len + 1);
 		if (bcmerror) {
-			DHD_ERROR(("%s: error downloading vars: %d\n",
-				   __func__, bcmerror));
+			dhd_dbg(ERROR, "%s: error downloading vars: %d\n",
+				__func__, bcmerror);
 		}
 	} else {
-		DHD_ERROR(("%s: error reading nvram file: %d\n",
-			   __func__, len));
+		dhd_dbg(ERROR, "%s: error reading nvram file: %d\n",
+			__func__, len);
 		bcmerror = BCME_SDIO_ERROR;
 	}
 
@@ -5841,15 +5927,17 @@ static int _dhdsdio_download_firmware(struct dhd_bus *bus)
 
 	/* Keep arm in reset */
 	if (dhdsdio_download_state(bus, true)) {
-		DHD_ERROR(("%s: error placing ARM core in reset\n", __func__));
+		dhd_dbg(ERROR, "%s: error placing ARM core in reset\n",
+			__func__);
 		goto err;
 	}
 
 	/* External image takes precedence if specified */
 	if ((bus->fw_path != NULL) && (bus->fw_path[0] != '\0')) {
 		if (dhdsdio_download_code_file(bus, bus->fw_path)) {
-			DHD_ERROR(("%s: dongle image file download failed\n",
-				   __func__));
+			dhd_dbg(ERROR,
+				"%s: dongle image file download failed\n",
+				__func__);
 #ifdef BCMEMBEDIMAGE
 			embed = true;
 #else
@@ -5863,8 +5951,9 @@ static int _dhdsdio_download_firmware(struct dhd_bus *bus)
 #ifdef BCMEMBEDIMAGE
 	if (embed) {
 		if (dhdsdio_download_code_array(bus)) {
-			DHD_ERROR(("%s: dongle image array download failed\n",
-				   __func__));
+			dhd_dbg(ERROR,
+				"%s: dongle image array download failed\n",
+				__func__);
 			goto err;
 		} else {
 			dlok = true;
@@ -5872,7 +5961,7 @@ static int _dhdsdio_download_firmware(struct dhd_bus *bus)
 	}
 #endif
 	if (!dlok) {
-		DHD_ERROR(("%s: dongle image download failed\n", __func__));
+		dhd_dbg(ERROR, "%s: dongle image download failed\n", __func__);
 		goto err;
 	}
 
@@ -5883,14 +5972,14 @@ static int _dhdsdio_download_firmware(struct dhd_bus *bus)
 
 	/* External nvram takes precedence if specified */
 	if (dhdsdio_download_nvram(bus)) {
-		DHD_ERROR(("%s: dongle nvram file download failed\n",
-			   __func__));
+		dhd_dbg(ERROR, "%s: dongle nvram file download failed\n",
+			__func__);
 	}
 
 	/* Take arm out of reset */
 	if (dhdsdio_download_state(bus, false)) {
-		DHD_ERROR(("%s: error getting out of ARM core reset\n",
-			   __func__));
+		dhd_dbg(ERROR, "%s: error getting out of ARM core reset\n",
+			__func__);
 		goto err;
 	}
 
@@ -5966,14 +6055,14 @@ int dhd_bus_devreset(dhd_pub_t *dhdp, u8 flag)
 			bus->dhd->dongle_reset = true;
 			bus->dhd->up = false;
 
-			DHD_TRACE(("%s:  WLAN OFF DONE\n", __func__));
+			dhd_dbg(TRACE, "%s: WLAN OFF DONE\n", __func__);
 			/* App can now remove power from device */
 		} else
 			bcmerror = BCME_SDIO_ERROR;
 	} else {
 		/* App must have restored power to device before calling */
 
-		DHD_TRACE(("\n\n%s: == WLAN ON ==\n", __func__));
+		dhd_dbg(TRACE, "%s: == WLAN ON ==\n", __func__);
 
 		if (bus->dhd->dongle_reset) {
 			/* Turn on WLAN */
@@ -6001,16 +6090,17 @@ int dhd_bus_devreset(dhd_pub_t *dhdp, u8 flag)
 					bus->dhd->dongle_reset = false;
 					bus->dhd->up = true;
 
-					DHD_TRACE(("%s: WLAN ON DONE\n",
-						   __func__));
+					dhd_dbg(TRACE, "%s: WLAN ON DONE\n",
+						__func__);
 				} else
 					bcmerror = BCME_SDIO_ERROR;
 			} else
 				bcmerror = BCME_SDIO_ERROR;
 		} else {
 			bcmerror = BCME_NOTDOWN;
-			DHD_ERROR(("%s: Set DEVRESET=false invoked when device "
-				"is on\n", __func__));
+			dhd_dbg(ERROR,
+				"%s: Set DEVRESET=false invoked when device is on\n",
+				__func__);
 			bcmerror = BCME_SDIO_ERROR;
 		}
 	}
@@ -6033,8 +6123,8 @@ dhdsdio_chip_recognition(bcmsdh_info_t *sdh, struct chip_info *ci, void *regs)
 	ci->chip = regdata & CID_ID_MASK;
 	ci->chiprev = (regdata & CID_REV_MASK) >> CID_REV_SHIFT;
 
-	DHD_INFO(("%s: chipid=0x%x chiprev=%d\n",
-		__func__, ci->chip, ci->chiprev));
+	dhd_dbg(INFO, "%s: chipid=0x%x chiprev=%d\n",
+		__func__, ci->chip, ci->chiprev);
 
 	/* Address of cores for new chips should be added here */
 	switch (ci->chip) {
@@ -6045,8 +6135,8 @@ dhdsdio_chip_recognition(bcmsdh_info_t *sdh, struct chip_info *ci, void *regs)
 		ci->ramsize = BCM4329_RAMSIZE;
 		break;
 	default:
-		DHD_ERROR(("%s: chipid 0x%x is not supported\n",
-			__func__, ci->chip));
+		dhd_dbg(ERROR, "%s: chipid 0x%x is not supported\n",
+			__func__, ci->chip);
 		return -ENODEV;
 	}
 
@@ -6062,9 +6152,9 @@ dhdsdio_chip_recognition(bcmsdh_info_t *sdh, struct chip_info *ci, void *regs)
 	ci->buscorerev = SBCOREREV(regdata);
 	ci->buscoretype = (regdata & SBIDH_CC_MASK) >> SBIDH_CC_SHIFT;
 
-	DHD_INFO(("%s: ccrev=%d, pmurev=%d, buscore rev/type=%d/0x%x\n",
+	dhd_dbg(INFO, "%s: ccrev=%d, pmurev=%d, buscore rev/type=%d/0x%x\n",
 		__func__, ci->ccrev, ci->pmurev,
-		ci->buscorerev, ci->buscoretype));
+		ci->buscorerev, ci->buscoretype);
 
 	/* get chipcommon capabilites */
 	ci->cccaps = bcmsdh_reg_read(sdh,
@@ -6105,7 +6195,7 @@ dhdsdio_chip_disablecore(bcmsdh_info_t *sdh, u32 corebase)
 		regdata = bcmsdh_reg_read(sdh,
 			CORE_SB(corebase, sbtmstatehigh), 4);
 		if (regdata & SBTMH_BUSY)
-			DHD_ERROR(("%s: ARM core still busy\n", __func__));
+			dhd_dbg(ERROR, "%s: ARM core still busy\n", __func__);
 
 		regdata = bcmsdh_reg_read(sdh,
 			CORE_SB(corebase, sbidlow), 4);
@@ -6159,12 +6249,12 @@ dhdsdio_chip_attach(struct dhd_bus *bus, void *regs)
 	int err;
 	u8 clkval, clkset;
 
-	DHD_TRACE(("%s: Enter\n", __func__));
+	dhd_dbg(TRACE, "%s: Enter\n", __func__);
 
 	/* alloc chip_info_t */
 	ci = kmalloc(sizeof(struct chip_info), GFP_ATOMIC);
 	if (NULL == ci) {
-		DHD_ERROR(("%s: malloc failed!\n", __func__));
+		dhd_dbg(ERROR, "%s: malloc failed!\n", __func__);
 		return -ENOMEM;
 	}
 
@@ -6176,7 +6266,7 @@ dhdsdio_chip_attach(struct dhd_bus *bus, void *regs)
 	bcmsdh_cfg_write(bus->sdh, SDIO_FUNC_1, SBSDIO_FUNC1_CHIPCLKCSR,
 			clkset, &err);
 	if (err) {
-		DHD_ERROR(("%s: error writing for HT off\n", __func__));
+		dhd_dbg(ERROR, "%s: error writing for HT off\n", __func__);
 		goto fail;
 	}
 
@@ -6192,8 +6282,9 @@ dhdsdio_chip_attach(struct dhd_bus *bus, void *regs)
 				!SBSDIO_ALPAV(clkval)),
 				PMU_MAX_TRANSITION_DLY);
 		if (!SBSDIO_ALPAV(clkval)) {
-			DHD_ERROR(("%s: timeout on ALPAV wait, clkval 0x%02x\n",
-				__func__, clkval));
+			dhd_dbg(ERROR,
+				"%s: timeout on ALPAV wait, clkval 0x%02x\n",
+				__func__, clkval);
 			err = -EBUSY;
 			goto fail;
 		}
@@ -6204,8 +6295,9 @@ dhdsdio_chip_attach(struct dhd_bus *bus, void *regs)
 				clkset, &err);
 		udelay(65);
 	} else {
-		DHD_ERROR(("%s: ChipClkCSR access: wrote 0x%02x read 0x%02x\n",
-			__func__, clkset, clkval));
+		dhd_dbg(ERROR,
+			"%s: ChipClkCSR access: wrote 0x%02x read 0x%02x\n",
+			__func__, clkset, clkval);
 		err = -EACCES;
 		goto fail;
 	}
@@ -6363,10 +6455,12 @@ dhdsdio_sdiod_drive_strength_init(struct dhd_bus *bus, u32 drivestrength) {
 		str_shift = 11;
 		break;
 	default:
-		DHD_ERROR(("No SDIO Drive strength init"
-			"done for chip %s rev %d pmurev %d\n",
+#ifdef BCMDBG
+		dhd_dbg(ERROR,
+			"No SDIO Drive strength init done for chip %s rev %d pmurev %d\n",
 			bcm_chipname(bus->ci->chip, chn, 8),
-			bus->ci->chiprev, bus->ci->pmurev));
+			bus->ci->chiprev, bus->ci->pmurev);
+#endif
 		break;
 	}
 
@@ -6394,15 +6488,16 @@ dhdsdio_sdiod_drive_strength_init(struct dhd_bus *bus, u32 drivestrength) {
 			CORE_CC_REG(bus->ci->cccorebase, chipcontrol_addr),
 			4, cc_data_temp);
 
-		DHD_INFO(("SDIO: %dmA drive strength selected, set to 0x%08x\n",
-			drivestrength, cc_data_temp));
+		dhd_dbg(INFO,
+			"SDIO: %dmA drive strength selected, set to 0x%08x\n",
+			drivestrength, cc_data_temp);
 	}
 }
 
 static void
 dhdsdio_chip_detach(struct dhd_bus *bus)
 {
-	DHD_TRACE(("%s: Enter\n", __func__));
+	dhd_dbg(TRACE, "%s: Enter\n", __func__);
 
 	kfree(bus->ci);
 	bus->ci = NULL;
-- 
1.7.5.rc3.dirty






More information about the devel mailing list