2 * debugfs.c - ACPI debugfs interface to userspace.
5 #include <linux/init.h>
6 #include <linux/module.h>
7 #include <linux/kernel.h>
8 #include <linux/uaccess.h>
9 #include <linux/debugfs.h>
10 #include <acpi/acpi_drivers.h>
12 #define _COMPONENT ACPI_SYSTEM_COMPONENT
13 ACPI_MODULE_NAME("debugfs");
15 struct dentry
*acpi_debugfs_dir
;
16 static struct dentry
*cm_dentry
;
18 /* /sys/kernel/debug/acpi/custom_method */
20 static ssize_t
cm_write(struct file
*file
, const char __user
* user_buf
,
21 size_t count
, loff_t
*ppos
)
25 static u32 uncopied_bytes
;
27 struct acpi_table_header table
;
31 /* parse the table header to get the table length */
32 if (count
<= sizeof(struct acpi_table_header
))
34 if (copy_from_user(&table
, user_buf
,
35 sizeof(struct acpi_table_header
)))
37 uncopied_bytes
= max_size
= table
.length
;
38 buf
= kzalloc(max_size
, GFP_KERNEL
);
46 if ((*ppos
> max_size
) ||
47 (*ppos
+ count
> max_size
) ||
48 (*ppos
+ count
< count
) ||
49 (count
> uncopied_bytes
))
52 if (copy_from_user(buf
+ (*ppos
), user_buf
, count
)) {
58 uncopied_bytes
-= count
;
61 if (!uncopied_bytes
) {
62 status
= acpi_install_method(buf
);
65 if (ACPI_FAILURE(status
))
67 add_taint(TAINT_OVERRIDDEN_ACPI_TABLE
);
73 static const struct file_operations cm_fops
= {
75 .llseek
= default_llseek
,
78 static int __init
acpi_custom_method_init(void)
80 if (!acpi_debugfs_dir
)
83 cm_dentry
= debugfs_create_file("custom_method", S_IWUSR
,
84 acpi_debugfs_dir
, NULL
, &cm_fops
);
91 void __init
acpi_debugfs_init(void)
93 acpi_debugfs_dir
= debugfs_create_dir("acpi", NULL
);
95 acpi_custom_method_init();