vserver 1.9.5.x5
[linux-2.6.git] / drivers / acpi / fan.c
index fa2a1b4..2c5422d 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/init.h>
 #include <linux/types.h>
 #include <linux/proc_fs.h>
+#include <linux/seq_file.h>
 #include <asm/uaccess.h>
 
 #include <acpi/acpi_bus.h>
@@ -75,51 +76,41 @@ struct proc_dir_entry               *acpi_fan_dir;
 
 
 static int
-acpi_fan_read_state (
-       char                    *page,
-       char                    **start,
-       off_t                   off,
-       int                     count,
-       int                     *eof,
-       void                    *data)
+acpi_fan_read_state (struct seq_file *seq, void *offset)
 {
-       struct acpi_fan         *fan = (struct acpi_fan *) data;
-       char                    *p = page;
-       int                     len = 0;
+       struct acpi_fan         *fan = (struct acpi_fan *) seq->private;
        int                     state = 0;
 
        ACPI_FUNCTION_TRACE("acpi_fan_read_state");
 
-       if (!fan || (off != 0))
+       if (!fan)
                goto end;
 
        if (acpi_bus_get_power(fan->handle, &state))
                goto end;
 
-       p += sprintf(p, "status:                  %s\n",
+       seq_printf(seq, "status:                  %s\n",
                !state?"on":"off");
 
 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_VALUE(0);
 }
 
+static int acpi_fan_state_open_fs(struct inode *inode, struct file *file)
+{
+       return single_open(file, acpi_fan_read_state, PDE(inode)->data);
+}
 
-static int
+static ssize_t
 acpi_fan_write_state (
        struct file             *file,
        const char              __user *buffer,
-       unsigned long           count,
-       void                    *data)
+       size_t                  count,
+       loff_t                  *ppos)
 {
        int                     result = 0;
-       struct acpi_fan         *fan = (struct acpi_fan *) data;
+       struct seq_file         *m = (struct seq_file *)file->private_data;
+       struct acpi_fan         *fan = (struct acpi_fan *) m->private;
        char                    state_string[12] = {'\0'};
 
        ACPI_FUNCTION_TRACE("acpi_fan_write_state");
@@ -140,6 +131,14 @@ acpi_fan_write_state (
        return_VALUE(count);
 }
 
+static struct file_operations acpi_fan_state_ops = {
+       .open           = acpi_fan_state_open_fs,
+       .read           = seq_read,
+       .write          = acpi_fan_write_state,
+       .llseek         = seq_lseek,
+       .release        = single_release,
+       .owner = THIS_MODULE,
+};
 
 static int
 acpi_fan_add_fs (
@@ -168,8 +167,7 @@ acpi_fan_add_fs (
                        "Unable to create '%s' fs entry\n",
                        ACPI_FAN_FILE_STATE));
        else {
-               entry->read_proc = acpi_fan_read_state;
-               entry->write_proc = acpi_fan_write_state;
+               entry->proc_fops = &acpi_fan_state_ops;
                entry->data = acpi_driver_data(device);
                entry->owner = THIS_MODULE;
        }