2 * debug.c - ACPI debug interface to userspace.
5 #include <linux/proc_fs.h>
6 #include <linux/init.h>
7 #include <asm/uaccess.h>
8 #include <acpi/acpi_drivers.h>
10 #define _COMPONENT ACPI_SYSTEM_COMPONENT
11 ACPI_MODULE_NAME ("debug")
13 #define ACPI_SYSTEM_FILE_DEBUG_LAYER "debug_layer"
14 #define ACPI_SYSTEM_FILE_DEBUG_LEVEL "debug_level"
17 acpi_system_read_debug (
31 switch ((unsigned long) data) {
33 p += sprintf(p, "0x%08x\n", acpi_dbg_layer);
36 p += sprintf(p, "0x%08x\n", acpi_dbg_level);
39 p += sprintf(p, "Invalid debug option\n");
45 if (size <= off+count) *eof = 1;
48 if (size>count) size = count;
56 acpi_system_write_debug (
62 char debug_string[12] = {'\0'};
64 ACPI_FUNCTION_TRACE("acpi_system_write_debug");
66 if (count > sizeof(debug_string) - 1)
67 return_VALUE(-EINVAL);
69 if (copy_from_user(debug_string, buffer, count))
70 return_VALUE(-EFAULT);
72 debug_string[count] = '\0';
74 switch ((unsigned long) data) {
76 acpi_dbg_layer = simple_strtoul(debug_string, NULL, 0);
79 acpi_dbg_level = simple_strtoul(debug_string, NULL, 0);
82 return_VALUE(-EINVAL);
88 static int __init acpi_debug_init(void)
90 struct proc_dir_entry *entry;
94 ACPI_FUNCTION_TRACE("acpi_debug_init");
99 /* 'debug_layer' [R/W] */
100 name = ACPI_SYSTEM_FILE_DEBUG_LAYER;
101 entry = create_proc_read_entry(name, S_IFREG|S_IRUGO|S_IWUSR, acpi_root_dir,
102 acpi_system_read_debug,(void *)0);
104 entry->write_proc = acpi_system_write_debug;
108 /* 'debug_level' [R/W] */
109 name = ACPI_SYSTEM_FILE_DEBUG_LEVEL;
110 entry = create_proc_read_entry(name, S_IFREG|S_IRUGO|S_IWUSR, acpi_root_dir,
111 acpi_system_read_debug, (void *)1);
113 entry->write_proc = acpi_system_write_debug;
121 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
122 "Unable to create '%s' proc fs entry\n", name));
124 remove_proc_entry(ACPI_SYSTEM_FILE_DEBUG_LEVEL, acpi_root_dir);
125 remove_proc_entry(ACPI_SYSTEM_FILE_DEBUG_LAYER, acpi_root_dir);
130 subsys_initcall(acpi_debug_init);