xref: /aosp_15_r20/external/kmod/testsuite/module-playground/mod-simple.c (revision cc4ad7da8cefe208cb129ac2aa9a357c7c72deb2)
1 #include <linux/debugfs.h>
2 #include <linux/init.h>
3 #include <linux/module.h>
4 
5 static struct dentry *debugfs_dir;
6 
test_show(struct seq_file * s,void * data)7 static int test_show(struct seq_file *s, void *data)
8 {
9 	seq_puts(s, "test");
10 	return 0;
11 }
12 
13 DEFINE_SHOW_ATTRIBUTE(test);
14 
test_module_init(void)15 static int __init test_module_init(void)
16 {
17 	debugfs_dir = debugfs_create_dir(KBUILD_MODNAME, NULL);
18 	debugfs_create_file("test", 0444, debugfs_dir, NULL, &test_fops);
19 
20 	return 0;
21 }
22 
test_module_exit(void)23 static void test_module_exit(void)
24 {
25 	debugfs_remove_recursive(debugfs_dir);
26 }
27 
28 module_init(test_module_init);
29 module_exit(test_module_exit);
30 
31 MODULE_AUTHOR("Lucas De Marchi <[email protected]>");
32 MODULE_LICENSE("GPL");
33