LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] seq_file conversion: APM on mips
@ 2007-01-15 21:14 Alexey Dobriyan
2007-01-23 14:36 ` Pavel Machek
0 siblings, 1 reply; 3+ messages in thread
From: Alexey Dobriyan @ 2007-01-15 21:14 UTC (permalink / raw)
To: akpm; +Cc: linux-kernel, linux-mips
Compile-tested.
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
arch/mips/kernel/apm.c | 28 +++++++++++++++++++++++-----
1 file changed, 23 insertions(+), 5 deletions(-)
--- a/arch/mips/kernel/apm.c
+++ b/arch/mips/kernel/apm.c
@@ -15,6 +15,7 @@ #include <linux/poll.h>
#include <linux/timer.h>
#include <linux/slab.h>
#include <linux/proc_fs.h>
+#include <linux/seq_file.h>
#include <linux/miscdevice.h>
#include <linux/apm_bios.h>
#include <linux/capability.h>
@@ -434,11 +435,10 @@ #ifdef CONFIG_PROC_FS
* -1: Unknown
* 8) min = minutes; sec = seconds
*/
-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)
{
struct apm_power_info info;
char *units;
- int ret;
info.ac_line_status = 0xff;
info.battery_status = 0xff;
@@ -456,14 +456,26 @@ static int apm_get_info(char *buf, char
case 1: units = "sec"; break;
}
- ret = sprintf(buf, "%s 1.2 0x%02x 0x%02x 0x%02x 0x%02x %d%% %d %s\n",
+ seq_printf(m, "%s 1.2 0x%02x 0x%02x 0x%02x 0x%02x %d%% %d %s\n",
driver_version, APM_32_BIT_SUPPORT,
info.ac_line_status, info.battery_status,
info.battery_flag, info.battery_life,
info.time, units);
+ return 0;
+}
- return ret;
+static int proc_apm_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, proc_apm_show, NULL);
}
+
+static const struct file_operations proc_apm_fops = {
+ .owner = THIS_MODULE,
+ .open = proc_apm_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+};
#endif
static int kapmd(void *arg)
@@ -529,7 +541,13 @@ static int __init apm_init(void)
}
#ifdef CONFIG_PROC_FS
- create_proc_info_entry("apm", 0, NULL, apm_get_info);
+ {
+ struct proc_dir_entry *pde;
+
+ pde = create_proc_entry("apm", 0, NULL);
+ if (pde)
+ pde->proc_fops = &proc_apm_fops;
+ }
#endif
ret = misc_register(&apm_device);
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] seq_file conversion: APM on mips
2007-01-15 21:14 [PATCH] seq_file conversion: APM on mips Alexey Dobriyan
@ 2007-01-23 14:36 ` Pavel Machek
2007-01-24 13:50 ` Alexey Dobriyan
0 siblings, 1 reply; 3+ messages in thread
From: Pavel Machek @ 2007-01-23 14:36 UTC (permalink / raw)
To: Alexey Dobriyan; +Cc: akpm, linux-kernel, linux-mips
Hi!
> @@ -456,14 +456,26 @@ static int apm_get_info(char *buf, char
> case 1: units = "sec"; break;
> }
>
> - ret = sprintf(buf, "%s 1.2 0x%02x 0x%02x 0x%02x 0x%02x %d%% %d %s\n",
> + seq_printf(m, "%s 1.2 0x%02x 0x%02x 0x%02x 0x%02x %d%% %d %s\n",
> driver_version, APM_32_BIT_SUPPORT,
> info.ac_line_status, info.battery_status,
> info.battery_flag, info.battery_life,
> info.time, units);
> + return 0;
> +}
>
> - return ret;
> +static int proc_apm_open(struct inode *inode, struct file *file)
> +{
> + return single_open(file, proc_apm_show, NULL);
> }
> +
> +static const struct file_operations proc_apm_fops = {
> + .owner = THIS_MODULE,
> + .open = proc_apm_open,
> + .read = seq_read,
> + .llseek = seq_lseek,
> + .release = single_release,
> +};
> #endif
>
> static int kapmd(void *arg)
Perhaps now is good time to make the code shared?
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] seq_file conversion: APM on mips
2007-01-23 14:36 ` Pavel Machek
@ 2007-01-24 13:50 ` Alexey Dobriyan
0 siblings, 0 replies; 3+ messages in thread
From: Alexey Dobriyan @ 2007-01-24 13:50 UTC (permalink / raw)
To: Pavel Machek; +Cc: akpm, linux-kernel, linux-mips
On 1/23/07, Pavel Machek <pavel@ucw.cz> wrote:
> Hi!
>
> > @@ -456,14 +456,26 @@ static int apm_get_info(char *buf, char
> > case 1: units = "sec"; break;
> > }
> >
> > - ret = sprintf(buf, "%s 1.2 0x%02x 0x%02x 0x%02x 0x%02x %d%% %d %s\n",
> > + seq_printf(m, "%s 1.2 0x%02x 0x%02x 0x%02x 0x%02x %d%% %d %s\n",
> > driver_version, APM_32_BIT_SUPPORT,
> > info.ac_line_status, info.battery_status,
> > info.battery_flag, info.battery_life,
> > info.time, units);
> > + return 0;
> > +}
> >
> > - return ret;
> > +static int proc_apm_open(struct inode *inode, struct file *file)
> > +{
> > + return single_open(file, proc_apm_show, NULL);
> > }
> > +
> > +static const struct file_operations proc_apm_fops = {
> > + .owner = THIS_MODULE,
> > + .open = proc_apm_open,
> > + .read = seq_read,
> > + .llseek = seq_lseek,
> > + .release = single_release,
> > +};
> > #endif
> >
> > static int kapmd(void *arg)
>
> Perhaps now is good time to make the code shared?
Well, my intention was to remove last ->get_info users and
remove struct proc_dir_entry::get_info altogether.
I didn't know about APM merging efforts.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-01-24 13:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-01-15 21:14 [PATCH] seq_file conversion: APM on mips Alexey Dobriyan
2007-01-23 14:36 ` Pavel Machek
2007-01-24 13:50 ` Alexey Dobriyan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).