Skip to contentSkip to conversation

drivers/net/8139too.c: rework the debug levels

PATCH In review Adrian Bunk 2 participants 2 messages Jul 22, 2005 – Jul 31, 2005

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers/net/8139too.c: rework the debug levels

I started looking at this driver after seeing the following warnings with -Wundef:

<-- snip -->

...
CC drivers/net/8139too.o
drivers/net/8139too.c:1961:5: warning: "RTL8139_DEBUG" is not defined drivers/net/8139too.c:2047:5: warning: "RTL8139_DEBUG" is not defined
...

<-- snip -->

Looking at this driver, I wondered why there were two different #define's controlling the debug output of the driver.

This patch consolidates this to one debug level, and the default setting "1" results in exactly the same 8139too.o as with the old defaults.

---

 drivers/net/8139too.c |   22 ++++++++++------------
 1 files changed, 10 insertions(+), 12 deletions(-)
drivers/net/8139too.c renamed from drivers/net/8139too.c.old +10 -12
@@ -85,7 +85,8 @@
 	Submitting bug reports:
 
 		"rtl8139-diag -mmmaaavvveefN" output
-		enable RTL8139_DEBUG below, and look at 'dmesg' or kernel log
+		set RTL8139_DEBUG to a higher debug level below,
+		and look at 'dmesg' or kernel log
 
 */
 
@@ -126,21 +127,18 @@
 #define USE_IO_OPS 1
 #endif
 
-/* define to 1 to enable copious debugging info */
-#undef RTL8139_DEBUG
+/* debug levels: 0-4 */
+#define RTL8139_DEBUG 1
 
-/* define to 1 to disable lightweight runtime debugging checks */
-#undef RTL8139_NDEBUG
 
-
-#ifdef RTL8139_DEBUG
+#if RTL8139_DEBUG > 1
 /* note: prints function name for you */
 #  define DPRINTK(fmt, args...) printk(KERN_DEBUG "%s: " fmt, __FUNCTION__ , ## args)
 #else
 #  define DPRINTK(fmt, args...)
 #endif
 
-#ifdef RTL8139_NDEBUG
+#if RTL8139_DEBUG == 0
 #  define assert(expr) do {} while (0)
 #else
 #  define assert(expr) \
@@ -1794,13 +1792,13 @@
 		tx_left--;
 	}
 
-#ifndef RTL8139_NDEBUG
+#if RTL8139_DEBUG > 0
 	if (tp->cur_tx - dirty_tx > NUM_TX_DESC) {
 		printk (KERN_ERR "%s: Out-of-sync dirty pointer, %ld vs. %ld.\n",
 		        dev->name, dirty_tx, tp->cur_tx);
 		dirty_tx += NUM_TX_DESC;
 	}
-#endif /* RTL8139_NDEBUG */
+#endif /* RTL8139_DEBUG > 0 */
 
 	/* only wake the queue if we did work, and the queue is stopped */
 	if (tp->dirty_tx != dirty_tx) {
@@ -1958,7 +1956,7 @@
 			printk(KERN_DEBUG "%s:  rtl8139_rx() status %4.4x, size %4.4x,"
 				" cur %4.4x.\n", dev->name, rx_status,
 			 rx_size, cur_rx);
-#if RTL8139_DEBUG > 2
+#if RTL8139_DEBUG > 3
 		{
 			int i;
 			DPRINTK ("%s: Frame contents ", dev->name);
@@ -2044,7 +2042,7 @@
 	if (unlikely(!received || rx_size == 0xfff0))
 		rtl8139_isr_ack(tp);
 
-#if RTL8139_DEBUG > 1
+#if RTL8139_DEBUG > 2
 	DPRINTK ("%s: Done rtl8139_rx(), current %4.4x BufAddr %4.4x,"
 		 " free to %4.4x, Cmd %2.2x.\n", dev->name, cur_rx,
 		 RTL_R16 (RxBufAddr),
#1 lore raw
Quoted 1 line · Adrian Bunk

Looking at this driver, I wondered why there were two different #define's controlling the debug output of the driver.

Because debug output and runtime checks are two different concepts, two different behaviors.

Jeff