]> git.karo-electronics.de Git - mv-sheeva.git/commitdiff
ath9k: Add "debug" file to debugfs
authorJeff Hansen <x@jeffhansen.com>
Wed, 27 May 2009 12:48:29 +0000 (12:48 +0000)
committerJohn W. Linville <linville@tuxdriver.com>
Wed, 3 Jun 2009 18:05:11 +0000 (14:05 -0400)
This patch adds the debug file to the ath9k debugfs, which lets you modify
the debug_mask at runtime, without having to reload the ath9k module.

Signed-off-by: Jeff Hansen <x@jeffhansen.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/ath/ath9k/debug.c
drivers/net/wireless/ath/ath9k/debug.h

index 80115ea07c7d0d49d77b0224f985299080ca946f..a42d631e74567112d3e65281eded4cf653c4ed39 100644 (file)
@@ -44,6 +44,38 @@ static int ath9k_debugfs_open(struct inode *inode, struct file *file)
        return 0;
 }
 
+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;
+       char buf[32];
+       unsigned int len = 0;
+       len += snprintf(buf, sizeof(buf), "0x%08x\n", sc->debug.debug_mask);
+       return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+}
+
+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;
+       unsigned long mask;
+       char buf[32];
+       if (copy_from_user(buf, user_buf, (sizeof(buf) - 1) < count ?
+               (sizeof(buf) - 1) : count))
+               return 0;
+       buf[sizeof(buf)-1] = 0;
+       if (strict_strtoul(buf, 0, &mask) == 0)
+               sc->debug.debug_mask = mask;
+       return count;
+}
+
+static const struct file_operations fops_debug = {
+       .read = read_file_debug,
+       .write = write_file_debug,
+       .open = ath9k_debugfs_open,
+       .owner = THIS_MODULE
+};
+
 static ssize_t read_file_dma(struct file *file, char __user *user_buf,
                             size_t count, loff_t *ppos)
 {
@@ -461,6 +493,11 @@ int ath9k_init_debug(struct ath_softc *sc)
        if (!sc->debug.debugfs_phy)
                goto err;
 
+       sc->debug.debugfs_debug = debugfs_create_file("debug",
+               S_IRUGO | S_IWUSR, sc->debug.debugfs_phy, sc, &fops_debug);
+       if (!sc->debug.debugfs_debug)
+               goto err;
+
        sc->debug.debugfs_dma = debugfs_create_file("dma", S_IRUGO,
                                       sc->debug.debugfs_phy, sc, &fops_dma);
        if (!sc->debug.debugfs_dma)
@@ -498,6 +535,7 @@ void ath9k_exit_debug(struct ath_softc *sc)
        debugfs_remove(sc->debug.debugfs_rcstat);
        debugfs_remove(sc->debug.debugfs_interrupt);
        debugfs_remove(sc->debug.debugfs_dma);
+       debugfs_remove(sc->debug.debugfs_debug);
        debugfs_remove(sc->debug.debugfs_phy);
 }
 
index cf9146a6aaaae2c66b7c7b6ee3c7b72599f0b35e..edda15bf2c1576bcb41b13f2ec6f79dedb48b22e 100644 (file)
@@ -95,6 +95,7 @@ struct ath_stats {
 struct ath9k_debug {
        int debug_mask;
        struct dentry *debugfs_phy;
+       struct dentry *debugfs_debug;
        struct dentry *debugfs_dma;
        struct dentry *debugfs_interrupt;
        struct dentry *debugfs_rcstat;