diff options
author | Jeff Hansen <x@jeffhansen.com> | 2009-05-27 08:48:29 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2009-06-03 14:05:11 -0400 |
commit | 2493928e4dbefa1869413cf24b7f605b9b69d0d2 (patch) | |
tree | 68dd75f350816eb36a435cc2a20ccb25cbf47e54 /drivers/net/wireless/ath/ath9k/debug.c | |
parent | bedf087af96a24861d09586ac25c26691300ff4c (diff) |
ath9k: Add "debug" file 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.
Signed-off-by: Jeff Hansen <x@jeffhansen.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/ath/ath9k/debug.c')
-rw-r--r-- | drivers/net/wireless/ath/ath9k/debug.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/drivers/net/wireless/ath/ath9k/debug.c b/drivers/net/wireless/ath/ath9k/debug.c index 80115ea07c7d..a42d631e7456 100644 --- a/drivers/net/wireless/ath/ath9k/debug.c +++ b/drivers/net/wireless/ath/ath9k/debug.c | |||
@@ -44,6 +44,38 @@ static int ath9k_debugfs_open(struct inode *inode, struct file *file) | |||
44 | return 0; | 44 | return 0; |
45 | } | 45 | } |
46 | 46 | ||
47 | static ssize_t read_file_debug(struct file *file, char __user *user_buf, | ||
48 | size_t count, loff_t *ppos) | ||
49 | { | ||
50 | struct ath_softc *sc = file->private_data; | ||
51 | char buf[32]; | ||
52 | unsigned int len = 0; | ||
53 | len += snprintf(buf, sizeof(buf), "0x%08x\n", sc->debug.debug_mask); | ||
54 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); | ||
55 | } | ||
56 | |||
57 | static ssize_t write_file_debug(struct file *file, const char __user *user_buf, | ||
58 | size_t count, loff_t *ppos) | ||
59 | { | ||
60 | struct ath_softc *sc = file->private_data; | ||
61 | unsigned long mask; | ||
62 | char buf[32]; | ||
63 | if (copy_from_user(buf, user_buf, (sizeof(buf) - 1) < count ? | ||
64 | (sizeof(buf) - 1) : count)) | ||
65 | return 0; | ||
66 | buf[sizeof(buf)-1] = 0; | ||
67 | if (strict_strtoul(buf, 0, &mask) == 0) | ||
68 | sc->debug.debug_mask = mask; | ||
69 | return count; | ||
70 | } | ||
71 | |||
72 | static const struct file_operations fops_debug = { | ||
73 | .read = read_file_debug, | ||
74 | .write = write_file_debug, | ||
75 | .open = ath9k_debugfs_open, | ||
76 | .owner = THIS_MODULE | ||
77 | }; | ||
78 | |||
47 | static ssize_t read_file_dma(struct file *file, char __user *user_buf, | 79 | static ssize_t read_file_dma(struct file *file, char __user *user_buf, |
48 | size_t count, loff_t *ppos) | 80 | size_t count, loff_t *ppos) |
49 | { | 81 | { |
@@ -461,6 +493,11 @@ int ath9k_init_debug(struct ath_softc *sc) | |||
461 | if (!sc->debug.debugfs_phy) | 493 | if (!sc->debug.debugfs_phy) |
462 | goto err; | 494 | goto err; |
463 | 495 | ||
496 | sc->debug.debugfs_debug = debugfs_create_file("debug", | ||
497 | S_IRUGO | S_IWUSR, sc->debug.debugfs_phy, sc, &fops_debug); | ||
498 | if (!sc->debug.debugfs_debug) | ||
499 | goto err; | ||
500 | |||
464 | sc->debug.debugfs_dma = debugfs_create_file("dma", S_IRUGO, | 501 | sc->debug.debugfs_dma = debugfs_create_file("dma", S_IRUGO, |
465 | sc->debug.debugfs_phy, sc, &fops_dma); | 502 | sc->debug.debugfs_phy, sc, &fops_dma); |
466 | if (!sc->debug.debugfs_dma) | 503 | if (!sc->debug.debugfs_dma) |
@@ -498,6 +535,7 @@ void ath9k_exit_debug(struct ath_softc *sc) | |||
498 | debugfs_remove(sc->debug.debugfs_rcstat); | 535 | debugfs_remove(sc->debug.debugfs_rcstat); |
499 | debugfs_remove(sc->debug.debugfs_interrupt); | 536 | debugfs_remove(sc->debug.debugfs_interrupt); |
500 | debugfs_remove(sc->debug.debugfs_dma); | 537 | debugfs_remove(sc->debug.debugfs_dma); |
538 | debugfs_remove(sc->debug.debugfs_debug); | ||
501 | debugfs_remove(sc->debug.debugfs_phy); | 539 | debugfs_remove(sc->debug.debugfs_phy); |
502 | } | 540 | } |
503 | 541 | ||