ath9k add debug to debugfs
PATCH 2/2 ath9k add debug to debugfs
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.
-Jeff
---------------------------------------------------
"If someone's gotta do it, it might as well be me."
x at jeffhansen.com
-------------- next part --------------
drivers/net/wireless/ath/ath9k/debug.h +1 -0
@@ -95,6 +95,7 @@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;
drivers/net/wireless/ath/ath9k/debug.c +35 -0
@@ -45,6 +45,35 @@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; +char buf[32 ]; +copy_from_user (buf, user_buf, (sizeof (buf) -1 ) < count ? + (sizeof (buf) -1 ) : count); + buf[sizeof (buf)-1 ] =0 ; + sc->debug.debug_mask =simple_strtoul (buf,NULL ,0 ); +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) {
@@ -458,6 +487,11 @@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)
@@ -495,6 +529,7 @@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); }