2 * This file is part of wl1271
4 * Copyright (C) 2009 Nokia Corporation
6 * Contact: Luciano Coelho <luciano.coelho@nokia.com>
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * version 2 as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
29 int wl1271_format_buffer(char __user
*userbuf
, size_t count
,
30 loff_t
*ppos
, char *fmt
, ...);
32 int wl1271_debugfs_init(struct wl1271
*wl
);
33 void wl1271_debugfs_exit(struct wl1271
*wl
);
34 void wl1271_debugfs_reset(struct wl1271
*wl
);
35 void wl1271_debugfs_update_stats(struct wl1271
*wl
);
37 #define DEBUGFS_FORMAT_BUFFER_SIZE 256
39 #define DEBUGFS_READONLY_FILE(name, fmt, value...) \
40 static ssize_t name## _read(struct file *file, char __user *userbuf, \
41 size_t count, loff_t *ppos) \
43 struct wl1271 *wl = file->private_data; \
44 return wl1271_format_buffer(userbuf, count, ppos, \
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) \
56 entry = debugfs_create_file(#name, 0400, parent, \
58 if (!entry || IS_ERR(entry)) \
63 #define DEBUGFS_ADD_PREFIX(prefix, name, parent) \
65 entry = debugfs_create_file(#name, 0400, parent, \
66 wl, &prefix## _## name## _ops); \
67 if (!entry || IS_ERR(entry)) \
71 #define DEBUGFS_FWSTATS_FILE(sub, name, fmt, struct_type) \
72 static ssize_t sub## _ ##name## _read(struct file *file, \
73 char __user *userbuf, \
74 size_t count, loff_t *ppos) \
76 struct wl1271 *wl = file->private_data; \
77 struct struct_type *stats = wl->stats.fw_stats; \
79 wl1271_debugfs_update_stats(wl); \
81 return wl1271_format_buffer(userbuf, count, ppos, fmt "\n", \
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_FILE_ARRAY(sub, name, len, struct_type) \
92 static ssize_t sub## _ ##name## _read(struct file *file, \
93 char __user *userbuf, \
94 size_t count, loff_t *ppos) \
96 struct wl1271 *wl = file->private_data; \
97 struct struct_type *stats = wl->stats.fw_stats; \
98 char buf[DEBUGFS_FORMAT_BUFFER_SIZE] = ""; \
101 wl1271_debugfs_update_stats(wl); \
103 for (i = 0; i < len; i++) \
104 res = snprintf(buf, sizeof(buf), "%s[%d] = %d\n", \
105 buf, i, stats->sub.name[i]); \
107 return wl1271_format_buffer(userbuf, count, ppos, "%s", buf); \
110 static const struct file_operations sub## _ ##name## _ops = { \
111 .read = sub## _ ##name## _read, \
112 .open = simple_open, \
113 .llseek = generic_file_llseek, \
116 #define DEBUGFS_FWSTATS_ADD(sub, name) \
117 DEBUGFS_ADD(sub## _ ##name, stats)
120 #endif /* WL1271_DEBUGFS_H */