wl12xx: add debugfs entries for dtim_interval and beacon_interval
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / drivers / net / wireless / wl12xx / debugfs.c
blob88c6efe33ecc80394b5c114e726586770d1878eb
1 /*
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
20 * 02110-1301 USA
24 #include "debugfs.h"
26 #include <linux/skbuff.h>
27 #include <linux/slab.h>
29 #include "wl12xx.h"
30 #include "acx.h"
31 #include "ps.h"
32 #include "io.h"
34 /* ms */
35 #define WL1271_DEBUGFS_STATS_LIFETIME 1000
37 /* debugfs macros idea from mac80211 */
38 #define DEBUGFS_FORMAT_BUFFER_SIZE 100
39 static int wl1271_format_buffer(char __user *userbuf, size_t count,
40 loff_t *ppos, char *fmt, ...)
42 va_list args;
43 char buf[DEBUGFS_FORMAT_BUFFER_SIZE];
44 int res;
46 va_start(args, fmt);
47 res = vscnprintf(buf, sizeof(buf), fmt, args);
48 va_end(args);
50 return simple_read_from_buffer(userbuf, count, ppos, buf, res);
53 #define DEBUGFS_READONLY_FILE(name, fmt, value...) \
54 static ssize_t name## _read(struct file *file, char __user *userbuf, \
55 size_t count, loff_t *ppos) \
56 { \
57 struct wl1271 *wl = file->private_data; \
58 return wl1271_format_buffer(userbuf, count, ppos, \
59 fmt "\n", ##value); \
60 } \
62 static const struct file_operations name## _ops = { \
63 .read = name## _read, \
64 .open = wl1271_open_file_generic, \
65 .llseek = generic_file_llseek, \
68 #define DEBUGFS_ADD(name, parent) \
69 entry = debugfs_create_file(#name, 0400, parent, \
70 wl, &name## _ops); \
71 if (!entry || IS_ERR(entry)) \
72 goto err; \
74 #define DEBUGFS_FWSTATS_FILE(sub, name, fmt) \
75 static ssize_t sub## _ ##name## _read(struct file *file, \
76 char __user *userbuf, \
77 size_t count, loff_t *ppos) \
78 { \
79 struct wl1271 *wl = file->private_data; \
81 wl1271_debugfs_update_stats(wl); \
83 return wl1271_format_buffer(userbuf, count, ppos, fmt "\n", \
84 wl->stats.fw_stats->sub.name); \
85 } \
87 static const struct file_operations sub## _ ##name## _ops = { \
88 .read = sub## _ ##name## _read, \
89 .open = wl1271_open_file_generic, \
90 .llseek = generic_file_llseek, \
93 #define DEBUGFS_FWSTATS_ADD(sub, name) \
94 DEBUGFS_ADD(sub## _ ##name, stats)
96 static void wl1271_debugfs_update_stats(struct wl1271 *wl)
98 int ret;
100 mutex_lock(&wl->mutex);
102 ret = wl1271_ps_elp_wakeup(wl);
103 if (ret < 0)
104 goto out;
106 if (wl->state == WL1271_STATE_ON &&
107 time_after(jiffies, wl->stats.fw_stats_update +
108 msecs_to_jiffies(WL1271_DEBUGFS_STATS_LIFETIME))) {
109 wl1271_acx_statistics(wl, wl->stats.fw_stats);
110 wl->stats.fw_stats_update = jiffies;
113 wl1271_ps_elp_sleep(wl);
115 out:
116 mutex_unlock(&wl->mutex);
119 static int wl1271_open_file_generic(struct inode *inode, struct file *file)
121 file->private_data = inode->i_private;
122 return 0;
125 DEBUGFS_FWSTATS_FILE(tx, internal_desc_overflow, "%u");
127 DEBUGFS_FWSTATS_FILE(rx, out_of_mem, "%u");
128 DEBUGFS_FWSTATS_FILE(rx, hdr_overflow, "%u");
129 DEBUGFS_FWSTATS_FILE(rx, hw_stuck, "%u");
130 DEBUGFS_FWSTATS_FILE(rx, dropped, "%u");
131 DEBUGFS_FWSTATS_FILE(rx, fcs_err, "%u");
132 DEBUGFS_FWSTATS_FILE(rx, xfr_hint_trig, "%u");
133 DEBUGFS_FWSTATS_FILE(rx, path_reset, "%u");
134 DEBUGFS_FWSTATS_FILE(rx, reset_counter, "%u");
136 DEBUGFS_FWSTATS_FILE(dma, rx_requested, "%u");
137 DEBUGFS_FWSTATS_FILE(dma, rx_errors, "%u");
138 DEBUGFS_FWSTATS_FILE(dma, tx_requested, "%u");
139 DEBUGFS_FWSTATS_FILE(dma, tx_errors, "%u");
141 DEBUGFS_FWSTATS_FILE(isr, cmd_cmplt, "%u");
142 DEBUGFS_FWSTATS_FILE(isr, fiqs, "%u");
143 DEBUGFS_FWSTATS_FILE(isr, rx_headers, "%u");
144 DEBUGFS_FWSTATS_FILE(isr, rx_mem_overflow, "%u");
145 DEBUGFS_FWSTATS_FILE(isr, rx_rdys, "%u");
146 DEBUGFS_FWSTATS_FILE(isr, irqs, "%u");
147 DEBUGFS_FWSTATS_FILE(isr, tx_procs, "%u");
148 DEBUGFS_FWSTATS_FILE(isr, decrypt_done, "%u");
149 DEBUGFS_FWSTATS_FILE(isr, dma0_done, "%u");
150 DEBUGFS_FWSTATS_FILE(isr, dma1_done, "%u");
151 DEBUGFS_FWSTATS_FILE(isr, tx_exch_complete, "%u");
152 DEBUGFS_FWSTATS_FILE(isr, commands, "%u");
153 DEBUGFS_FWSTATS_FILE(isr, rx_procs, "%u");
154 DEBUGFS_FWSTATS_FILE(isr, hw_pm_mode_changes, "%u");
155 DEBUGFS_FWSTATS_FILE(isr, host_acknowledges, "%u");
156 DEBUGFS_FWSTATS_FILE(isr, pci_pm, "%u");
157 DEBUGFS_FWSTATS_FILE(isr, wakeups, "%u");
158 DEBUGFS_FWSTATS_FILE(isr, low_rssi, "%u");
160 DEBUGFS_FWSTATS_FILE(wep, addr_key_count, "%u");
161 DEBUGFS_FWSTATS_FILE(wep, default_key_count, "%u");
162 /* skipping wep.reserved */
163 DEBUGFS_FWSTATS_FILE(wep, key_not_found, "%u");
164 DEBUGFS_FWSTATS_FILE(wep, decrypt_fail, "%u");
165 DEBUGFS_FWSTATS_FILE(wep, packets, "%u");
166 DEBUGFS_FWSTATS_FILE(wep, interrupt, "%u");
168 DEBUGFS_FWSTATS_FILE(pwr, ps_enter, "%u");
169 DEBUGFS_FWSTATS_FILE(pwr, elp_enter, "%u");
170 DEBUGFS_FWSTATS_FILE(pwr, missing_bcns, "%u");
171 DEBUGFS_FWSTATS_FILE(pwr, wake_on_host, "%u");
172 DEBUGFS_FWSTATS_FILE(pwr, wake_on_timer_exp, "%u");
173 DEBUGFS_FWSTATS_FILE(pwr, tx_with_ps, "%u");
174 DEBUGFS_FWSTATS_FILE(pwr, tx_without_ps, "%u");
175 DEBUGFS_FWSTATS_FILE(pwr, rcvd_beacons, "%u");
176 DEBUGFS_FWSTATS_FILE(pwr, power_save_off, "%u");
177 DEBUGFS_FWSTATS_FILE(pwr, enable_ps, "%u");
178 DEBUGFS_FWSTATS_FILE(pwr, disable_ps, "%u");
179 DEBUGFS_FWSTATS_FILE(pwr, fix_tsf_ps, "%u");
180 /* skipping cont_miss_bcns_spread for now */
181 DEBUGFS_FWSTATS_FILE(pwr, rcvd_awake_beacons, "%u");
183 DEBUGFS_FWSTATS_FILE(mic, rx_pkts, "%u");
184 DEBUGFS_FWSTATS_FILE(mic, calc_failure, "%u");
186 DEBUGFS_FWSTATS_FILE(aes, encrypt_fail, "%u");
187 DEBUGFS_FWSTATS_FILE(aes, decrypt_fail, "%u");
188 DEBUGFS_FWSTATS_FILE(aes, encrypt_packets, "%u");
189 DEBUGFS_FWSTATS_FILE(aes, decrypt_packets, "%u");
190 DEBUGFS_FWSTATS_FILE(aes, encrypt_interrupt, "%u");
191 DEBUGFS_FWSTATS_FILE(aes, decrypt_interrupt, "%u");
193 DEBUGFS_FWSTATS_FILE(event, heart_beat, "%u");
194 DEBUGFS_FWSTATS_FILE(event, calibration, "%u");
195 DEBUGFS_FWSTATS_FILE(event, rx_mismatch, "%u");
196 DEBUGFS_FWSTATS_FILE(event, rx_mem_empty, "%u");
197 DEBUGFS_FWSTATS_FILE(event, rx_pool, "%u");
198 DEBUGFS_FWSTATS_FILE(event, oom_late, "%u");
199 DEBUGFS_FWSTATS_FILE(event, phy_transmit_error, "%u");
200 DEBUGFS_FWSTATS_FILE(event, tx_stuck, "%u");
202 DEBUGFS_FWSTATS_FILE(ps, pspoll_timeouts, "%u");
203 DEBUGFS_FWSTATS_FILE(ps, upsd_timeouts, "%u");
204 DEBUGFS_FWSTATS_FILE(ps, upsd_max_sptime, "%u");
205 DEBUGFS_FWSTATS_FILE(ps, upsd_max_apturn, "%u");
206 DEBUGFS_FWSTATS_FILE(ps, pspoll_max_apturn, "%u");
207 DEBUGFS_FWSTATS_FILE(ps, pspoll_utilization, "%u");
208 DEBUGFS_FWSTATS_FILE(ps, upsd_utilization, "%u");
210 DEBUGFS_FWSTATS_FILE(rxpipe, rx_prep_beacon_drop, "%u");
211 DEBUGFS_FWSTATS_FILE(rxpipe, descr_host_int_trig_rx_data, "%u");
212 DEBUGFS_FWSTATS_FILE(rxpipe, beacon_buffer_thres_host_int_trig_rx_data, "%u");
213 DEBUGFS_FWSTATS_FILE(rxpipe, missed_beacon_host_int_trig_rx_data, "%u");
214 DEBUGFS_FWSTATS_FILE(rxpipe, tx_xfr_host_int_trig_rx_data, "%u");
216 DEBUGFS_READONLY_FILE(retry_count, "%u", wl->stats.retry_count);
217 DEBUGFS_READONLY_FILE(excessive_retries, "%u",
218 wl->stats.excessive_retries);
220 static ssize_t tx_queue_len_read(struct file *file, char __user *userbuf,
221 size_t count, loff_t *ppos)
223 struct wl1271 *wl = file->private_data;
224 u32 queue_len;
225 char buf[20];
226 int res;
228 queue_len = wl->tx_queue_count;
230 res = scnprintf(buf, sizeof(buf), "%u\n", queue_len);
231 return simple_read_from_buffer(userbuf, count, ppos, buf, res);
234 static const struct file_operations tx_queue_len_ops = {
235 .read = tx_queue_len_read,
236 .open = wl1271_open_file_generic,
237 .llseek = default_llseek,
240 static ssize_t gpio_power_read(struct file *file, char __user *user_buf,
241 size_t count, loff_t *ppos)
243 struct wl1271 *wl = file->private_data;
244 bool state = test_bit(WL1271_FLAG_GPIO_POWER, &wl->flags);
246 int res;
247 char buf[10];
249 res = scnprintf(buf, sizeof(buf), "%d\n", state);
251 return simple_read_from_buffer(user_buf, count, ppos, buf, res);
254 static ssize_t gpio_power_write(struct file *file,
255 const char __user *user_buf,
256 size_t count, loff_t *ppos)
258 struct wl1271 *wl = file->private_data;
259 char buf[10];
260 size_t len;
261 unsigned long value;
262 int ret;
264 len = min(count, sizeof(buf) - 1);
265 if (copy_from_user(buf, user_buf, len)) {
266 return -EFAULT;
268 buf[len] = '\0';
270 ret = kstrtoul(buf, 0, &value);
271 if (ret < 0) {
272 wl1271_warning("illegal value in gpio_power");
273 return -EINVAL;
276 mutex_lock(&wl->mutex);
278 if (value)
279 wl1271_power_on(wl);
280 else
281 wl1271_power_off(wl);
283 mutex_unlock(&wl->mutex);
284 return count;
287 static const struct file_operations gpio_power_ops = {
288 .read = gpio_power_read,
289 .write = gpio_power_write,
290 .open = wl1271_open_file_generic,
291 .llseek = default_llseek,
294 static ssize_t dtim_interval_read(struct file *file, char __user *user_buf,
295 size_t count, loff_t *ppos)
297 struct wl1271 *wl = file->private_data;
298 u8 value;
300 if (wl->conf.conn.wake_up_event == CONF_WAKE_UP_EVENT_DTIM ||
301 wl->conf.conn.wake_up_event == CONF_WAKE_UP_EVENT_N_DTIM)
302 value = wl->conf.conn.listen_interval;
303 else
304 value = 0;
306 return wl1271_format_buffer(user_buf, count, ppos, "%d\n", value);
309 static ssize_t dtim_interval_write(struct file *file,
310 const char __user *user_buf,
311 size_t count, loff_t *ppos)
313 struct wl1271 *wl = file->private_data;
314 char buf[10];
315 size_t len;
316 unsigned long value;
317 int ret;
319 len = min(count, sizeof(buf) - 1);
320 if (copy_from_user(buf, user_buf, len))
321 return -EFAULT;
322 buf[len] = '\0';
324 ret = strict_strtoul(buf, 0, &value);
325 if (ret < 0) {
326 wl1271_warning("illegal value for dtim_interval");
327 return -EINVAL;
330 if (value < 1 || value > 10) {
331 wl1271_warning("dtim value is not in valid range");
332 return -ERANGE;
335 mutex_lock(&wl->mutex);
337 wl->conf.conn.listen_interval = value;
338 /* for some reason there are different event types for 1 and >1 */
339 if (value == 1)
340 wl->conf.conn.wake_up_event = CONF_WAKE_UP_EVENT_DTIM;
341 else
342 wl->conf.conn.wake_up_event = CONF_WAKE_UP_EVENT_N_DTIM;
345 * we don't reconfigure ACX_WAKE_UP_CONDITIONS now, so it will only
346 * take effect on the next time we enter psm.
348 mutex_unlock(&wl->mutex);
349 return count;
352 static const struct file_operations dtim_interval_ops = {
353 .read = dtim_interval_read,
354 .write = dtim_interval_write,
355 .open = wl1271_open_file_generic,
356 .llseek = default_llseek,
359 static ssize_t beacon_interval_read(struct file *file, char __user *user_buf,
360 size_t count, loff_t *ppos)
362 struct wl1271 *wl = file->private_data;
363 u8 value;
365 if (wl->conf.conn.wake_up_event == CONF_WAKE_UP_EVENT_BEACON ||
366 wl->conf.conn.wake_up_event == CONF_WAKE_UP_EVENT_N_BEACONS)
367 value = wl->conf.conn.listen_interval;
368 else
369 value = 0;
371 return wl1271_format_buffer(user_buf, count, ppos, "%d\n", value);
374 static ssize_t beacon_interval_write(struct file *file,
375 const char __user *user_buf,
376 size_t count, loff_t *ppos)
378 struct wl1271 *wl = file->private_data;
379 char buf[10];
380 size_t len;
381 unsigned long value;
382 int ret;
384 len = min(count, sizeof(buf) - 1);
385 if (copy_from_user(buf, user_buf, len))
386 return -EFAULT;
387 buf[len] = '\0';
389 ret = strict_strtoul(buf, 0, &value);
390 if (ret < 0) {
391 wl1271_warning("illegal value for beacon_interval");
392 return -EINVAL;
395 if (value < 1 || value > 255) {
396 wl1271_warning("beacon interval value is not in valid range");
397 return -ERANGE;
400 mutex_lock(&wl->mutex);
402 wl->conf.conn.listen_interval = value;
403 /* for some reason there are different event types for 1 and >1 */
404 if (value == 1)
405 wl->conf.conn.wake_up_event = CONF_WAKE_UP_EVENT_BEACON;
406 else
407 wl->conf.conn.wake_up_event = CONF_WAKE_UP_EVENT_N_BEACONS;
410 * we don't reconfigure ACX_WAKE_UP_CONDITIONS now, so it will only
411 * take effect on the next time we enter psm.
413 mutex_unlock(&wl->mutex);
414 return count;
417 static const struct file_operations beacon_interval_ops = {
418 .read = beacon_interval_read,
419 .write = beacon_interval_write,
420 .open = wl1271_open_file_generic,
421 .llseek = default_llseek,
424 static int wl1271_debugfs_add_files(struct wl1271 *wl,
425 struct dentry *rootdir)
427 int ret = 0;
428 struct dentry *entry, *stats;
430 stats = debugfs_create_dir("fw-statistics", rootdir);
431 if (!stats || IS_ERR(stats)) {
432 entry = stats;
433 goto err;
436 DEBUGFS_FWSTATS_ADD(tx, internal_desc_overflow);
438 DEBUGFS_FWSTATS_ADD(rx, out_of_mem);
439 DEBUGFS_FWSTATS_ADD(rx, hdr_overflow);
440 DEBUGFS_FWSTATS_ADD(rx, hw_stuck);
441 DEBUGFS_FWSTATS_ADD(rx, dropped);
442 DEBUGFS_FWSTATS_ADD(rx, fcs_err);
443 DEBUGFS_FWSTATS_ADD(rx, xfr_hint_trig);
444 DEBUGFS_FWSTATS_ADD(rx, path_reset);
445 DEBUGFS_FWSTATS_ADD(rx, reset_counter);
447 DEBUGFS_FWSTATS_ADD(dma, rx_requested);
448 DEBUGFS_FWSTATS_ADD(dma, rx_errors);
449 DEBUGFS_FWSTATS_ADD(dma, tx_requested);
450 DEBUGFS_FWSTATS_ADD(dma, tx_errors);
452 DEBUGFS_FWSTATS_ADD(isr, cmd_cmplt);
453 DEBUGFS_FWSTATS_ADD(isr, fiqs);
454 DEBUGFS_FWSTATS_ADD(isr, rx_headers);
455 DEBUGFS_FWSTATS_ADD(isr, rx_mem_overflow);
456 DEBUGFS_FWSTATS_ADD(isr, rx_rdys);
457 DEBUGFS_FWSTATS_ADD(isr, irqs);
458 DEBUGFS_FWSTATS_ADD(isr, tx_procs);
459 DEBUGFS_FWSTATS_ADD(isr, decrypt_done);
460 DEBUGFS_FWSTATS_ADD(isr, dma0_done);
461 DEBUGFS_FWSTATS_ADD(isr, dma1_done);
462 DEBUGFS_FWSTATS_ADD(isr, tx_exch_complete);
463 DEBUGFS_FWSTATS_ADD(isr, commands);
464 DEBUGFS_FWSTATS_ADD(isr, rx_procs);
465 DEBUGFS_FWSTATS_ADD(isr, hw_pm_mode_changes);
466 DEBUGFS_FWSTATS_ADD(isr, host_acknowledges);
467 DEBUGFS_FWSTATS_ADD(isr, pci_pm);
468 DEBUGFS_FWSTATS_ADD(isr, wakeups);
469 DEBUGFS_FWSTATS_ADD(isr, low_rssi);
471 DEBUGFS_FWSTATS_ADD(wep, addr_key_count);
472 DEBUGFS_FWSTATS_ADD(wep, default_key_count);
473 /* skipping wep.reserved */
474 DEBUGFS_FWSTATS_ADD(wep, key_not_found);
475 DEBUGFS_FWSTATS_ADD(wep, decrypt_fail);
476 DEBUGFS_FWSTATS_ADD(wep, packets);
477 DEBUGFS_FWSTATS_ADD(wep, interrupt);
479 DEBUGFS_FWSTATS_ADD(pwr, ps_enter);
480 DEBUGFS_FWSTATS_ADD(pwr, elp_enter);
481 DEBUGFS_FWSTATS_ADD(pwr, missing_bcns);
482 DEBUGFS_FWSTATS_ADD(pwr, wake_on_host);
483 DEBUGFS_FWSTATS_ADD(pwr, wake_on_timer_exp);
484 DEBUGFS_FWSTATS_ADD(pwr, tx_with_ps);
485 DEBUGFS_FWSTATS_ADD(pwr, tx_without_ps);
486 DEBUGFS_FWSTATS_ADD(pwr, rcvd_beacons);
487 DEBUGFS_FWSTATS_ADD(pwr, power_save_off);
488 DEBUGFS_FWSTATS_ADD(pwr, enable_ps);
489 DEBUGFS_FWSTATS_ADD(pwr, disable_ps);
490 DEBUGFS_FWSTATS_ADD(pwr, fix_tsf_ps);
491 /* skipping cont_miss_bcns_spread for now */
492 DEBUGFS_FWSTATS_ADD(pwr, rcvd_awake_beacons);
494 DEBUGFS_FWSTATS_ADD(mic, rx_pkts);
495 DEBUGFS_FWSTATS_ADD(mic, calc_failure);
497 DEBUGFS_FWSTATS_ADD(aes, encrypt_fail);
498 DEBUGFS_FWSTATS_ADD(aes, decrypt_fail);
499 DEBUGFS_FWSTATS_ADD(aes, encrypt_packets);
500 DEBUGFS_FWSTATS_ADD(aes, decrypt_packets);
501 DEBUGFS_FWSTATS_ADD(aes, encrypt_interrupt);
502 DEBUGFS_FWSTATS_ADD(aes, decrypt_interrupt);
504 DEBUGFS_FWSTATS_ADD(event, heart_beat);
505 DEBUGFS_FWSTATS_ADD(event, calibration);
506 DEBUGFS_FWSTATS_ADD(event, rx_mismatch);
507 DEBUGFS_FWSTATS_ADD(event, rx_mem_empty);
508 DEBUGFS_FWSTATS_ADD(event, rx_pool);
509 DEBUGFS_FWSTATS_ADD(event, oom_late);
510 DEBUGFS_FWSTATS_ADD(event, phy_transmit_error);
511 DEBUGFS_FWSTATS_ADD(event, tx_stuck);
513 DEBUGFS_FWSTATS_ADD(ps, pspoll_timeouts);
514 DEBUGFS_FWSTATS_ADD(ps, upsd_timeouts);
515 DEBUGFS_FWSTATS_ADD(ps, upsd_max_sptime);
516 DEBUGFS_FWSTATS_ADD(ps, upsd_max_apturn);
517 DEBUGFS_FWSTATS_ADD(ps, pspoll_max_apturn);
518 DEBUGFS_FWSTATS_ADD(ps, pspoll_utilization);
519 DEBUGFS_FWSTATS_ADD(ps, upsd_utilization);
521 DEBUGFS_FWSTATS_ADD(rxpipe, rx_prep_beacon_drop);
522 DEBUGFS_FWSTATS_ADD(rxpipe, descr_host_int_trig_rx_data);
523 DEBUGFS_FWSTATS_ADD(rxpipe, beacon_buffer_thres_host_int_trig_rx_data);
524 DEBUGFS_FWSTATS_ADD(rxpipe, missed_beacon_host_int_trig_rx_data);
525 DEBUGFS_FWSTATS_ADD(rxpipe, tx_xfr_host_int_trig_rx_data);
527 DEBUGFS_ADD(tx_queue_len, rootdir);
528 DEBUGFS_ADD(retry_count, rootdir);
529 DEBUGFS_ADD(excessive_retries, rootdir);
531 DEBUGFS_ADD(gpio_power, rootdir);
532 DEBUGFS_ADD(dtim_interval, rootdir);
533 DEBUGFS_ADD(beacon_interval, rootdir);
535 return 0;
537 err:
538 if (IS_ERR(entry))
539 ret = PTR_ERR(entry);
540 else
541 ret = -ENOMEM;
543 return ret;
546 void wl1271_debugfs_reset(struct wl1271 *wl)
548 if (!wl->stats.fw_stats)
549 return;
551 memset(wl->stats.fw_stats, 0, sizeof(*wl->stats.fw_stats));
552 wl->stats.retry_count = 0;
553 wl->stats.excessive_retries = 0;
556 int wl1271_debugfs_init(struct wl1271 *wl)
558 int ret;
559 struct dentry *rootdir;
561 rootdir = debugfs_create_dir(KBUILD_MODNAME,
562 wl->hw->wiphy->debugfsdir);
564 if (IS_ERR(rootdir)) {
565 ret = PTR_ERR(rootdir);
566 goto err;
569 wl->stats.fw_stats = kzalloc(sizeof(*wl->stats.fw_stats),
570 GFP_KERNEL);
572 if (!wl->stats.fw_stats) {
573 ret = -ENOMEM;
574 goto err_fw;
577 wl->stats.fw_stats_update = jiffies;
579 ret = wl1271_debugfs_add_files(wl, rootdir);
581 if (ret < 0)
582 goto err_file;
584 return 0;
586 err_file:
587 kfree(wl->stats.fw_stats);
588 wl->stats.fw_stats = NULL;
590 err_fw:
591 debugfs_remove_recursive(rootdir);
593 err:
594 return ret;
597 void wl1271_debugfs_exit(struct wl1271 *wl)
599 kfree(wl->stats.fw_stats);
600 wl->stats.fw_stats = NULL;