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