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>
14
#define _COMPONENT ACPI_SYSTEM_COMPONENT
15
ACPI_MODULE_NAME("custom_method");
16
MODULE_LICENSE("GPL");
18
static struct dentry *cm_dentry;
20
/* /sys/kernel/debug/acpi/custom_method */
22
static ssize_t cm_write(struct file *file, const char __user * user_buf,
23
size_t count, loff_t *ppos)
27
static u32 uncopied_bytes;
29
struct acpi_table_header table;
33
/* parse the table header to get the table length */
34
if (count <= sizeof(struct acpi_table_header))
36
if (copy_from_user(&table, user_buf,
37
sizeof(struct acpi_table_header)))
39
uncopied_bytes = max_size = table.length;
40
buf = kzalloc(max_size, GFP_KERNEL);
48
if ((*ppos > max_size) ||
49
(*ppos + count > max_size) ||
50
(*ppos + count < count) ||
51
(count > uncopied_bytes))
54
if (copy_from_user(buf + (*ppos), user_buf, count)) {
60
uncopied_bytes -= count;
63
if (!uncopied_bytes) {
64
status = acpi_install_method(buf);
67
if (ACPI_FAILURE(status))
69
add_taint(TAINT_OVERRIDDEN_ACPI_TABLE);
75
static const struct file_operations cm_fops = {
77
.llseek = default_llseek,
80
static int __init acpi_custom_method_init(void)
82
if (acpi_debugfs_dir == NULL)
85
cm_dentry = debugfs_create_file("custom_method", S_IWUSR,
86
acpi_debugfs_dir, NULL, &cm_fops);
87
if (cm_dentry == NULL)
93
static void __exit acpi_custom_method_exit(void)
96
debugfs_remove(cm_dentry);
99
module_init(acpi_custom_method_init);
100
module_exit(acpi_custom_method_exit);