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");
16 /* /sys/modules/acpi/parameters/aml_debug_output */
18 module_param_named(aml_debug_output, acpi_gbl_enable_aml_debug_object,
20 MODULE_PARM_DESC(aml_debug_output,
21 "To enable/disable the ACPI Debug Object output.");
23 /* /sys/kernel/debug/acpi/custom_method */
25 static ssize_t cm_write(struct file *file, const char __user * user_buf,
26 size_t count, loff_t *ppos)
30 static u32 uncopied_bytes;
32 struct acpi_table_header table;
36 /* parse the table header to get the table length */
37 if (count <= sizeof(struct acpi_table_header))
39 if (copy_from_user(&table, user_buf,
40 sizeof(struct acpi_table_header)))
42 uncopied_bytes = max_size = table.length;
43 buf = kzalloc(max_size, GFP_KERNEL);
51 if ((*ppos > max_size) ||
52 (*ppos + count > max_size) ||
53 (*ppos + count < count) ||
54 (count > uncopied_bytes))
57 if (copy_from_user(buf + (*ppos), user_buf, count)) {
63 uncopied_bytes -= count;
66 if (!uncopied_bytes) {
67 status = acpi_install_method(buf);
70 if (ACPI_FAILURE(status))
72 add_taint(TAINT_OVERRIDDEN_ACPI_TABLE);
78 static const struct file_operations cm_fops = {
80 .llseek = default_llseek,
83 int __init acpi_debugfs_init(void)
85 struct dentry *acpi_dir, *cm_dentry;
87 acpi_dir = debugfs_create_dir("acpi", NULL);
91 cm_dentry = debugfs_create_file("custom_method", S_IWUSR,
92 acpi_dir, NULL, &cm_fops);
100 debugfs_remove(acpi_dir);