[PATCH] drivers/acpi/ac.c: convert to seq_file

Arnaldo Carvalho de Melo (acme@conectiva.com.br)
Thu, 14 Nov 2002 14:45:42 -0200


Hi Andrew,

Please consider pulling from:

bk://oops.kerneljanitors.org:acpi-2.5

This is the first in a series of changesets converting
ACPI to seq_file, please lets us know if something is unacceptable.

The work was done by Aristeu Rozanski.

- Arnaldo

You can import this changeset into BK by piping this whole message to:
'| bk receive [path to repository]' or apply the patch as usual.

===================================================================

ChangeSet@1.846, 2002-11-13 19:35:45-02:00, aris@cathedrallabs.org
drivers/acpi/ac.c: convert to seq_file

ac.c | 57 ++++++++++++++++++++++++++-------------------------------
1 files changed, 26 insertions(+), 31 deletions(-)

diff -Nru a/drivers/acpi/ac.c b/drivers/acpi/ac.c
--- a/drivers/acpi/ac.c Thu Nov 14 14:20:40 2002
+++ b/drivers/acpi/ac.c Thu Nov 14 14:20:40 2002
@@ -29,6 +29,7 @@
#include <linux/types.h>
#include <linux/compatmac.h>
#include <linux/proc_fs.h>
+#include <linux/seq_file.h>
#include "acpi_bus.h"
#include "acpi_drivers.h"

@@ -53,6 +54,7 @@

int acpi_ac_add (struct acpi_device *device);
int acpi_ac_remove (struct acpi_device *device, int type);
+static int acpi_ac_open_fs(struct inode *inode, struct file *file);

static struct acpi_driver acpi_ac_driver = {
.name = ACPI_AC_DRIVER_NAME,
@@ -69,6 +71,12 @@
unsigned long state;
};

+static struct file_operations acpi_ac_fops = {
+ .open = acpi_ac_open_fs,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+};

/* --------------------------------------------------------------------------
AC Adapter Management
@@ -103,53 +111,40 @@

struct proc_dir_entry *acpi_ac_dir = NULL;

-static int
-acpi_ac_read_state (
- char *page,
- char **start,
- off_t off,
- int count,
- int *eof,
- void *data)
+int acpi_ac_seq_show(struct seq_file *seq, void *offset)
{
- struct acpi_ac *ac = (struct acpi_ac *) data;
- char *p = page;
- int len = 0;
+ struct acpi_ac *ac = (struct acpi_ac *) seq->private;

- ACPI_FUNCTION_TRACE("acpi_ac_read_state");
+ ACPI_FUNCTION_TRACE("acpi_ac_seq_show");

- if (!ac || (off != 0))
- goto end;
+ if (!ac)
+ return 0;

if (acpi_ac_get_state(ac)) {
- p += sprintf(p, "ERROR: Unable to read AC Adapter state\n");
- goto end;
+ seq_puts(seq, "ERROR: Unable to read AC Adapter state\n");
+ return 0;
}

- p += sprintf(p, "state: ");
+ seq_puts(seq, "state: ");
switch (ac->state) {
case ACPI_AC_STATUS_OFFLINE:
- p += sprintf(p, "off-line\n");
+ seq_puts(seq, "off-line\n");
break;
case ACPI_AC_STATUS_ONLINE:
- p += sprintf(p, "on-line\n");
+ seq_puts(seq, "on-line\n");
break;
default:
- p += sprintf(p, "unknown\n");
+ seq_puts(seq, "unknown\n");
break;
}

-end:
- len = (p - page);
- if (len <= off+count) *eof = 1;
- *start = page + off;
- len -= off;
- if (len>count) len = count;
- if (len<0) len = 0;
-
- return_VALUE(len);
+ return 0;
+}
+
+static int acpi_ac_open_fs(struct inode *inode, struct file *file)
+{
+ return single_open(file, acpi_ac_seq_show, PDE(inode)->data);
}
-

static int
acpi_ac_add_fs (
@@ -180,7 +175,7 @@
"Unable to create '%s' fs entry\n",
ACPI_AC_FILE_STATE));
else {
- entry->read_proc = acpi_ac_read_state;
+ entry->proc_fops = &acpi_ac_fops;
entry->data = acpi_driver_data(device);
}

===================================================================

This BitKeeper patch contains the following changesets:
1.846
## Wrapped with gzip_uu ##

begin 664 bkpatch5049
M'XL(`%C-TST``[55;6_:2!#^[/T5<XET`@[,OGB-<8XHE.1ZJ*<&<<VWD]!B
M+\&*LTOMA5Q5^M^[:P--H-6]J#5HQ\P\\\SL[+/B'.Y*6<2>2!XE.H??=6EB
M+]%*)B;;"#_1C_Z\L(&IUC;07>I'V7WUIBN25=:A/D<V-!$F6<)&%F7L$9\=
M/.;#2L;>].;UW1_#*4*#`8R60MW+/Z6!P0`976Q$GI97PBQSK7Q3"%4^2E,5
MW1Z@6XHQM1].>@SS<$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at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/