Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

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