Commit 016d6f35 authored by Alexey Dobriyan's avatar Alexey Dobriyan Committed by Andi Kleen

[PATCH] i386: Convert /proc/apm to seqfile

Byte-to-byte identical /proc/apm here.
Signed-off-by: default avatarAlexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: default avatarAndi Kleen <ak@suse.de>
parent b0957f1a
...@@ -211,6 +211,7 @@ ...@@ -211,6 +211,7 @@
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/stat.h> #include <linux/stat.h>
#include <linux/proc_fs.h> #include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <linux/miscdevice.h> #include <linux/miscdevice.h>
#include <linux/apm_bios.h> #include <linux/apm_bios.h>
#include <linux/init.h> #include <linux/init.h>
...@@ -1636,9 +1637,8 @@ static int do_open(struct inode * inode, struct file * filp) ...@@ -1636,9 +1637,8 @@ static int do_open(struct inode * inode, struct file * filp)
return 0; return 0;
} }
static int apm_get_info(char *buf, char **start, off_t fpos, int length) static int proc_apm_show(struct seq_file *m, void *v)
{ {
char * p;
unsigned short bx; unsigned short bx;
unsigned short cx; unsigned short cx;
unsigned short dx; unsigned short dx;
...@@ -1650,8 +1650,6 @@ static int apm_get_info(char *buf, char **start, off_t fpos, int length) ...@@ -1650,8 +1650,6 @@ static int apm_get_info(char *buf, char **start, off_t fpos, int length)
int time_units = -1; int time_units = -1;
char *units = "?"; char *units = "?";
p = buf;
if ((num_online_cpus() == 1) && if ((num_online_cpus() == 1) &&
!(error = apm_get_power_status(&bx, &cx, &dx))) { !(error = apm_get_power_status(&bx, &cx, &dx))) {
ac_line_status = (bx >> 8) & 0xff; 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,7 +1703,7 @@ static int apm_get_info(char *buf, char **start, off_t fpos, int length)
-1: Unknown -1: Unknown
8) min = minutes; sec = seconds */ 8) min = minutes; sec = seconds */
p += sprintf(p, "%s %d.%d 0x%02x 0x%02x 0x%02x 0x%02x %d%% %d %s\n", seq_printf(m, "%s %d.%d 0x%02x 0x%02x 0x%02x 0x%02x %d%% %d %s\n",
driver_version, driver_version,
(apm_info.bios.version >> 8) & 0xff, (apm_info.bios.version >> 8) & 0xff,
apm_info.bios.version & 0xff, apm_info.bios.version & 0xff,
...@@ -1716,10 +1714,22 @@ static int apm_get_info(char *buf, char **start, off_t fpos, int length) ...@@ -1716,10 +1714,22 @@ static int apm_get_info(char *buf, char **start, off_t fpos, int length)
percentage, percentage,
time_units, time_units,
units); units);
return 0;
}
return p - buf; static int proc_apm_open(struct inode *inode, struct file *file)
{
return single_open(file, proc_apm_show, NULL);
} }
static const struct file_operations apm_file_ops = {
.owner = THIS_MODULE,
.open = proc_apm_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
static int apm(void *unused) static int apm(void *unused)
{ {
unsigned short bx; unsigned short bx;
...@@ -2341,9 +2351,9 @@ static int __init apm_init(void) ...@@ -2341,9 +2351,9 @@ static int __init apm_init(void)
set_base(gdt[APM_DS >> 3], set_base(gdt[APM_DS >> 3],
__va((unsigned long)apm_info.bios.dseg << 4)); __va((unsigned long)apm_info.bios.dseg << 4));
apm_proc = create_proc_info_entry("apm", 0, NULL, apm_get_info); apm_proc = create_proc_entry("apm", 0, NULL);
if (apm_proc) if (apm_proc)
apm_proc->owner = THIS_MODULE; apm_proc->proc_fops = &apm_file_ops;
kapmd_task = kthread_create(apm, NULL, "kapmd"); kapmd_task = kthread_create(apm, NULL, "kapmd");
if (IS_ERR(kapmd_task)) { if (IS_ERR(kapmd_task)) {
......
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