]> nv-tegra.nvidia Code Review - linux-2.6.git/blobdiff - drivers/net/wireless/ath/ath9k/debug.c
ath9k: use common read/write ops on pci and debug code
[linux-2.6.git] / drivers / net / wireless / ath / ath9k / debug.c
index 2be4c22520479bc68f184e6a009adc91ad3d94bc..352914cae6d8b4611ac4db5a8652d41be0d93ed8 100644 (file)
 
 #include "ath9k.h"
 
-static unsigned int ath9k_debug = DBG_DEFAULT;
+#define REG_WRITE_D(_ah, _reg, _val) \
+       ath9k_hw_common(_ah)->ops->write((_ah), (_val), (_reg))
+#define REG_READ_D(_ah, _reg) \
+       ath9k_hw_common(_ah)->ops->read((_ah), (_reg))
+
+static unsigned int ath9k_debug = ATH_DBG_DEFAULT;
 module_param_named(debug, ath9k_debug, uint, 0);
 
 static struct dentry *ath9k_debugfs_root;
 
-void DPRINTF(struct ath_softc *sc, int dbg_mask, const char *fmt, ...)
-{
-       if (!sc)
-               return;
-
-       if (sc->debug.debug_mask & dbg_mask) {
-               va_list args;
-
-               va_start(args, fmt);
-               printk(KERN_DEBUG "ath9k: ");
-               vprintk(fmt, args);
-               va_end(args);
-       }
-}
-
 static int ath9k_debugfs_open(struct inode *inode, struct file *file)
 {
        file->private_data = inode->i_private;
@@ -48,10 +38,11 @@ static ssize_t read_file_debug(struct file *file, char __user *user_buf,
                             size_t count, loff_t *ppos)
 {
        struct ath_softc *sc = file->private_data;
+       struct ath_common *common = ath9k_hw_common(sc->sc_ah);
        char buf[32];
        unsigned int len;
 
-       len = snprintf(buf, sizeof(buf), "0x%08x\n", sc->debug.debug_mask);
+       len = snprintf(buf, sizeof(buf), "0x%08x\n", common->debug_mask);
        return simple_read_from_buffer(user_buf, count, ppos, buf, len);
 }
 
@@ -59,6 +50,7 @@ static ssize_t write_file_debug(struct file *file, const char __user *user_buf,
                             size_t count, loff_t *ppos)
 {
        struct ath_softc *sc = file->private_data;
+       struct ath_common *common = ath9k_hw_common(sc->sc_ah);
        unsigned long mask;
        char buf[32];
        ssize_t len;
@@ -71,7 +63,7 @@ static ssize_t write_file_debug(struct file *file, const char __user *user_buf,
        if (strict_strtoul(buf, 0, &mask))
                return -EINVAL;
 
-       sc->debug.debug_mask = mask;
+       common->debug_mask = mask;
        return count;
 }
 
@@ -95,7 +87,7 @@ static ssize_t read_file_dma(struct file *file, char __user *user_buf,
 
        ath9k_ps_wakeup(sc);
 
-       REG_WRITE(ah, AR_MACMISC,
+       REG_WRITE_D(ah, AR_MACMISC,
                  ((AR_MACMISC_DMA_OBS_LINE_8 << AR_MACMISC_DMA_OBS_S) |
                   (AR_MACMISC_MISC_OBS_BUS_1 <<
                    AR_MACMISC_MISC_OBS_BUS_MSB_S)));
@@ -107,7 +99,7 @@ static ssize_t read_file_dma(struct file *file, char __user *user_buf,
                if (i % 4 == 0)
                        len += snprintf(buf + len, sizeof(buf) - len, "\n");
 
-               val[i] = REG_READ(ah, AR_DMADBG_0 + (i * sizeof(u32)));
+               val[i] = REG_READ_D(ah, AR_DMADBG_0 + (i * sizeof(u32)));
                len += snprintf(buf + len, sizeof(buf) - len, "%d: %08x ",
                                i, val[i]);
        }
@@ -157,9 +149,9 @@ static ssize_t read_file_dma(struct file *file, char __user *user_buf,
                (val[6] & 0x0001e000) >> 13, (val[6] & 0x001e0000) >> 17);
 
        len += snprintf(buf + len, sizeof(buf) - len, "pcu observe: 0x%x \n",
-                       REG_READ(ah, AR_OBS_BUS_1));
+                       REG_READ_D(ah, AR_OBS_BUS_1));
        len += snprintf(buf + len, sizeof(buf) - len,
-                       "AR_CR: 0x%x \n", REG_READ(ah, AR_CR));
+                       "AR_CR: 0x%x \n", REG_READ_D(ah, AR_CR));
 
        ath9k_ps_restore(sc);
 
@@ -376,12 +368,12 @@ static ssize_t read_file_wiphy(struct file *file, char __user *user_buf,
                                aphy->chan_idx, aphy->chan_is_ht);
        }
 
-       put_unaligned_le32(REG_READ(sc->sc_ah, AR_STA_ID0), addr);
-       put_unaligned_le16(REG_READ(sc->sc_ah, AR_STA_ID1) & 0xffff, addr + 4);
+       put_unaligned_le32(REG_READ_D(sc->sc_ah, AR_STA_ID0), addr);
+       put_unaligned_le16(REG_READ_D(sc->sc_ah, AR_STA_ID1) & 0xffff, addr + 4);
        len += snprintf(buf + len, sizeof(buf) - len,
                        "addr: %pM\n", addr);
-       put_unaligned_le32(REG_READ(sc->sc_ah, AR_BSSMSKL), addr);
-       put_unaligned_le16(REG_READ(sc->sc_ah, AR_BSSMSKU) & 0xffff, addr + 4);
+       put_unaligned_le32(REG_READ_D(sc->sc_ah, AR_BSSMSKL), addr);
+       put_unaligned_le16(REG_READ_D(sc->sc_ah, AR_BSSMSKU) & 0xffff, addr + 4);
        len += snprintf(buf + len, sizeof(buf) - len,
                        "addrmask: %pM\n", addr);
 
@@ -568,9 +560,12 @@ static const struct file_operations fops_xmit = {
        .owner = THIS_MODULE
 };
 
-int ath9k_init_debug(struct ath_softc *sc)
+int ath9k_init_debug(struct ath_hw *ah)
 {
-       sc->debug.debug_mask = ath9k_debug;
+       struct ath_softc *sc = ah->ah_sc;
+       struct ath_common *common = ath9k_hw_common(sc->sc_ah);
+
+       common->debug_mask = ath9k_debug;
 
        if (!ath9k_debugfs_root)
                return -ENOENT;
@@ -619,12 +614,14 @@ int ath9k_init_debug(struct ath_softc *sc)
 
        return 0;
 err:
-       ath9k_exit_debug(sc);
+       ath9k_exit_debug(ah);
        return -ENOMEM;
 }
 
-void ath9k_exit_debug(struct ath_softc *sc)
+void ath9k_exit_debug(struct ath_hw *ah)
 {
+       struct ath_softc *sc = ah->ah_sc;
+
        debugfs_remove(sc->debug.debugfs_xmit);
        debugfs_remove(sc->debug.debugfs_wiphy);
        debugfs_remove(sc->debug.debugfs_rcstat);