diff options
author | Dmitry Torokhov <dtor_core@ameritech.net> | 2005-06-25 17:54:26 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-06-25 19:24:24 -0400 |
commit | 352f8f8bfbfb401c8af4c685beaafeb95c27fdd1 (patch) | |
tree | e76bf5589246831604130349ae67b30b998deb29 /drivers/char/i8k.c | |
parent | e70c9d5e61c6cb2272c866fc1303e62975006752 (diff) |
[PATCH] I8K: convert to seqfile
I8K: Change proc code to use seq_file.
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/char/i8k.c')
-rw-r--r-- | drivers/char/i8k.c | 64 |
1 files changed, 22 insertions, 42 deletions
diff --git a/drivers/char/i8k.c b/drivers/char/i8k.c index 81d2f675fb77..1599456bdb65 100644 --- a/drivers/char/i8k.c +++ b/drivers/char/i8k.c | |||
@@ -20,13 +20,14 @@ | |||
20 | #include <linux/types.h> | 20 | #include <linux/types.h> |
21 | #include <linux/init.h> | 21 | #include <linux/init.h> |
22 | #include <linux/proc_fs.h> | 22 | #include <linux/proc_fs.h> |
23 | #include <linux/seq_file.h> | ||
23 | #include <linux/dmi.h> | 24 | #include <linux/dmi.h> |
24 | #include <asm/uaccess.h> | 25 | #include <asm/uaccess.h> |
25 | #include <asm/io.h> | 26 | #include <asm/io.h> |
26 | 27 | ||
27 | #include <linux/i8k.h> | 28 | #include <linux/i8k.h> |
28 | 29 | ||
29 | #define I8K_VERSION "1.13 14/05/2002" | 30 | #define I8K_VERSION "1.14 21/02/2005" |
30 | 31 | ||
31 | #define I8K_SMM_FN_STATUS 0x0025 | 32 | #define I8K_SMM_FN_STATUS 0x0025 |
32 | #define I8K_SMM_POWER_STATUS 0x0069 | 33 | #define I8K_SMM_POWER_STATUS 0x0069 |
@@ -74,13 +75,16 @@ static int power_status; | |||
74 | module_param(power_status, bool, 0600); | 75 | module_param(power_status, bool, 0600); |
75 | MODULE_PARM_DESC(power_status, "Report power status in /proc/i8k"); | 76 | MODULE_PARM_DESC(power_status, "Report power status in /proc/i8k"); |
76 | 77 | ||
77 | static ssize_t i8k_read(struct file *, char __user *, size_t, loff_t *); | 78 | static int i8k_open_fs(struct inode *inode, struct file *file); |
78 | static int i8k_ioctl(struct inode *, struct file *, unsigned int, | 79 | static int i8k_ioctl(struct inode *, struct file *, unsigned int, |
79 | unsigned long); | 80 | unsigned long); |
80 | 81 | ||
81 | static struct file_operations i8k_fops = { | 82 | static struct file_operations i8k_fops = { |
82 | .read = i8k_read, | 83 | .open = i8k_open_fs, |
83 | .ioctl = i8k_ioctl, | 84 | .read = seq_read, |
85 | .llseek = seq_lseek, | ||
86 | .release = single_release, | ||
87 | .ioctl = i8k_ioctl, | ||
84 | }; | 88 | }; |
85 | 89 | ||
86 | typedef struct { | 90 | typedef struct { |
@@ -400,9 +404,9 @@ static int i8k_ioctl(struct inode *ip, struct file *fp, unsigned int cmd, | |||
400 | /* | 404 | /* |
401 | * Print the information for /proc/i8k. | 405 | * Print the information for /proc/i8k. |
402 | */ | 406 | */ |
403 | static int i8k_get_info(char *buffer, char **start, off_t fpos, int length) | 407 | static int i8k_proc_show(struct seq_file *seq, void *offset) |
404 | { | 408 | { |
405 | int n, fn_key, cpu_temp, ac_power; | 409 | int fn_key, cpu_temp, ac_power; |
406 | int left_fan, right_fan, left_speed, right_speed; | 410 | int left_fan, right_fan, left_speed, right_speed; |
407 | 411 | ||
408 | cpu_temp = i8k_get_cpu_temp(); /* 11100 µs */ | 412 | cpu_temp = i8k_get_cpu_temp(); /* 11100 µs */ |
@@ -431,42 +435,18 @@ static int i8k_get_info(char *buffer, char **start, off_t fpos, int length) | |||
431 | * 9) AC power | 435 | * 9) AC power |
432 | * 10) Fn Key status | 436 | * 10) Fn Key status |
433 | */ | 437 | */ |
434 | n = sprintf(buffer, "%s %s %s %d %d %d %d %d %d %d\n", | 438 | return seq_printf(seq, "%s %s %s %d %d %d %d %d %d %d\n", |
435 | I8K_PROC_FMT, | 439 | I8K_PROC_FMT, |
436 | bios_version, | 440 | bios_version, |
437 | dmi_get_system_info(DMI_PRODUCT_SERIAL) ? : "N/A", | 441 | dmi_get_system_info(DMI_PRODUCT_SERIAL) ? : "N/A", |
438 | cpu_temp, | 442 | cpu_temp, |
439 | left_fan, right_fan, left_speed, right_speed, | 443 | left_fan, right_fan, left_speed, right_speed, |
440 | ac_power, fn_key); | 444 | ac_power, fn_key); |
441 | |||
442 | return n; | ||
443 | } | 445 | } |
444 | 446 | ||
445 | static ssize_t i8k_read(struct file *f, char __user * buffer, size_t len, | 447 | static int i8k_open_fs(struct inode *inode, struct file *file) |
446 | loff_t * fpos) | ||
447 | { | 448 | { |
448 | int n; | 449 | return single_open(file, i8k_proc_show, NULL); |
449 | char info[128]; | ||
450 | |||
451 | n = i8k_get_info(info, NULL, 0, 128); | ||
452 | if (n <= 0) { | ||
453 | return n; | ||
454 | } | ||
455 | |||
456 | if (*fpos >= n) { | ||
457 | return 0; | ||
458 | } | ||
459 | |||
460 | if ((*fpos + len) >= n) { | ||
461 | len = n - *fpos; | ||
462 | } | ||
463 | |||
464 | if (copy_to_user(buffer, info, len) != 0) { | ||
465 | return -EFAULT; | ||
466 | } | ||
467 | |||
468 | *fpos += len; | ||
469 | return len; | ||
470 | } | 450 | } |
471 | 451 | ||
472 | static struct dmi_system_id __initdata i8k_dmi_table[] = { | 452 | static struct dmi_system_id __initdata i8k_dmi_table[] = { |
@@ -560,10 +540,10 @@ int __init i8k_init(void) | |||
560 | return -ENODEV; | 540 | return -ENODEV; |
561 | 541 | ||
562 | /* Register the proc entry */ | 542 | /* Register the proc entry */ |
563 | proc_i8k = create_proc_info_entry("i8k", 0, NULL, i8k_get_info); | 543 | proc_i8k = create_proc_entry("i8k", 0, NULL); |
564 | if (!proc_i8k) { | 544 | if (!proc_i8k) |
565 | return -ENOENT; | 545 | return -ENOENT; |
566 | } | 546 | |
567 | proc_i8k->proc_fops = &i8k_fops; | 547 | proc_i8k->proc_fops = &i8k_fops; |
568 | proc_i8k->owner = THIS_MODULE; | 548 | proc_i8k->owner = THIS_MODULE; |
569 | 549 | ||