diff options
author | Alexey Dobriyan <adobriyan@sw.ru> | 2008-04-29 04:01:46 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-04-29 11:06:19 -0400 |
commit | 647634df400ed26e2707ef65a8bf0df3f3bb8663 (patch) | |
tree | a733669df7afea2e0c87e02abafb8443ebd162ad /drivers/char/apm-emulation.c | |
parent | 8331438b38b07b97dbbb9049aa90a0d6ce5da03b (diff) |
proc: switch /proc/apm to seq_file interface
Signed-off-by: Alexey Dobriyan <adobriyan@sw.ru>
Cc: Rafael J. Wysocki <rjw@sisk.pl>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Len Brown <len.brown@intel.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/char/apm-emulation.c')
-rw-r--r-- | drivers/char/apm-emulation.c | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/drivers/char/apm-emulation.c b/drivers/char/apm-emulation.c index 17d54315e146..cdd876dbb2b0 100644 --- a/drivers/char/apm-emulation.c +++ b/drivers/char/apm-emulation.c | |||
@@ -14,6 +14,7 @@ | |||
14 | #include <linux/poll.h> | 14 | #include <linux/poll.h> |
15 | #include <linux/slab.h> | 15 | #include <linux/slab.h> |
16 | #include <linux/proc_fs.h> | 16 | #include <linux/proc_fs.h> |
17 | #include <linux/seq_file.h> | ||
17 | #include <linux/miscdevice.h> | 18 | #include <linux/miscdevice.h> |
18 | #include <linux/apm_bios.h> | 19 | #include <linux/apm_bios.h> |
19 | #include <linux/capability.h> | 20 | #include <linux/capability.h> |
@@ -493,11 +494,10 @@ static struct miscdevice apm_device = { | |||
493 | * -1: Unknown | 494 | * -1: Unknown |
494 | * 8) min = minutes; sec = seconds | 495 | * 8) min = minutes; sec = seconds |
495 | */ | 496 | */ |
496 | static int apm_get_info(char *buf, char **start, off_t fpos, int length) | 497 | static int proc_apm_show(struct seq_file *m, void *v) |
497 | { | 498 | { |
498 | struct apm_power_info info; | 499 | struct apm_power_info info; |
499 | char *units; | 500 | char *units; |
500 | int ret; | ||
501 | 501 | ||
502 | info.ac_line_status = 0xff; | 502 | info.ac_line_status = 0xff; |
503 | info.battery_status = 0xff; | 503 | info.battery_status = 0xff; |
@@ -515,14 +515,27 @@ static int apm_get_info(char *buf, char **start, off_t fpos, int length) | |||
515 | case 1: units = "sec"; break; | 515 | case 1: units = "sec"; break; |
516 | } | 516 | } |
517 | 517 | ||
518 | ret = sprintf(buf, "%s 1.2 0x%02x 0x%02x 0x%02x 0x%02x %d%% %d %s\n", | 518 | seq_printf(m, "%s 1.2 0x%02x 0x%02x 0x%02x 0x%02x %d%% %d %s\n", |
519 | driver_version, APM_32_BIT_SUPPORT, | 519 | driver_version, APM_32_BIT_SUPPORT, |
520 | info.ac_line_status, info.battery_status, | 520 | info.ac_line_status, info.battery_status, |
521 | info.battery_flag, info.battery_life, | 521 | info.battery_flag, info.battery_life, |
522 | info.time, units); | 522 | info.time, units); |
523 | 523 | ||
524 | return ret; | 524 | return 0; |
525 | } | 525 | } |
526 | |||
527 | static int proc_apm_open(struct inode *inode, struct file *file) | ||
528 | { | ||
529 | return single_open(file, proc_apm_show, NULL); | ||
530 | } | ||
531 | |||
532 | static const struct file_operations apm_proc_fops = { | ||
533 | .owner = THIS_MODULE, | ||
534 | .open = proc_apm_open, | ||
535 | .read = seq_read, | ||
536 | .llseek = seq_lseek, | ||
537 | .release = single_release, | ||
538 | }; | ||
526 | #endif | 539 | #endif |
527 | 540 | ||
528 | static int kapmd(void *arg) | 541 | static int kapmd(void *arg) |
@@ -593,7 +606,7 @@ static int __init apm_init(void) | |||
593 | wake_up_process(kapmd_tsk); | 606 | wake_up_process(kapmd_tsk); |
594 | 607 | ||
595 | #ifdef CONFIG_PROC_FS | 608 | #ifdef CONFIG_PROC_FS |
596 | create_proc_info_entry("apm", 0, NULL, apm_get_info); | 609 | proc_create("apm", 0, NULL, &apm_proc_fops); |
597 | #endif | 610 | #endif |
598 | 611 | ||
599 | ret = misc_register(&apm_device); | 612 | ret = misc_register(&apm_device); |