25 #include <linux/slab.h>
32 #define WL1251_DEBUGFS_STATS_LIFETIME 1000
36 #define DEBUGFS_READONLY_FILE(name, buflen, fmt, value...) \
37 static ssize_t name## _read(struct file *file, char __user *userbuf, \
38 size_t count, loff_t *ppos) \
40 struct wl1251 *wl = file->private_data; \
44 res = scnprintf(buf, buflen, fmt "\n", ##value); \
45 return simple_read_from_buffer(userbuf, count, ppos, buf, res); \
48 static const struct file_operations name## _ops = { \
49 .read = name## _read, \
50 .open = simple_open, \
51 .llseek = generic_file_llseek, \
54 #define DEBUGFS_ADD(name, parent) \
55 wl->debugfs.name = debugfs_create_file(#name, 0400, parent, \
57 if (IS_ERR(wl->debugfs.name)) { \
58 ret = PTR_ERR(wl->debugfs.name); \
59 wl->debugfs.name = NULL; \
63 #define DEBUGFS_DEL(name) \
65 debugfs_remove(wl->debugfs.name); \
66 wl->debugfs.name = NULL; \
69 #define DEBUGFS_FWSTATS_FILE(sub, name, buflen, fmt) \
70 static ssize_t sub## _ ##name## _read(struct file *file, \
71 char __user *userbuf, \
72 size_t count, loff_t *ppos) \
74 struct wl1251 *wl = file->private_data; \
78 wl1251_debugfs_update_stats(wl); \
80 res = scnprintf(buf, buflen, fmt "\n", \
81 wl->stats.fw_stats->sub.name); \
82 return simple_read_from_buffer(userbuf, count, ppos, buf, res); \
85 static const struct file_operations sub## _ ##name## _ops = { \
86 .read = sub## _ ##name## _read, \
87 .open = simple_open, \
88 .llseek = generic_file_llseek, \
91 #define DEBUGFS_FWSTATS_ADD(sub, name) \
92 DEBUGFS_ADD(sub## _ ##name, wl->debugfs.fw_statistics)
94 #define DEBUGFS_FWSTATS_DEL(sub, name) \
95 DEBUGFS_DEL(sub## _ ##name)
97 static void wl1251_debugfs_update_stats(
struct wl1251 *wl)
214 wl->stats.excessive_retries);
216 static ssize_t tx_queue_len_read(
struct file *
file,
char __user *userbuf,
217 size_t count, loff_t *ppos)
224 queue_len = skb_queue_len(&wl->
tx_queue);
226 res =
scnprintf(buf,
sizeof(buf),
"%u\n", queue_len);
231 .read = tx_queue_len_read,
236 static ssize_t tx_queue_status_read(
struct file *file,
char __user *userbuf,
237 size_t count, loff_t *ppos)
248 len =
scnprintf(buf,
sizeof(buf),
"%c\n", status);
253 .read = tx_queue_status_read,
258 static void wl1251_debugfs_delete_files(
struct wl1251 *wl)
357 static int wl1251_debugfs_add_files(
struct wl1251 *wl)
459 wl1251_debugfs_delete_files(wl);
468 wl->
stats.retry_count = 0;
469 wl->
stats.excessive_retries = 0;
478 if (IS_ERR(wl->
debugfs.rootdir)) {
479 ret = PTR_ERR(wl->
debugfs.rootdir);
487 if (IS_ERR(wl->
debugfs.fw_statistics)) {
488 ret = PTR_ERR(wl->
debugfs.fw_statistics);
493 wl->
stats.fw_stats = kzalloc(
sizeof(*wl->
stats.fw_stats),
496 if (!wl->
stats.fw_stats) {
503 ret = wl1251_debugfs_add_files(wl);
528 wl1251_debugfs_delete_files(wl);