aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/ath9k/debug.c
diff options
context:
space:
mode:
authorAlina Friedrichsen <x-alina@gmx.net>2009-01-22 23:44:21 -0500
committerJohn W. Linville <linville@tuxdriver.com>2009-01-29 16:01:22 -0500
commit27abe060aa9d3410545ef663676c7183fc2512c6 (patch)
tree33dc2e0c3e783a0446e92436540c69a87778b48e /drivers/net/wireless/ath9k/debug.c
parent8cab7581dba90b0519e25784e08feb5dedde737f (diff)
ath9k: Read and write the TSF via debugfs
This patch adds an ath9k specific entry to read, write and reset the TSF into the debugfs, like in ath5k. This makes debugging the IBSS handling of wifi drivers _much_ easier. Signed-off-by: Alina Friedrichsen <x-alina@gmx.net> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/ath9k/debug.c')
-rw-r--r--drivers/net/wireless/ath9k/debug.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/drivers/net/wireless/ath9k/debug.c b/drivers/net/wireless/ath9k/debug.c
index a80ed576830f..05e1f82cc7a1 100644
--- a/drivers/net/wireless/ath9k/debug.c
+++ b/drivers/net/wireless/ath9k/debug.c
@@ -222,6 +222,49 @@ static const struct file_operations fops_interrupt = {
222 .owner = THIS_MODULE 222 .owner = THIS_MODULE
223}; 223};
224 224
225
226static ssize_t read_file_tsf(struct file *file, char __user *user_buf,
227 size_t count, loff_t *ppos)
228{
229 struct ath_softc *sc = file->private_data;
230 char buf[100];
231 snprintf(buf, sizeof(buf), "0x%016llx\n",
232 (unsigned long long)ath9k_hw_gettsf64(sc->sc_ah));
233 return simple_read_from_buffer(user_buf, count, ppos, buf, 19);
234}
235
236static ssize_t write_file_tsf(struct file *file,
237 const char __user *user_buf,
238 size_t count, loff_t *ppos)
239{
240 struct ath_softc *sc = file->private_data;
241 char buf[21];
242 unsigned long long tsf;
243
244 if (copy_from_user(buf, user_buf, min(count, sizeof(buf) - 1)))
245 return -EFAULT;
246 buf[sizeof(buf) - 1] = '\0';
247
248 if (strncmp(buf, "reset", 5) == 0) {
249 ath9k_hw_reset_tsf(sc->sc_ah);
250 printk(KERN_INFO "debugfs reset TSF\n");
251 } else {
252 tsf = simple_strtoul(buf, NULL, 0);
253 ath9k_hw_settsf64(sc->sc_ah, tsf);
254 printk(KERN_INFO "debugfs set TSF to %#018llx\n", tsf);
255 }
256
257 return count;
258}
259
260static const struct file_operations fops_tsf = {
261 .read = read_file_tsf,
262 .write = write_file_tsf,
263 .open = ath9k_debugfs_open,
264 .owner = THIS_MODULE
265};
266
267
225int ath9k_init_debug(struct ath_softc *sc) 268int ath9k_init_debug(struct ath_softc *sc)
226{ 269{
227 sc->sc_debug.debug_mask = ath9k_debug; 270 sc->sc_debug.debug_mask = ath9k_debug;
@@ -247,6 +290,11 @@ int ath9k_init_debug(struct ath_softc *sc)
247 if (!sc->sc_debug.debugfs_interrupt) 290 if (!sc->sc_debug.debugfs_interrupt)
248 goto err; 291 goto err;
249 292
293 sc->sc_debug.debugfs_tsf = debugfs_create_file("tsf", S_IRUGO,
294 sc->sc_debug.debugfs_phy, sc, &fops_tsf);
295 if (!sc->sc_debug.debugfs_tsf)
296 goto err;
297
250 return 0; 298 return 0;
251err: 299err:
252 ath9k_exit_debug(sc); 300 ath9k_exit_debug(sc);
@@ -255,6 +303,7 @@ err:
255 303
256void ath9k_exit_debug(struct ath_softc *sc) 304void ath9k_exit_debug(struct ath_softc *sc)
257{ 305{
306 debugfs_remove(sc->sc_debug.debugfs_tsf);
258 debugfs_remove(sc->sc_debug.debugfs_interrupt); 307 debugfs_remove(sc->sc_debug.debugfs_interrupt);
259 debugfs_remove(sc->sc_debug.debugfs_dma); 308 debugfs_remove(sc->sc_debug.debugfs_dma);
260 debugfs_remove(sc->sc_debug.debugfs_phy); 309 debugfs_remove(sc->sc_debug.debugfs_phy);