842_debugfs.h 1.3 KB

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