aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorDmitry Torokhov <dtor_core@ameritech.net>2005-06-25 17:54:26 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-25 19:24:24 -0400
commit352f8f8bfbfb401c8af4c685beaafeb95c27fdd1 (patch)
treee76bf5589246831604130349ae67b30b998deb29 /drivers
parente70c9d5e61c6cb2272c866fc1303e62975006752 (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')
-rw-r--r--drivers/char/i8k.c64
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;
74module_param(power_status, bool, 0600); 75module_param(power_status, bool, 0600);
75MODULE_PARM_DESC(power_status, "Report power status in /proc/i8k"); 76MODULE_PARM_DESC(power_status, "Report power status in /proc/i8k");
76 77
77static ssize_t i8k_read(struct file *, char __user *, size_t, loff_t *); 78static int i8k_open_fs(struct inode *inode, struct file *file);
78static int i8k_ioctl(struct inode *, struct file *, unsigned int, 79static int i8k_ioctl(struct inode *, struct file *, unsigned int,
79 unsigned long); 80 unsigned long);
80 81
81static struct file_operations i8k_fops = { 82static 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
86typedef struct { 90typedef 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 */
403static int i8k_get_info(char *buffer, char **start, off_t fpos, int length) 407static 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
445static ssize_t i8k_read(struct file *f, char __user * buffer, size_t len, 447static 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
472static struct dmi_system_id __initdata i8k_dmi_table[] = { 452static 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