diff options
author | Alexey Dobriyan <adobriyan@gmail.com> | 2009-09-18 15:41:08 -0400 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2009-09-19 01:38:57 -0400 |
commit | 7d7decb213a65dea0973ed980c02dae2b1b88dbe (patch) | |
tree | 70867823b6438e44a8dbab65690660fe6846c18c /drivers/acpi/debug.c | |
parent | 09729f0b11a389e046f621f3e4841043f460b603 (diff) |
acpi: switch /proc/acpi/{debug_layer,debug_level} to seq_file
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi/debug.c')
-rw-r--r-- | drivers/acpi/debug.c | 82 |
1 files changed, 34 insertions, 48 deletions
diff --git a/drivers/acpi/debug.c b/drivers/acpi/debug.c index a8287be0870e..8a690c3b8e23 100644 --- a/drivers/acpi/debug.c +++ b/drivers/acpi/debug.c | |||
@@ -3,6 +3,7 @@ | |||
3 | */ | 3 | */ |
4 | 4 | ||
5 | #include <linux/proc_fs.h> | 5 | #include <linux/proc_fs.h> |
6 | #include <linux/seq_file.h> | ||
6 | #include <linux/init.h> | 7 | #include <linux/init.h> |
7 | #include <linux/module.h> | 8 | #include <linux/module.h> |
8 | #include <linux/kernel.h> | 9 | #include <linux/kernel.h> |
@@ -201,72 +202,54 @@ module_param_call(trace_state, param_set_trace_state, param_get_trace_state, | |||
201 | #define ACPI_SYSTEM_FILE_DEBUG_LAYER "debug_layer" | 202 | #define ACPI_SYSTEM_FILE_DEBUG_LAYER "debug_layer" |
202 | #define ACPI_SYSTEM_FILE_DEBUG_LEVEL "debug_level" | 203 | #define ACPI_SYSTEM_FILE_DEBUG_LEVEL "debug_level" |
203 | 204 | ||
204 | static int | 205 | static int acpi_system_debug_proc_show(struct seq_file *m, void *v) |
205 | acpi_system_read_debug(char *page, | ||
206 | char **start, off_t off, int count, int *eof, void *data) | ||
207 | { | 206 | { |
208 | char *p = page; | ||
209 | int size = 0; | ||
210 | unsigned int i; | 207 | unsigned int i; |
211 | 208 | ||
212 | if (off != 0) | 209 | seq_printf(m, "%-25s\tHex SET\n", "Description"); |
213 | goto end; | ||
214 | 210 | ||
215 | p += sprintf(p, "%-25s\tHex SET\n", "Description"); | 211 | switch ((unsigned long)m->private) { |
216 | |||
217 | switch ((unsigned long)data) { | ||
218 | case 0: | 212 | case 0: |
219 | for (i = 0; i < ARRAY_SIZE(acpi_debug_layers); i++) { | 213 | for (i = 0; i < ARRAY_SIZE(acpi_debug_layers); i++) { |
220 | p += sprintf(p, "%-25s\t0x%08lX [%c]\n", | 214 | seq_printf(m, "%-25s\t0x%08lX [%c]\n", |
221 | acpi_debug_layers[i].name, | 215 | acpi_debug_layers[i].name, |
222 | acpi_debug_layers[i].value, | 216 | acpi_debug_layers[i].value, |
223 | (acpi_dbg_layer & acpi_debug_layers[i]. | 217 | (acpi_dbg_layer & acpi_debug_layers[i]. |
224 | value) ? '*' : ' '); | 218 | value) ? '*' : ' '); |
225 | } | 219 | } |
226 | p += sprintf(p, "%-25s\t0x%08X [%c]\n", "ACPI_ALL_DRIVERS", | 220 | seq_printf(m, "%-25s\t0x%08X [%c]\n", "ACPI_ALL_DRIVERS", |
227 | ACPI_ALL_DRIVERS, | 221 | ACPI_ALL_DRIVERS, |
228 | (acpi_dbg_layer & ACPI_ALL_DRIVERS) == | 222 | (acpi_dbg_layer & ACPI_ALL_DRIVERS) == |
229 | ACPI_ALL_DRIVERS ? '*' : (acpi_dbg_layer & | 223 | ACPI_ALL_DRIVERS ? '*' : (acpi_dbg_layer & |
230 | ACPI_ALL_DRIVERS) == | 224 | ACPI_ALL_DRIVERS) == |
231 | 0 ? ' ' : '-'); | 225 | 0 ? ' ' : '-'); |
232 | p += sprintf(p, | 226 | seq_printf(m, |
233 | "--\ndebug_layer = 0x%08X (* = enabled, - = partial)\n", | 227 | "--\ndebug_layer = 0x%08X (* = enabled, - = partial)\n", |
234 | acpi_dbg_layer); | 228 | acpi_dbg_layer); |
235 | break; | 229 | break; |
236 | case 1: | 230 | case 1: |
237 | for (i = 0; i < ARRAY_SIZE(acpi_debug_levels); i++) { | 231 | for (i = 0; i < ARRAY_SIZE(acpi_debug_levels); i++) { |
238 | p += sprintf(p, "%-25s\t0x%08lX [%c]\n", | 232 | seq_printf(m, "%-25s\t0x%08lX [%c]\n", |
239 | acpi_debug_levels[i].name, | 233 | acpi_debug_levels[i].name, |
240 | acpi_debug_levels[i].value, | 234 | acpi_debug_levels[i].value, |
241 | (acpi_dbg_level & acpi_debug_levels[i]. | 235 | (acpi_dbg_level & acpi_debug_levels[i]. |
242 | value) ? '*' : ' '); | 236 | value) ? '*' : ' '); |
243 | } | 237 | } |
244 | p += sprintf(p, "--\ndebug_level = 0x%08X (* = enabled)\n", | 238 | seq_printf(m, "--\ndebug_level = 0x%08X (* = enabled)\n", |
245 | acpi_dbg_level); | 239 | acpi_dbg_level); |
246 | break; | 240 | break; |
247 | default: | ||
248 | p += sprintf(p, "Invalid debug option\n"); | ||
249 | break; | ||
250 | } | 241 | } |
242 | return 0; | ||
243 | } | ||
251 | 244 | ||
252 | end: | 245 | static int acpi_system_debug_proc_open(struct inode *inode, struct file *file) |
253 | size = (p - page); | 246 | { |
254 | if (size <= off + count) | 247 | return single_open(file, acpi_system_debug_proc_show, PDE(inode)->data); |
255 | *eof = 1; | ||
256 | *start = page + off; | ||
257 | size -= off; | ||
258 | if (size > count) | ||
259 | size = count; | ||
260 | if (size < 0) | ||
261 | size = 0; | ||
262 | |||
263 | return size; | ||
264 | } | 248 | } |
265 | 249 | ||
266 | static int | 250 | static ssize_t acpi_system_debug_proc_write(struct file *file, |
267 | acpi_system_write_debug(struct file *file, | ||
268 | const char __user * buffer, | 251 | const char __user * buffer, |
269 | unsigned long count, void *data) | 252 | size_t count, loff_t *pos) |
270 | { | 253 | { |
271 | char debug_string[12] = { '\0' }; | 254 | char debug_string[12] = { '\0' }; |
272 | 255 | ||
@@ -279,7 +262,7 @@ acpi_system_write_debug(struct file *file, | |||
279 | 262 | ||
280 | debug_string[count] = '\0'; | 263 | debug_string[count] = '\0'; |
281 | 264 | ||
282 | switch ((unsigned long)data) { | 265 | switch ((unsigned long)PDE(file->f_path.dentry->d_inode)->data) { |
283 | case 0: | 266 | case 0: |
284 | acpi_dbg_layer = simple_strtoul(debug_string, NULL, 0); | 267 | acpi_dbg_layer = simple_strtoul(debug_string, NULL, 0); |
285 | break; | 268 | break; |
@@ -292,6 +275,15 @@ acpi_system_write_debug(struct file *file, | |||
292 | 275 | ||
293 | return count; | 276 | return count; |
294 | } | 277 | } |
278 | |||
279 | static const struct file_operations acpi_system_debug_proc_fops = { | ||
280 | .owner = THIS_MODULE, | ||
281 | .open = acpi_system_debug_proc_open, | ||
282 | .read = seq_read, | ||
283 | .llseek = seq_lseek, | ||
284 | .release = single_release, | ||
285 | .write = acpi_system_debug_proc_write, | ||
286 | }; | ||
295 | #endif | 287 | #endif |
296 | 288 | ||
297 | int __init acpi_debug_init(void) | 289 | int __init acpi_debug_init(void) |
@@ -303,24 +295,18 @@ int __init acpi_debug_init(void) | |||
303 | 295 | ||
304 | /* 'debug_layer' [R/W] */ | 296 | /* 'debug_layer' [R/W] */ |
305 | name = ACPI_SYSTEM_FILE_DEBUG_LAYER; | 297 | name = ACPI_SYSTEM_FILE_DEBUG_LAYER; |
306 | entry = | 298 | entry = proc_create_data(name, S_IFREG | S_IRUGO | S_IWUSR, |
307 | create_proc_read_entry(name, S_IFREG | S_IRUGO | S_IWUSR, | 299 | acpi_root_dir, &acpi_system_debug_proc_fops, |
308 | acpi_root_dir, acpi_system_read_debug, | 300 | (void *)0); |
309 | (void *)0); | 301 | if (!entry) |
310 | if (entry) | ||
311 | entry->write_proc = acpi_system_write_debug; | ||
312 | else | ||
313 | goto Error; | 302 | goto Error; |
314 | 303 | ||
315 | /* 'debug_level' [R/W] */ | 304 | /* 'debug_level' [R/W] */ |
316 | name = ACPI_SYSTEM_FILE_DEBUG_LEVEL; | 305 | name = ACPI_SYSTEM_FILE_DEBUG_LEVEL; |
317 | entry = | 306 | entry = proc_create_data(name, S_IFREG | S_IRUGO | S_IWUSR, |
318 | create_proc_read_entry(name, S_IFREG | S_IRUGO | S_IWUSR, | 307 | acpi_root_dir, &acpi_system_debug_proc_fops, |
319 | acpi_root_dir, acpi_system_read_debug, | 308 | (void *)1); |
320 | (void *)1); | 309 | if (!entry) |
321 | if (entry) | ||
322 | entry->write_proc = acpi_system_write_debug; | ||
323 | else | ||
324 | goto Error; | 310 | goto Error; |
325 | 311 | ||
326 | Done: | 312 | Done: |