diff options
author | Alexey Dobriyan <adobriyan@gmail.com> | 2007-02-13 07:26:23 -0500 |
---|---|---|
committer | Andi Kleen <andi@basil.nowhere.org> | 2007-02-13 07:26:23 -0500 |
commit | 016d6f35803667ffbe3e7bba8b58a6b611fac998 (patch) | |
tree | d8d0d5fb40539015a2fe8021b886f2c6c597fb4b /arch/i386 | |
parent | b0957f1a3a7687bfaf5b0bfe402b50985ea2f06b (diff) |
[PATCH] i386: Convert /proc/apm to seqfile
Byte-to-byte identical /proc/apm here.
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Andi Kleen <ak@suse.de>
Diffstat (limited to 'arch/i386')
-rw-r--r-- | arch/i386/kernel/apm.c | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/arch/i386/kernel/apm.c b/arch/i386/kernel/apm.c index db99a8948dae..f9ba0af7ee1f 100644 --- a/arch/i386/kernel/apm.c +++ b/arch/i386/kernel/apm.c | |||
@@ -211,6 +211,7 @@ | |||
211 | #include <linux/slab.h> | 211 | #include <linux/slab.h> |
212 | #include <linux/stat.h> | 212 | #include <linux/stat.h> |
213 | #include <linux/proc_fs.h> | 213 | #include <linux/proc_fs.h> |
214 | #include <linux/seq_file.h> | ||
214 | #include <linux/miscdevice.h> | 215 | #include <linux/miscdevice.h> |
215 | #include <linux/apm_bios.h> | 216 | #include <linux/apm_bios.h> |
216 | #include <linux/init.h> | 217 | #include <linux/init.h> |
@@ -1636,9 +1637,8 @@ static int do_open(struct inode * inode, struct file * filp) | |||
1636 | return 0; | 1637 | return 0; |
1637 | } | 1638 | } |
1638 | 1639 | ||
1639 | static int apm_get_info(char *buf, char **start, off_t fpos, int length) | 1640 | static int proc_apm_show(struct seq_file *m, void *v) |
1640 | { | 1641 | { |
1641 | char * p; | ||
1642 | unsigned short bx; | 1642 | unsigned short bx; |
1643 | unsigned short cx; | 1643 | unsigned short cx; |
1644 | unsigned short dx; | 1644 | unsigned short dx; |
@@ -1650,8 +1650,6 @@ static int apm_get_info(char *buf, char **start, off_t fpos, int length) | |||
1650 | int time_units = -1; | 1650 | int time_units = -1; |
1651 | char *units = "?"; | 1651 | char *units = "?"; |
1652 | 1652 | ||
1653 | p = buf; | ||
1654 | |||
1655 | if ((num_online_cpus() == 1) && | 1653 | if ((num_online_cpus() == 1) && |
1656 | !(error = apm_get_power_status(&bx, &cx, &dx))) { | 1654 | !(error = apm_get_power_status(&bx, &cx, &dx))) { |
1657 | ac_line_status = (bx >> 8) & 0xff; | 1655 | ac_line_status = (bx >> 8) & 0xff; |
@@ -1705,7 +1703,7 @@ static int apm_get_info(char *buf, char **start, off_t fpos, int length) | |||
1705 | -1: Unknown | 1703 | -1: Unknown |
1706 | 8) min = minutes; sec = seconds */ | 1704 | 8) min = minutes; sec = seconds */ |
1707 | 1705 | ||
1708 | p += sprintf(p, "%s %d.%d 0x%02x 0x%02x 0x%02x 0x%02x %d%% %d %s\n", | 1706 | seq_printf(m, "%s %d.%d 0x%02x 0x%02x 0x%02x 0x%02x %d%% %d %s\n", |
1709 | driver_version, | 1707 | driver_version, |
1710 | (apm_info.bios.version >> 8) & 0xff, | 1708 | (apm_info.bios.version >> 8) & 0xff, |
1711 | apm_info.bios.version & 0xff, | 1709 | apm_info.bios.version & 0xff, |
@@ -1716,10 +1714,22 @@ static int apm_get_info(char *buf, char **start, off_t fpos, int length) | |||
1716 | percentage, | 1714 | percentage, |
1717 | time_units, | 1715 | time_units, |
1718 | units); | 1716 | units); |
1717 | return 0; | ||
1718 | } | ||
1719 | 1719 | ||
1720 | return p - buf; | 1720 | static int proc_apm_open(struct inode *inode, struct file *file) |
1721 | { | ||
1722 | return single_open(file, proc_apm_show, NULL); | ||
1721 | } | 1723 | } |
1722 | 1724 | ||
1725 | static const struct file_operations apm_file_ops = { | ||
1726 | .owner = THIS_MODULE, | ||
1727 | .open = proc_apm_open, | ||
1728 | .read = seq_read, | ||
1729 | .llseek = seq_lseek, | ||
1730 | .release = single_release, | ||
1731 | }; | ||
1732 | |||
1723 | static int apm(void *unused) | 1733 | static int apm(void *unused) |
1724 | { | 1734 | { |
1725 | unsigned short bx; | 1735 | unsigned short bx; |
@@ -2341,9 +2351,9 @@ static int __init apm_init(void) | |||
2341 | set_base(gdt[APM_DS >> 3], | 2351 | set_base(gdt[APM_DS >> 3], |
2342 | __va((unsigned long)apm_info.bios.dseg << 4)); | 2352 | __va((unsigned long)apm_info.bios.dseg << 4)); |
2343 | 2353 | ||
2344 | apm_proc = create_proc_info_entry("apm", 0, NULL, apm_get_info); | 2354 | apm_proc = create_proc_entry("apm", 0, NULL); |
2345 | if (apm_proc) | 2355 | if (apm_proc) |
2346 | apm_proc->owner = THIS_MODULE; | 2356 | apm_proc->proc_fops = &apm_file_ops; |
2347 | 2357 | ||
2348 | kapmd_task = kthread_create(apm, NULL, "kapmd"); | 2358 | kapmd_task = kthread_create(apm, NULL, "kapmd"); |
2349 | if (IS_ERR(kapmd_task)) { | 2359 | if (IS_ERR(kapmd_task)) { |