X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Facpi%2Ffan.c;h=2c5422dfecb5af6e8b5a57dd8af926be23445319;hb=6a77f38946aaee1cd85eeec6cf4229b204c15071;hp=fa2a1b4141b5b648bf0730f24e52446995524e25;hpb=9213980e6a70d8473e0ffd4b39ab5b6caaba9ff5;p=linux-2.6.git diff --git a/drivers/acpi/fan.c b/drivers/acpi/fan.c index fa2a1b414..2c5422dfe 100644 --- a/drivers/acpi/fan.c +++ b/drivers/acpi/fan.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -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; }