[U-Boot] [PATCH 8/9 v2] DM9000: change some printf to use debug instead

Eric Jarrige eric.jarrige at armadeus.org
Sun Aug 28 23:49:20 CEST 2011


Signed-off-by: Eric Jarrige <eric.jarrige at armadeus.org>
Cc: Wolfgang Denk <wd at denx.de>
Cc: Detlev Zundel <dzu at denx.de>

Changes for v2:
	- Remove DM9000_ DEBUG macros and use debug() instead
---
 drivers/net/dm9000x.c |   97 +++++++++++++++++++++++--------------------------
 1 files changed, 46 insertions(+), 51 deletions(-)

diff --git a/drivers/net/dm9000x.c b/drivers/net/dm9000x.c
index b5c5573..7fe7e46 100644
--- a/drivers/net/dm9000x.c
+++ b/drivers/net/dm9000x.c
@@ -66,27 +66,6 @@ TODO: external MII is not functional, only internal at the moment.
 
 #include "dm9000x.h"
 
-/* Board/System/Debug information/definition ---------------- */
-
-/* #define CONFIG_DM9000_DEBUG */
-
-#ifdef CONFIG_DM9000_DEBUG
-#define DM9000_DBG(fmt,args...) printf(fmt, ##args)
-#define DM9000_DMP_PACKET(func,packet,length)  \
-	do { \
-		int i; 							\
-		printf("%s: length: %d\n", func, length);		\
-		for (i = 0; i < length; i++) {				\
-			if (i % 8 == 0)					\
-				printf("\n%s: %02x: ", func, i);	\
-			printf("%02x ", ((unsigned char *) packet)[i]);	\
-		} printf("\n");						\
-	} while(0)
-#else
-#define DM9000_DBG(fmt,args...)
-#define DM9000_DMP_PACKET(func,packet,length)
-#endif
-
 /* Structure/enum declaration ------------------------------- */
 typedef struct board_info {
 	u32 runt_length_counter;	/* counter: RX length < 64byte */
@@ -124,21 +103,37 @@ static void DM9000_iow(int reg, u8 value);
 #define DM9000_inw(r) readw((volatile u16 *)(r))
 #define DM9000_inl(r) readl((volatile u32 *)(r))
 
-#ifdef CONFIG_DM9000_DEBUG
+#ifdef DEBUG
 static void
 dump_regs(void)
 {
-	DM9000_DBG("\n");
-	DM9000_DBG("NCR   (0x00): %02x\n", DM9000_ior(0));
-	DM9000_DBG("NSR   (0x01): %02x\n", DM9000_ior(1));
-	DM9000_DBG("TCR   (0x02): %02x\n", DM9000_ior(2));
-	DM9000_DBG("TSRI  (0x03): %02x\n", DM9000_ior(3));
-	DM9000_DBG("TSRII (0x04): %02x\n", DM9000_ior(4));
-	DM9000_DBG("RCR   (0x05): %02x\n", DM9000_ior(5));
-	DM9000_DBG("RSR   (0x06): %02x\n", DM9000_ior(6));
-	DM9000_DBG("ISR   (0xFE): %02x\n", DM9000_ior(DM9000_ISR));
-	DM9000_DBG("\n");
+	debug("\n");
+	debug("NCR   (0x00): %02x\n", DM9000_ior(0));
+	debug("NSR   (0x01): %02x\n", DM9000_ior(1));
+	debug("TCR   (0x02): %02x\n", DM9000_ior(2));
+	debug("TSRI  (0x03): %02x\n", DM9000_ior(3));
+	debug("TSRII (0x04): %02x\n", DM9000_ior(4));
+	debug("RCR   (0x05): %02x\n", DM9000_ior(5));
+	debug("RSR   (0x06): %02x\n", DM9000_ior(6));
+	debug("ISR   (0xFE): %02x\n", DM9000_ior(DM9000_ISR));
+	debug("\n");
+}
+
+static void dm9000_dmp_packet(char *func, unsigned char *packet, int length)
+{
+	int i;
+	do {
+		printf("%s: length: %d\n", func, length);
+		for (i = 0; i < length; i++) {
+			if (i % 8 == 0)
+				printf("\n%s: %02x: ", func, i);
+			printf("%02x ", ((unsigned char *) packet)[i]);
+		}
+		printf("\n");
+	} while (0);
 }
+#else
+#define dm9000_dmp_packet(func, packet, length)
 #endif
 
 static void dm9000_outblk_8bit(volatile void *data_ptr, int count)
@@ -232,7 +227,7 @@ dm9000_probe(void)
 	id_val |= DM9000_ior(DM9000_PIDL) << 16;
 	id_val |= DM9000_ior(DM9000_PIDH) << 24;
 	if (id_val == DM9000_ID) {
-		printf("dm9000 i/o: 0x%x, id: 0x%x \n", CONFIG_DM9000_BASE,
+		debug("dm9000 i/o: 0x%x, id: 0x%x \n", CONFIG_DM9000_BASE,
 		       id_val);
 		return 0;
 	} else {
@@ -246,7 +241,7 @@ dm9000_probe(void)
 static void
 dm9000_reset(void)
 {
-	DM9000_DBG("resetting DM9000\n");
+	debug("resetting DM9000\n");
 
 	/* Reset DM9000,
 	   see DM9000 Application Notes V1.22 Jun 11, 2004 page 29 */
@@ -259,7 +254,7 @@ dm9000_reset(void)
 	DM9000_iow(DM9000_NCR, (NCR_LBK_INT_MAC | NCR_RST));
 
 	do {
-		DM9000_DBG("resetting the DM9000, 1st reset\n");
+		debug("resetting the DM9000, 1st reset\n");
 		udelay(25); /* Wait at least 20 us */
 	} while (DM9000_ior(DM9000_NCR) & 1);
 
@@ -267,7 +262,7 @@ dm9000_reset(void)
 	DM9000_iow(DM9000_NCR, (NCR_LBK_INT_MAC | NCR_RST)); /* Issue a second reset */
 
 	do {
-		DM9000_DBG("resetting the DM9000, 2nd reset\n");
+		debug("resetting the DM9000, 2nd reset\n");
 		udelay(25); /* Wait at least 20 us */
 	} while (DM9000_ior(DM9000_NCR) & 1);
 
@@ -285,7 +280,7 @@ static int dm9000_init(struct eth_device *dev, bd_t *bd)
 	u8 io_mode;
 	struct board_info *db = &dm9000_info;
 
-	DM9000_DBG("%s\n", __func__);
+	debug("%s\n", __func__);
 
 	/* RESET device */
 	dm9000_reset();
@@ -298,19 +293,19 @@ static int dm9000_init(struct eth_device *dev, bd_t *bd)
 
 	switch (io_mode) {
 	case 0x0:  /* 16-bit mode */
-		printf("DM9000: running in 16 bit mode\n");
+		debug("DM9000: running in 16 bit mode\n");
 		db->outblk    = dm9000_outblk_16bit;
 		db->inblk     = dm9000_inblk_16bit;
 		db->rx_status = dm9000_rx_status_16bit;
 		break;
 	case 0x01:  /* 32-bit mode */
-		printf("DM9000: running in 32 bit mode\n");
+		debug("DM9000: running in 32 bit mode\n");
 		db->outblk    = dm9000_outblk_32bit;
 		db->inblk     = dm9000_inblk_32bit;
 		db->rx_status = dm9000_rx_status_32bit;
 		break;
 	case 0x02: /* 8 bit mode */
-		printf("DM9000: running in 8 bit mode\n");
+		debug("DM9000: running in 8 bit mode\n");
 		db->outblk    = dm9000_outblk_8bit;
 		db->inblk     = dm9000_inblk_8bit;
 		db->rx_status = dm9000_rx_status_8bit;
@@ -351,8 +346,8 @@ static int dm9000_init(struct eth_device *dev, bd_t *bd)
 
 	/* read back mac, just to be sure */
 	for (i = 0, oft = 0x10; i < 6; i++, oft++)
-		DM9000_DBG("%02x:", DM9000_ior(oft));
-	DM9000_DBG("\n");
+		debug("%02x:", DM9000_ior(oft));
+	debug("\n");
 
 	/* Activate DM9000 */
 	/* RX enable */
@@ -404,7 +399,7 @@ static int dm9000_send(struct eth_device *netdev, volatile void *packet,
 	int tmo;
 	struct board_info *db = &dm9000_info;
 
-	DM9000_DMP_PACKET(__func__ , packet, length);
+	dm9000_dmp_packet(__func__ , packet, length);
 
 	DM9000_iow(DM9000_ISR, IMR_PTM); /* Clear Tx bit in ISR */
 
@@ -432,7 +427,7 @@ static int dm9000_send(struct eth_device *netdev, volatile void *packet,
 	}
 	DM9000_iow(DM9000_ISR, IMR_PTM); /* Clear Tx bit in ISR */
 
-	DM9000_DBG("transmit done\n\n");
+	debug("transmit done\n\n");
 	return 0;
 }
 
@@ -442,7 +437,7 @@ static int dm9000_send(struct eth_device *netdev, volatile void *packet,
 */
 static void dm9000_halt(struct eth_device *netdev)
 {
-	DM9000_DBG("%s\n", __func__);
+	debug("%s\n", __func__);
 
 	/* RESET devie */
 	dm9000_phy_write(0, 0x8000);	/* PHY RESET */
@@ -487,12 +482,12 @@ static int dm9000_rx(struct eth_device *netdev)
 		if (rxbyte != DM9000_PKT_RDY)
 			return 0; /* No packet received, ignore */
 
-		DM9000_DBG("receiving packet\n");
+		debug("receiving packet\n");
 
 		/* A packet ready now  & Get status/length */
 		(db->rx_status)(&RxStatus, &RxLen);
 
-		DM9000_DBG("rx status: 0x%04x rx len: %d\n", RxStatus, RxLen);
+		debug("rx status: 0x%04x rx len: %d\n", RxStatus, RxLen);
 
 		/* Move data from DM9000 */
 		/* Read received packet from RX SRAM */
@@ -514,9 +509,9 @@ static int dm9000_rx(struct eth_device *netdev)
 				dm9000_reset();
 			}
 		} else {
-			DM9000_DMP_PACKET(__func__ , rdptr, RxLen);
+			dm9000_dmp_packet(__func__ , rdptr, RxLen);
 
-			DM9000_DBG("passing packet to upper layer\n");
+			debug("passing packet to upper layer\n");
 			NetReceive(NetRxPackets[0], RxLen);
 		}
 	}
@@ -593,7 +588,7 @@ dm9000_phy_read(int reg)
 	val = (DM9000_ior(DM9000_EPDRH) << 8) | DM9000_ior(DM9000_EPDRL);
 
 	/* The read data keeps on REG_0D & REG_0E */
-	DM9000_DBG("dm9000_phy_read(0x%x): 0x%x\n", reg, val);
+	debug("dm9000_phy_read(0x%x): 0x%x\n", reg, val);
 	return val;
 }
 
@@ -613,7 +608,7 @@ dm9000_phy_write(int reg, u16 value)
 	DM9000_iow(DM9000_EPCR, 0xa);	/* Issue phyxcer write command */
 	udelay(500);			/* Wait write complete */
 	DM9000_iow(DM9000_EPCR, 0x0);	/* Clear phyxcer write command */
-	DM9000_DBG("dm9000_phy_write(reg:0x%x, value:0x%x)\n", reg, value);
+	debug("dm9000_phy_write(reg:0x%x, value:0x%x)\n", reg, value);
 }
 
 int dm9000_initialize(bd_t *bis)



More information about the U-Boot mailing list