Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

wlcore: add debugfs macro to help print fw statistics arrays

Add a macro to make it easy to print arrays from the FW statistics
array in debugfs. At the same time, increase the buffer size so
arrays fit more easily.

Signed-off-by: Luciano Coelho <coelho@ti.com>
Signed-off-by: Arik Nemtsov <arik@wizery.com>

+27 -1
-1
drivers/net/wireless/ti/wlcore/debugfs.c
··· 39 39 #define WL1271_DEBUGFS_STATS_LIFETIME 1000 40 40 41 41 /* debugfs macros idea from mac80211 */ 42 - #define DEBUGFS_FORMAT_BUFFER_SIZE 100 43 42 int wl1271_format_buffer(char __user *userbuf, size_t count, 44 43 loff_t *ppos, char *fmt, ...) 45 44 {
+27
drivers/net/wireless/ti/wlcore/debugfs.h
··· 34 34 void wl1271_debugfs_reset(struct wl1271 *wl); 35 35 void wl1271_debugfs_update_stats(struct wl1271 *wl); 36 36 37 + #define DEBUGFS_FORMAT_BUFFER_SIZE 256 38 + 37 39 #define DEBUGFS_READONLY_FILE(name, fmt, value...) \ 38 40 static ssize_t name## _read(struct file *file, char __user *userbuf, \ 39 41 size_t count, loff_t *ppos) \ ··· 80 78 \ 81 79 return wl1271_format_buffer(userbuf, count, ppos, fmt "\n", \ 82 80 stats->sub.name); \ 81 + } \ 82 + \ 83 + static const struct file_operations sub## _ ##name## _ops = { \ 84 + .read = sub## _ ##name## _read, \ 85 + .open = simple_open, \ 86 + .llseek = generic_file_llseek, \ 87 + }; 88 + 89 + #define DEBUGFS_FWSTATS_FILE_ARRAY(sub, name, len, struct_type) \ 90 + static ssize_t sub## _ ##name## _read(struct file *file, \ 91 + char __user *userbuf, \ 92 + size_t count, loff_t *ppos) \ 93 + { \ 94 + struct wl1271 *wl = file->private_data; \ 95 + struct struct_type *stats = wl->stats.fw_stats; \ 96 + char buf[DEBUGFS_FORMAT_BUFFER_SIZE] = ""; \ 97 + int res, i; \ 98 + \ 99 + wl1271_debugfs_update_stats(wl); \ 100 + \ 101 + for (i = 0; i < len; i++) \ 102 + res = snprintf(buf, sizeof(buf), "%s[%d] = %d\n", \ 103 + buf, i, stats->sub.name[i]); \ 104 + \ 105 + return wl1271_format_buffer(userbuf, count, ppos, "%s", buf); \ 83 106 } \ 84 107 \ 85 108 static const struct file_operations sub## _ ##name## _ops = { \