Commit 7d7decb2 authored by Alexey Dobriyan's avatar Alexey Dobriyan Committed by Len Brown

acpi: switch /proc/acpi/{debug_layer,debug_level} to seq_file

Signed-off-by: default avatarAlexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLen Brown <len.brown@intel.com>
parent 09729f0b
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
*/ */
#include <linux/proc_fs.h> #include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/kernel.h> #include <linux/kernel.h>
...@@ -201,72 +202,54 @@ module_param_call(trace_state, param_set_trace_state, param_get_trace_state, ...@@ -201,72 +202,54 @@ module_param_call(trace_state, param_set_trace_state, param_get_trace_state,
#define ACPI_SYSTEM_FILE_DEBUG_LAYER "debug_layer" #define ACPI_SYSTEM_FILE_DEBUG_LAYER "debug_layer"
#define ACPI_SYSTEM_FILE_DEBUG_LEVEL "debug_level" #define ACPI_SYSTEM_FILE_DEBUG_LEVEL "debug_level"
static int static int acpi_system_debug_proc_show(struct seq_file *m, void *v)
acpi_system_read_debug(char *page,
char **start, off_t off, int count, int *eof, void *data)
{ {
char *p = page;
int size = 0;
unsigned int i; unsigned int i;
if (off != 0) seq_printf(m, "%-25s\tHex SET\n", "Description");
goto end;
p += sprintf(p, "%-25s\tHex SET\n", "Description"); switch ((unsigned long)m->private) {
switch ((unsigned long)data) {
case 0: case 0:
for (i = 0; i < ARRAY_SIZE(acpi_debug_layers); i++) { for (i = 0; i < ARRAY_SIZE(acpi_debug_layers); i++) {
p += sprintf(p, "%-25s\t0x%08lX [%c]\n", seq_printf(m, "%-25s\t0x%08lX [%c]\n",
acpi_debug_layers[i].name, acpi_debug_layers[i].name,
acpi_debug_layers[i].value, acpi_debug_layers[i].value,
(acpi_dbg_layer & acpi_debug_layers[i]. (acpi_dbg_layer & acpi_debug_layers[i].
value) ? '*' : ' '); value) ? '*' : ' ');
} }
p += sprintf(p, "%-25s\t0x%08X [%c]\n", "ACPI_ALL_DRIVERS", seq_printf(m, "%-25s\t0x%08X [%c]\n", "ACPI_ALL_DRIVERS",
ACPI_ALL_DRIVERS, ACPI_ALL_DRIVERS,
(acpi_dbg_layer & ACPI_ALL_DRIVERS) == (acpi_dbg_layer & ACPI_ALL_DRIVERS) ==
ACPI_ALL_DRIVERS ? '*' : (acpi_dbg_layer & ACPI_ALL_DRIVERS ? '*' : (acpi_dbg_layer &
ACPI_ALL_DRIVERS) == ACPI_ALL_DRIVERS) ==
0 ? ' ' : '-'); 0 ? ' ' : '-');
p += sprintf(p, seq_printf(m,
"--\ndebug_layer = 0x%08X (* = enabled, - = partial)\n", "--\ndebug_layer = 0x%08X (* = enabled, - = partial)\n",
acpi_dbg_layer); acpi_dbg_layer);
break; break;
case 1: case 1:
for (i = 0; i < ARRAY_SIZE(acpi_debug_levels); i++) { for (i = 0; i < ARRAY_SIZE(acpi_debug_levels); i++) {
p += sprintf(p, "%-25s\t0x%08lX [%c]\n", seq_printf(m, "%-25s\t0x%08lX [%c]\n",
acpi_debug_levels[i].name, acpi_debug_levels[i].name,
acpi_debug_levels[i].value, acpi_debug_levels[i].value,
(acpi_dbg_level & acpi_debug_levels[i]. (acpi_dbg_level & acpi_debug_levels[i].
value) ? '*' : ' '); value) ? '*' : ' ');
} }
p += sprintf(p, "--\ndebug_level = 0x%08X (* = enabled)\n", seq_printf(m, "--\ndebug_level = 0x%08X (* = enabled)\n",
acpi_dbg_level); acpi_dbg_level);
break; break;
default:
p += sprintf(p, "Invalid debug option\n");
break;
} }
return 0;
}
end: static int acpi_system_debug_proc_open(struct inode *inode, struct file *file)
size = (p - page); {
if (size <= off + count) return single_open(file, acpi_system_debug_proc_show, PDE(inode)->data);
*eof = 1;
*start = page + off;
size -= off;
if (size > count)
size = count;
if (size < 0)
size = 0;
return size;
} }
static int static ssize_t acpi_system_debug_proc_write(struct file *file,
acpi_system_write_debug(struct file *file,
const char __user * buffer, const char __user * buffer,
unsigned long count, void *data) size_t count, loff_t *pos)
{ {
char debug_string[12] = { '\0' }; char debug_string[12] = { '\0' };
...@@ -279,7 +262,7 @@ acpi_system_write_debug(struct file *file, ...@@ -279,7 +262,7 @@ acpi_system_write_debug(struct file *file,
debug_string[count] = '\0'; debug_string[count] = '\0';
switch ((unsigned long)data) { switch ((unsigned long)PDE(file->f_path.dentry->d_inode)->data) {
case 0: case 0:
acpi_dbg_layer = simple_strtoul(debug_string, NULL, 0); acpi_dbg_layer = simple_strtoul(debug_string, NULL, 0);
break; break;
...@@ -292,6 +275,15 @@ acpi_system_write_debug(struct file *file, ...@@ -292,6 +275,15 @@ acpi_system_write_debug(struct file *file,
return count; return count;
} }
static const struct file_operations acpi_system_debug_proc_fops = {
.owner = THIS_MODULE,
.open = acpi_system_debug_proc_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
.write = acpi_system_debug_proc_write,
};
#endif #endif
int __init acpi_debug_init(void) int __init acpi_debug_init(void)
...@@ -303,24 +295,18 @@ int __init acpi_debug_init(void) ...@@ -303,24 +295,18 @@ int __init acpi_debug_init(void)
/* 'debug_layer' [R/W] */ /* 'debug_layer' [R/W] */
name = ACPI_SYSTEM_FILE_DEBUG_LAYER; name = ACPI_SYSTEM_FILE_DEBUG_LAYER;
entry = entry = proc_create_data(name, S_IFREG | S_IRUGO | S_IWUSR,
create_proc_read_entry(name, S_IFREG | S_IRUGO | S_IWUSR, acpi_root_dir, &acpi_system_debug_proc_fops,
acpi_root_dir, acpi_system_read_debug,
(void *)0); (void *)0);
if (entry) if (!entry)
entry->write_proc = acpi_system_write_debug;
else
goto Error; goto Error;
/* 'debug_level' [R/W] */ /* 'debug_level' [R/W] */
name = ACPI_SYSTEM_FILE_DEBUG_LEVEL; name = ACPI_SYSTEM_FILE_DEBUG_LEVEL;
entry = entry = proc_create_data(name, S_IFREG | S_IRUGO | S_IWUSR,
create_proc_read_entry(name, S_IFREG | S_IRUGO | S_IWUSR, acpi_root_dir, &acpi_system_debug_proc_fops,
acpi_root_dir, acpi_system_read_debug,
(void *)1); (void *)1);
if (entry) if (!entry)
entry->write_proc = acpi_system_write_debug;
else
goto Error; goto Error;
Done: Done:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment