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