summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Dooks <ben-linux@fluff.org>2008-02-05 00:02:03 +0000
committerJeff Garzik <jeff@garzik.org>2008-02-11 11:06:23 -0500
commit5b2b4ff05593bc35c90dac84ecb82cb7501ecd07 (patch)
tree4faf39b5546825c2676fd06db839bdadbf808cff
parenta76836f95d285edcbdcddde5dfaca56e2030f2f5 (diff)
downloadlinux-5b2b4ff05593bc35c90dac84ecb82cb7501ecd07.tar.bz2
DM9000 update debugging macros to use debug level
Change the debug macros to use the compiler to elide any unnecessary debug level, and to allow device configurable debug control. Signed-off-by: Ben Dooks <ben-linux@fluff.org> Signed-off-by: Jeff Garzik <jeff@garzik.org>
-rw-r--r--drivers/net/Kconfig8
-rw-r--r--drivers/net/dm9000.c54
2 files changed, 27 insertions, 35 deletions
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 37f8e4790b68..f337800076c0 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -931,6 +931,14 @@ config ENC28J60_WRITEVERIFY
Enable the verify after the buffer write useful for debugging purpose.
If unsure, say N.
+config DM9000_DEBUGLEVEL
+ int "DM9000 maximum debug level"
+ depends on DM9000
+ default 4
+ help
+ The maximum level of debugging code compiled into the DM9000
+ driver.
+
config SMC911X
tristate "SMSC LAN911[5678] support"
select CRC32
diff --git a/drivers/net/dm9000.c b/drivers/net/dm9000.c
index 95563982d19f..5470062659f4 100644
--- a/drivers/net/dm9000.c
+++ b/drivers/net/dm9000.c
@@ -83,28 +83,6 @@
#define DM9000_TIMER_WUT jiffies+(HZ*2) /* timer wakeup time : 2 second */
-#define DM9000_DEBUG 0
-
-#if DM9000_DEBUG > 2
-#define PRINTK3(args...) printk(CARDNAME ": " args)
-#else
-#define PRINTK3(args...) do { } while(0)
-#endif
-
-#if DM9000_DEBUG > 1
-#define PRINTK2(args...) printk(CARDNAME ": " args)
-#else
-#define PRINTK2(args...) do { } while(0)
-#endif
-
-#if DM9000_DEBUG > 0
-#define PRINTK1(args...) printk(CARDNAME ": " args)
-#define PRINTK(args...) printk(CARDNAME ": " args)
-#else
-#define PRINTK1(args...) do { } while(0)
-#define PRINTK(args...) printk(KERN_DEBUG args)
-#endif
-
#ifdef CONFIG_BLACKFIN
#define readsb insb
#define readsw insw
@@ -139,6 +117,8 @@ typedef struct board_info {
u8 phy_addr;
unsigned int flags;
+ int debug_level;
+
void (*inblk)(void __iomem *port, void *data, int length);
void (*outblk)(void __iomem *port, void *data, int length);
void (*dumpblk)(void __iomem *port, int length);
@@ -159,6 +139,15 @@ typedef struct board_info {
u32 msg_enable;
} board_info_t;
+/* debug code */
+
+#define dm9000_dbg(db, lev, msg...) do { \
+ if ((lev) < CONFIG_DM9000_DEBUGLEVEL && \
+ (lev) < db->debug_level) { \
+ dev_dbg(db->dev, msg); \
+ } \
+} while (0)
+
/* function declaration ------------------------------------- */
static int dm9000_probe(struct platform_device *);
static int dm9000_open(struct net_device *);
@@ -659,7 +648,7 @@ dm9000_init_dm9000(struct net_device *dev)
{
board_info_t *db = (board_info_t *) dev->priv;
- PRINTK1("entering %s\n",__FUNCTION__);
+ dm9000_dbg(db, 1, "entering %s\n", __func__);
/* I/O mode */
db->io_mode = ior(db, DM9000_ISR) >> 6; /* ISR bit7:6 keeps I/O mode */
@@ -705,7 +694,7 @@ dm9000_start_xmit(struct sk_buff *skb, struct net_device *dev)
unsigned long flags;
board_info_t *db = (board_info_t *) dev->priv;
- PRINTK3("dm9000_start_xmit\n");
+ dm9000_dbg(db, 3, "%s:\n", __func__);
if (db->tx_pkt_cnt > 1)
return 1;
@@ -764,7 +753,7 @@ dm9000_stop(struct net_device *ndev)
{
board_info_t *db = (board_info_t *) ndev->priv;
- PRINTK1("entering %s\n",__FUNCTION__);
+ dm9000_dbg(db, 1, "entering %s\n", __func__);
/* deleted timer */
del_timer(&db->timer);
@@ -810,19 +799,14 @@ static irqreturn_t
dm9000_interrupt(int irq, void *dev_id)
{
struct net_device *dev = dev_id;
- board_info_t *db;
+ board_info_t *db = (board_info_t *) dev->priv;
int int_status;
u8 reg_save;
- PRINTK3("entering %s\n",__FUNCTION__);
-
- if (!dev) {
- PRINTK1("dm9000_interrupt() without DEVICE arg\n");
- return IRQ_HANDLED;
- }
+ dm9000_dbg(db, 3, "entering %s\n", __func__);
/* A real interrupt coming */
- db = (board_info_t *) dev->priv;
+
spin_lock(&db->lock);
/* Save previous register address */
@@ -864,7 +848,7 @@ dm9000_timer(unsigned long data)
struct net_device *dev = (struct net_device *) data;
board_info_t *db = (board_info_t *) dev->priv;
- PRINTK3("dm9000_timer()\n");
+ dm9000_dbg(db, 3, "entering %s\n", __func__);
mii_check_media(&db->mii, netif_msg_link(db), 0);
@@ -1049,7 +1033,7 @@ dm9000_hash_table(struct net_device *dev)
u16 i, oft, hash_table[4];
unsigned long flags;
- PRINTK2("dm9000_hash_table()\n");
+ dm9000_dbg(db, 1, "entering %s\n", __func__);
spin_lock_irqsave(&db->lock,flags);