Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 
0003 #ifndef __842_DEBUGFS_H__
0004 #define __842_DEBUGFS_H__
0005 
0006 #include <linux/debugfs.h>
0007 
0008 static bool sw842_template_counts;
0009 module_param_named(template_counts, sw842_template_counts, bool, 0444);
0010 
0011 static atomic_t template_count[OPS_MAX], template_repeat_count,
0012     template_zeros_count, template_short_data_count, template_end_count;
0013 
0014 static struct dentry *sw842_debugfs_root;
0015 
0016 static int __init sw842_debugfs_create(void)
0017 {
0018     umode_t m = S_IRUGO | S_IWUSR;
0019     int i;
0020 
0021     if (!debugfs_initialized())
0022         return -ENODEV;
0023 
0024     sw842_debugfs_root = debugfs_create_dir(MODULE_NAME, NULL);
0025 
0026     for (i = 0; i < ARRAY_SIZE(template_count); i++) {
0027         char name[32];
0028 
0029         snprintf(name, 32, "template_%02x", i);
0030         debugfs_create_atomic_t(name, m, sw842_debugfs_root,
0031                     &template_count[i]);
0032     }
0033     debugfs_create_atomic_t("template_repeat", m, sw842_debugfs_root,
0034                 &template_repeat_count);
0035     debugfs_create_atomic_t("template_zeros", m, sw842_debugfs_root,
0036                 &template_zeros_count);
0037     debugfs_create_atomic_t("template_short_data", m, sw842_debugfs_root,
0038                 &template_short_data_count);
0039     debugfs_create_atomic_t("template_end", m, sw842_debugfs_root,
0040                 &template_end_count);
0041 
0042     return 0;
0043 }
0044 
0045 static void __exit sw842_debugfs_remove(void)
0046 {
0047     debugfs_remove_recursive(sw842_debugfs_root);
0048 }
0049 
0050 #endif