commit 369d62c54c3a2de5910182407f9134d3b07dacd0 Author: Jiri Slaby Date: Sun Jul 15 22:45:48 2007 +0200 debug stuff cleanup diff --git a/ath.c b/ath.c index 0898711..2b95442 100644 --- a/ath.c +++ b/ath.c @@ -42,10 +42,18 @@ #define ATH_DUMP_SKB 0 /* show skb contents */ #define AR_DEBUG 1 +#if AR_DEBUG #define DPRINTF(sc, _m, _fmt...) do { \ - if ((sc->debug & (_m)) && net_ratelimit()) \ - printk(_fmt); \ + if (((sc)->debug & (_m)) && net_ratelimit()) \ + printk(KERN_DEBUG _fmt); \ } while (0) +#else +static inline int __attribute__ ((format (printf, 3, 4))) +DPRINTF(struct ath_softc *sc, unsigned int m, const char *fmt, ...) +{ + return 0; +} +#endif enum { ATH_DEBUG_RESET = 0x00000020, /* reset processing */ ATH_DEBUG_MODE = 0x00000040, /* mode init/setup */ @@ -68,7 +76,7 @@ MODULE_PARM_DESC(outdoor, "Enable/disable outdoor use"); module_param(xchanmode, int, 0); MODULE_PARM_DESC(xchanmode, "Enable/disable extended channel mode"); -#ifdef AR_DEBUG +#if AR_DEBUG static unsigned int ath_debug; module_param_named(debug, ath_debug, uint, 0); #endif @@ -100,12 +108,12 @@ static struct pci_device_id ath_pci_id_table[] __devinitdata = { }; MODULE_DEVICE_TABLE(pci, ath_pci_id_table); -#ifdef AR_DEBUG +#if AR_DEBUG static void ath_printrxbuf(struct ath_buf *bf, int done) { struct ath_desc *ds = bf->desc; - printk("R (%p %llx) %08x %08x %08x %08x %08x %08x %c\n", + printk(KERN_DEBUG "R (%p %llx) %08x %08x %08x %08x %08x %08x %c\n", ds, (unsigned long long)bf->daddr, ds->ds_link, ds->ds_data, ds->ds_ctl0, ds->ds_ctl1, ds->ds_hw[0], ds->ds_hw[1], @@ -116,7 +124,8 @@ static void ath_printtxbuf(struct ath_buf *bf, int done) { struct ath_desc *ds = bf->desc; - printk("T (%p %llx) %08x %08x %08x %08x %08x %08x %08x %08x %c\n", + printk(KERN_DEBUG "T (%p %llx) %08x %08x %08x %08x %08x %08x %08x " + "%08x %c\n", ds, (unsigned long long)bf->daddr, ds->ds_link, ds->ds_data, ds->ds_ctl0, ds->ds_ctl1, ds->ds_hw[0], ds->ds_hw[1], ds->ds_hw[2], ds->ds_hw[3], @@ -125,17 +134,10 @@ static void ath_printtxbuf(struct ath_buf *bf, int done) #endif #if ATH_DUMP_SKB -static void ath_dump_skb(struct sk_buff *skb, unsigned int rx) +static inline void ath_dump_skb(struct sk_buff *skb, unsigned int rx) { - unsigned int a; - - printk(KERN_DEBUG "%c", rx ? 'r' : 't'); - for (a = 0; a < min(200U, skb->len) + 4; a++) { - printk("%.2x %s", skb->data[a], ((a+1) % 8) ? "" : " "); - if (!((a+1) % 16)) - printk("\n" KERN_DEBUG " "); - } - printk("\n"); + print_hex_dump_bytes(rx ? "r" : "t", DUMP_PREFIX_NONE, skb->data, + min(200U, skb->len)); } #else static inline void ath_dump_skb(struct sk_buff *skb, unsigned int rx) {} @@ -589,8 +591,8 @@ static void ath_stoprecv(struct ath_softc *sc) ath5k_hw_set_rx_filter(ah, 0); /* clear recv filter */ ath5k_hw_stop_rx_dma(ah); /* disable DMA engine */ mdelay(3); /* 3ms is long enough for 1 frame */ -#ifdef AR_DEBUG - if (sc->debug & (ATH_DEBUG_RESET | ATH_DEBUG_FATAL)) { // TODO: compiler warns integer overflow +#if AR_DEBUG + if (sc->debug & (ATH_DEBUG_RESET | ATH_DEBUG_FATAL)) { struct ath_desc *ds; struct ath_buf *bf; int status; @@ -613,9 +615,6 @@ static void ath_stoprecv(struct ath_softc *sc) static void ath_tx_draintxq(struct ath_softc *sc, struct ath_txq *txq) { -#ifdef AR_DEBUG - struct ath_hw *ah = sc->ah; -#endif struct ath_buf *bf, *bf0; /* @@ -624,9 +623,10 @@ static void ath_tx_draintxq(struct ath_softc *sc, struct ath_txq *txq) */ spin_lock_bh(&txq->lock); list_for_each_entry_safe(bf, bf0, &txq->q, list) { -#ifdef AR_DEBUG +#if AR_DEBUG if (sc->debug & ATH_DEBUG_RESET) - ath_printtxbuf(bf, !ah->ah_proc_tx_desc(ah, bf->desc)); + ath_printtxbuf(bf, !sc->ah->ah_proc_tx_desc(sc->ah, + bf->desc)); #endif pci_unmap_single(sc->pdev, bf->skbaddr, bf->skb->len, PCI_DMA_TODEVICE); @@ -1890,7 +1890,9 @@ static int __devinit ath_pci_probe(struct pci_dev *pdev, * Mark the device as detached to avoid processing * interrupts until setup is complete. */ +#if AR_DEBUG sc->debug = ath_debug; +#endif sc->invalid = 1; sc->iobase = mem; sc->cachelsz = csz * sizeof(u32); /* convert to bytes */ @@ -2029,7 +2031,7 @@ static int maxint = 0x7ffffff / 1000; #define CTL_AUTO -2 /* cannot be CTL_ANY or CTL_NONE */ static ctl_table ath_static_sysctls[] = { -#ifdef AR_DEBUG +#if AR_DEBUG { .ctl_name = CTL_AUTO, .procname = "debug", .mode = 0644,