aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorBen Dooks <ben-linux@fluff.org>2008-02-04 19:02:03 -0500
committerJeff Garzik <jeff@garzik.org>2008-02-11 11:06:23 -0500
commit5b2b4ff05593bc35c90dac84ecb82cb7501ecd07 (patch)
tree4faf39b5546825c2676fd06db839bdadbf808cff /drivers/net
parenta76836f95d285edcbdcddde5dfaca56e2030f2f5 (diff)
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>
Diffstat (limited to 'drivers/net')
-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
931 Enable the verify after the buffer write useful for debugging purpose. 931 Enable the verify after the buffer write useful for debugging purpose.
932 If unsure, say N. 932 If unsure, say N.
933 933
934config DM9000_DEBUGLEVEL
935 int "DM9000 maximum debug level"
936 depends on DM9000
937 default 4
938 help
939 The maximum level of debugging code compiled into the DM9000
940 driver.
941
934config SMC911X 942config SMC911X
935 tristate "SMSC LAN911[5678] support" 943 tristate "SMSC LAN911[5678] support"
936 select CRC32 944 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 @@
83 83
84#define DM9000_TIMER_WUT jiffies+(HZ*2) /* timer wakeup time : 2 second */ 84#define DM9000_TIMER_WUT jiffies+(HZ*2) /* timer wakeup time : 2 second */
85 85
86#define DM9000_DEBUG 0
87
88#if DM9000_DEBUG > 2
89#define PRINTK3(args...) printk(CARDNAME ": " args)
90#else
91#define PRINTK3(args...) do { } while(0)
92#endif
93
94#if DM9000_DEBUG > 1
95#define PRINTK2(args...) printk(CARDNAME ": " args)
96#else
97#define PRINTK2(args...) do { } while(0)
98#endif
99
100#if DM9000_DEBUG > 0
101#define PRINTK1(args...) printk(CARDNAME ": " args)
102#define PRINTK(args...) printk(CARDNAME ": " args)
103#else
104#define PRINTK1(args...) do { } while(0)
105#define PRINTK(args...) printk(KERN_DEBUG args)
106#endif
107
108#ifdef CONFIG_BLACKFIN 86#ifdef CONFIG_BLACKFIN
109#define readsb insb 87#define readsb insb
110#define readsw insw 88#define readsw insw
@@ -139,6 +117,8 @@ typedef struct board_info {
139 u8 phy_addr; 117 u8 phy_addr;
140 unsigned int flags; 118 unsigned int flags;
141 119
120 int debug_level;
121
142 void (*inblk)(void __iomem *port, void *data, int length); 122 void (*inblk)(void __iomem *port, void *data, int length);
143 void (*outblk)(void __iomem *port, void *data, int length); 123 void (*outblk)(void __iomem *port, void *data, int length);
144 void (*dumpblk)(void __iomem *port, int length); 124 void (*dumpblk)(void __iomem *port, int length);
@@ -159,6 +139,15 @@ typedef struct board_info {
159 u32 msg_enable; 139 u32 msg_enable;
160} board_info_t; 140} board_info_t;
161 141
142/* debug code */
143
144#define dm9000_dbg(db, lev, msg...) do { \
145 if ((lev) < CONFIG_DM9000_DEBUGLEVEL && \
146 (lev) < db->debug_level) { \
147 dev_dbg(db->dev, msg); \
148 } \
149} while (0)
150
162/* function declaration ------------------------------------- */ 151/* function declaration ------------------------------------- */
163static int dm9000_probe(struct platform_device *); 152static int dm9000_probe(struct platform_device *);
164static int dm9000_open(struct net_device *); 153static int dm9000_open(struct net_device *);
@@ -659,7 +648,7 @@ dm9000_init_dm9000(struct net_device *dev)
659{ 648{
660 board_info_t *db = (board_info_t *) dev->priv; 649 board_info_t *db = (board_info_t *) dev->priv;
661 650
662 PRINTK1("entering %s\n",__FUNCTION__); 651 dm9000_dbg(db, 1, "entering %s\n", __func__);
663 652
664 /* I/O mode */ 653 /* I/O mode */
665 db->io_mode = ior(db, DM9000_ISR) >> 6; /* ISR bit7:6 keeps I/O mode */ 654 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)
705 unsigned long flags; 694 unsigned long flags;
706 board_info_t *db = (board_info_t *) dev->priv; 695 board_info_t *db = (board_info_t *) dev->priv;
707 696
708 PRINTK3("dm9000_start_xmit\n"); 697 dm9000_dbg(db, 3, "%s:\n", __func__);
709 698
710 if (db->tx_pkt_cnt > 1) 699 if (db->tx_pkt_cnt > 1)
711 return 1; 700 return 1;
@@ -764,7 +753,7 @@ dm9000_stop(struct net_device *ndev)
764{ 753{
765 board_info_t *db = (board_info_t *) ndev->priv; 754 board_info_t *db = (board_info_t *) ndev->priv;
766 755
767 PRINTK1("entering %s\n",__FUNCTION__); 756 dm9000_dbg(db, 1, "entering %s\n", __func__);
768 757
769 /* deleted timer */ 758 /* deleted timer */
770 del_timer(&db->timer); 759 del_timer(&db->timer);
@@ -810,19 +799,14 @@ static irqreturn_t
810dm9000_interrupt(int irq, void *dev_id) 799dm9000_interrupt(int irq, void *dev_id)
811{ 800{
812 struct net_device *dev = dev_id; 801 struct net_device *dev = dev_id;
813 board_info_t *db; 802 board_info_t *db = (board_info_t *) dev->priv;
814 int int_status; 803 int int_status;
815 u8 reg_save; 804 u8 reg_save;
816 805
817 PRINTK3("entering %s\n",__FUNCTION__); 806 dm9000_dbg(db, 3, "entering %s\n", __func__);
818
819 if (!dev) {
820 PRINTK1("dm9000_interrupt() without DEVICE arg\n");
821 return IRQ_HANDLED;
822 }
823 807
824 /* A real interrupt coming */ 808 /* A real interrupt coming */
825 db = (board_info_t *) dev->priv; 809
826 spin_lock(&db->lock); 810 spin_lock(&db->lock);
827 811
828 /* Save previous register address */ 812 /* Save previous register address */
@@ -864,7 +848,7 @@ dm9000_timer(unsigned long data)
864 struct net_device *dev = (struct net_device *) data; 848 struct net_device *dev = (struct net_device *) data;
865 board_info_t *db = (board_info_t *) dev->priv; 849 board_info_t *db = (board_info_t *) dev->priv;
866 850
867 PRINTK3("dm9000_timer()\n"); 851 dm9000_dbg(db, 3, "entering %s\n", __func__);
868 852
869 mii_check_media(&db->mii, netif_msg_link(db), 0); 853 mii_check_media(&db->mii, netif_msg_link(db), 0);
870 854
@@ -1049,7 +1033,7 @@ dm9000_hash_table(struct net_device *dev)
1049 u16 i, oft, hash_table[4]; 1033 u16 i, oft, hash_table[4];
1050 unsigned long flags; 1034 unsigned long flags;
1051 1035
1052 PRINTK2("dm9000_hash_table()\n"); 1036 dm9000_dbg(db, 1, "entering %s\n", __func__);
1053 1037
1054 spin_lock_irqsave(&db->lock,flags); 1038 spin_lock_irqsave(&db->lock,flags);
1055 1039