1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */
2*4882a593Smuzhiyun
3*4882a593Smuzhiyun #ifndef __842_DEBUGFS_H__
4*4882a593Smuzhiyun #define __842_DEBUGFS_H__
5*4882a593Smuzhiyun
6*4882a593Smuzhiyun #include <linux/debugfs.h>
7*4882a593Smuzhiyun
8*4882a593Smuzhiyun static bool sw842_template_counts;
9*4882a593Smuzhiyun module_param_named(template_counts, sw842_template_counts, bool, 0444);
10*4882a593Smuzhiyun
11*4882a593Smuzhiyun static atomic_t template_count[OPS_MAX], template_repeat_count,
12*4882a593Smuzhiyun template_zeros_count, template_short_data_count, template_end_count;
13*4882a593Smuzhiyun
14*4882a593Smuzhiyun static struct dentry *sw842_debugfs_root;
15*4882a593Smuzhiyun
sw842_debugfs_create(void)16*4882a593Smuzhiyun static int __init sw842_debugfs_create(void)
17*4882a593Smuzhiyun {
18*4882a593Smuzhiyun umode_t m = S_IRUGO | S_IWUSR;
19*4882a593Smuzhiyun int i;
20*4882a593Smuzhiyun
21*4882a593Smuzhiyun if (!debugfs_initialized())
22*4882a593Smuzhiyun return -ENODEV;
23*4882a593Smuzhiyun
24*4882a593Smuzhiyun sw842_debugfs_root = debugfs_create_dir(MODULE_NAME, NULL);
25*4882a593Smuzhiyun
26*4882a593Smuzhiyun for (i = 0; i < ARRAY_SIZE(template_count); i++) {
27*4882a593Smuzhiyun char name[32];
28*4882a593Smuzhiyun
29*4882a593Smuzhiyun snprintf(name, 32, "template_%02x", i);
30*4882a593Smuzhiyun debugfs_create_atomic_t(name, m, sw842_debugfs_root,
31*4882a593Smuzhiyun &template_count[i]);
32*4882a593Smuzhiyun }
33*4882a593Smuzhiyun debugfs_create_atomic_t("template_repeat", m, sw842_debugfs_root,
34*4882a593Smuzhiyun &template_repeat_count);
35*4882a593Smuzhiyun debugfs_create_atomic_t("template_zeros", m, sw842_debugfs_root,
36*4882a593Smuzhiyun &template_zeros_count);
37*4882a593Smuzhiyun debugfs_create_atomic_t("template_short_data", m, sw842_debugfs_root,
38*4882a593Smuzhiyun &template_short_data_count);
39*4882a593Smuzhiyun debugfs_create_atomic_t("template_end", m, sw842_debugfs_root,
40*4882a593Smuzhiyun &template_end_count);
41*4882a593Smuzhiyun
42*4882a593Smuzhiyun return 0;
43*4882a593Smuzhiyun }
44*4882a593Smuzhiyun
sw842_debugfs_remove(void)45*4882a593Smuzhiyun static void __exit sw842_debugfs_remove(void)
46*4882a593Smuzhiyun {
47*4882a593Smuzhiyun debugfs_remove_recursive(sw842_debugfs_root);
48*4882a593Smuzhiyun }
49*4882a593Smuzhiyun
50*4882a593Smuzhiyun #endif
51