Skip to contentSkip to conversation

bcm: Replace the BCM_DEBUG_* and BCM_SHOW_* macros with functions

PATCH Superseded Devendra Naga 2 participants 3 messages May 29, 2012 Staging

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 bcm: Replace the BCM_DEBUG_* and BCM_SHOW_* macros with functions

This patch is made by following the improvements told by Joe Perches, replaced the BCM_DEBUG* and BCM_SHOW* macros into functions and added them in a file and added macros in the Debug.h file. This patch also improves the if check in bcm_show_debug_bitmap,

the check was

	if ((i == 1) || (i == 2) || (i == 4) || (i == 8));
anyway its a check to find whether its a power of two, and replaces
it like the following,
	if ((i != 0) && !(i & (i - 1)))
---
 drivers/staging/bcm/Debug.c  |   54 ++++++++++++++++++++++++++++++++++++
 drivers/staging/bcm/Debug.h  |   62 ++++++++++++++----------------------------
 drivers/staging/bcm/Makefile |    2 +-
 3 files changed, 76 insertions(+), 42 deletions(-)
 create mode 100644 drivers/staging/bcm/Debug.c
drivers/staging/bcm/Debug.c new file +54 -0
new file mode 100644
index 0000000..5ae629a
@@ -0,0 +1,54 @@
+#include "headers.h"
+
+void bcm_debug_print(PMINI_ADAPTER Adapter, int Type, int SubType,
+			int dbg_level, const char *fmt, ...)
+{
+	struct va_format vaf;
+	va_list args;
+	UINT debug_level = Adapter->stDebugState.debug_level;
+
+	va_start(args, fmt);
+
+	vaf.fmt = fmt;
+	vaf.va = &args;
+
+	if (DBG_TYPE_PRINTK == Type)
+		pr_info("%s: %pV", __func__, &vaf);
+	else if (Adapter &&
+		(dbg_level & DBG_LVL_BITMASK) <= debug_level &&
+		(Type & Adapter->stDebugState.type) &&
+		(SubType & Adapter->stDebugState.subtype[Type])) {
+		if (dbg_level & DBG_NO_FUNC_PRINT)
+			printk(KERN_DEBUG "%pV" , &vaf);
+		else
+			printk(KERN_DEBUG "%s: %pV", __func__, &vaf);
+	}
+
+	va_end(args);
+}
+
+void bcm_debug_print_buffer(PMINI_ADAPTER Adapter, int Type, int SubType,
+			    int dbg_level, const void *buffer, size_t bufferlen)
+{
+	if (DBG_TYPE_PRINTK == Type ||
+	   (Adapter &&
+	   (dbg_level & DBG_LVL_BITMASK) <= Adapter->stDebugState.debug_level &&
+	   (Type & Adapter->stDebugState.type) &&
+	   (SubType & Adapter->stDebugState.subtype[Type]))) {
+		printk(KERN_DEBUG "%s:\n", __func__);
+		print_hex_dump(KERN_DEBUG, " ", DUMP_PREFIX_OFFSET,
+			       16, 1, buffer, bufferlen, false);
+	}
+}
+
+void bcm_show_debug_bitmap(PMINI_ADAPTER Adapter)
+{
+	int i;
+	for (i = 0; i < (NUMTYPES * 2) + 1; i++) {
+		if ((i != 0) && !(i & (i - 1))) {
+			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0,
+					"subtype[%d] = 0x%08x\n",
+					i, Adapter->stDebugState.subtype[i]);
+		}
+	}
+}
drivers/staging/bcm/Debug.h +21 -41

78 lines not on this page · raw message

drivers/staging/bcm/Makefile +1 -1
index 652b7f8..85b134d 100644
@@ -7,6 +7,6 @@ obj-$(CONFIG_BCM_WIMAX) +=	bcm_wimax.o
 bcm_wimax-y :=  InterfaceDld.o InterfaceIdleMode.o InterfaceInit.o InterfaceRx.o \
 		InterfaceIsr.o InterfaceMisc.o InterfaceTx.o \
 		CmHost.o IPv6Protocol.o Qos.o Transmit.o\
-		Bcmnet.o DDRInit.o HandleControlPacket.o\
+		Debug.o Bcmnet.o DDRInit.o HandleControlPacket.o\
 		LeakyBucket.o Misc.o sort.o Bcmchar.o hostmibs.o PHSModule.o\
 		led_control.o nvm.o vendorspecificextn.o
Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 10 lines · Devendra Naga

This patch is made by following the improvements told by Joe Perches, replaced the BCM_DEBUG* and BCM_SHOW* macros into functions and added them in a file and added macros in the Debug.h file. This patch also improves the if check in bcm_show_debug_bitmap,

the check was

	if ((i == 1) || (i == 2) || (i == 4) || (i == 8));
anyway its a check to find whether its a power of two, and replaces
it like the following,
	if ((i != 0) && !(i & (i - 1)))

So why not using is_power_of_2() ?

#2 lore raw

Hello Eric,

Quoted 6 lines · Eric Dumazet
Quoted 5 lines · Devendra Naga

This patch is made by following the improvements told by Joe Perches, replaced the BCM_DEBUG* and BCM_SHOW* macros into functions and added them in a file and added macros in the Debug.h file. This patch also improves the if check in bcm_show_debug_bitmap,

Quoted 8 lines
Quoted 5 lines

the check was
      if ((i == 1) || (i == 2) || (i == 4) || (i == 8)); anyway its a check to find whether its a power of two, and replaces it like the following,
      if ((i != 0) && !(i & (i - 1)))

So why not using is_power_of_2() ?

I really dont know its there. Thanks for letting me know, :), will do and submit the change.

Quoted 1 line

Thanks,
Devendra.