WIP FPC-III support
[linux/fpc-iii.git] / drivers / net / wireless / ti / wlcore / debugfs.h
blobb143293e694f92018d54b2602d49ff8eed0fc467
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3 * This file is part of wl1271
5 * Copyright (C) 2009 Nokia Corporation
7 * Contact: Luciano Coelho <luciano.coelho@nokia.com>
8 */
10 #ifndef __DEBUGFS_H__
11 #define __DEBUGFS_H__
13 #include "wlcore.h"
15 __printf(4, 5) int wl1271_format_buffer(char __user *userbuf, size_t count,
16 loff_t *ppos, char *fmt, ...);
18 int wl1271_debugfs_init(struct wl1271 *wl);
19 void wl1271_debugfs_exit(struct wl1271 *wl);
20 void wl1271_debugfs_reset(struct wl1271 *wl);
21 void wl1271_debugfs_update_stats(struct wl1271 *wl);
23 #define DEBUGFS_FORMAT_BUFFER_SIZE 256
25 #define DEBUGFS_READONLY_FILE(name, fmt, value...) \
26 static ssize_t name## _read(struct file *file, char __user *userbuf, \
27 size_t count, loff_t *ppos) \
28 { \
29 struct wl1271 *wl = file->private_data; \
30 return wl1271_format_buffer(userbuf, count, ppos, \
31 fmt "\n", ##value); \
32 } \
34 static const struct file_operations name## _ops = { \
35 .read = name## _read, \
36 .open = simple_open, \
37 .llseek = generic_file_llseek, \
40 #define DEBUGFS_ADD(name, parent) \
41 do { \
42 debugfs_create_file(#name, 0400, parent, \
43 wl, &name## _ops); \
44 } while (0)
47 #define DEBUGFS_ADD_PREFIX(prefix, name, parent) \
48 do { \
49 debugfs_create_file(#name, 0400, parent, \
50 wl, &prefix## _## name## _ops); \
51 } while (0)
53 #define DEBUGFS_FWSTATS_FILE(sub, name, fmt, struct_type) \
54 static ssize_t sub## _ ##name## _read(struct file *file, \
55 char __user *userbuf, \
56 size_t count, loff_t *ppos) \
57 { \
58 struct wl1271 *wl = file->private_data; \
59 struct struct_type *stats = wl->stats.fw_stats; \
61 wl1271_debugfs_update_stats(wl); \
63 return wl1271_format_buffer(userbuf, count, ppos, fmt "\n", \
64 stats->sub.name); \
65 } \
67 static const struct file_operations sub## _ ##name## _ops = { \
68 .read = sub## _ ##name## _read, \
69 .open = simple_open, \
70 .llseek = generic_file_llseek, \
73 #define DEBUGFS_FWSTATS_FILE_ARRAY(sub, name, len, struct_type) \
74 static ssize_t sub## _ ##name## _read(struct file *file, \
75 char __user *userbuf, \
76 size_t count, loff_t *ppos) \
77 { \
78 struct wl1271 *wl = file->private_data; \
79 struct struct_type *stats = wl->stats.fw_stats; \
80 char buf[DEBUGFS_FORMAT_BUFFER_SIZE] = ""; \
81 int i; \
83 wl1271_debugfs_update_stats(wl); \
85 for (i = 0; i < len; i++) \
86 snprintf(buf, sizeof(buf), "%s[%d] = %d\n", \
87 buf, i, stats->sub.name[i]); \
89 return wl1271_format_buffer(userbuf, count, ppos, "%s", buf); \
90 } \
92 static const struct file_operations sub## _ ##name## _ops = { \
93 .read = sub## _ ##name## _read, \
94 .open = simple_open, \
95 .llseek = generic_file_llseek, \
98 #define DEBUGFS_FWSTATS_ADD(sub, name) \
99 DEBUGFS_ADD(sub## _ ##name, stats)
102 #endif /* WL1271_DEBUGFS_H */