From: Dmitry Torokhov <dtor_core@ameritech.net>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Massimo Dal Zotto <dz@debian.org>
Subject: [PATCH 3/5] I8K - switch to seq_file
Date: Thu, 24 Feb 2005 01:12:54 -0500 [thread overview]
Message-ID: <200502240112.56523.dtor_core@ameritech.net> (raw)
In-Reply-To: <200502240112.02062.dtor_core@ameritech.net>
===================================================================
I8K: Change proc code to use seq_file.
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
i8k.c | 64 ++++++++++++++++++++++------------------------------------------
1 files changed, 22 insertions(+), 42 deletions(-)
Index: dtor/drivers/char/i8k.c
===================================================================
--- dtor.orig/drivers/char/i8k.c
+++ dtor/drivers/char/i8k.c
@@ -20,13 +20,14 @@
#include <linux/types.h>
#include <linux/init.h>
#include <linux/proc_fs.h>
+#include <linux/seq_file.h>
#include <linux/dmi.h>
#include <asm/uaccess.h>
#include <asm/io.h>
#include <linux/i8k.h>
-#define I8K_VERSION "1.13 14/05/2002"
+#define I8K_VERSION "1.14 21/02/2005"
#define I8K_SMM_FN_STATUS 0x0025
#define I8K_SMM_POWER_STATUS 0x0069
@@ -74,13 +75,16 @@ static int power_status;
module_param(power_status, bool, 0600);
MODULE_PARM_DESC(power_status, "Report power status in /proc/i8k");
-static ssize_t i8k_read(struct file *, char __user *, size_t, loff_t *);
+static int i8k_open_fs(struct inode *inode, struct file *file);
static int i8k_ioctl(struct inode *, struct file *, unsigned int,
unsigned long);
static struct file_operations i8k_fops = {
- .read = i8k_read,
- .ioctl = i8k_ioctl,
+ .open = i8k_open_fs,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+ .ioctl = i8k_ioctl,
};
typedef struct {
@@ -400,9 +404,9 @@ static int i8k_ioctl(struct inode *ip, s
/*
* Print the information for /proc/i8k.
*/
-static int i8k_get_info(char *buffer, char **start, off_t fpos, int length)
+static int i8k_proc_show(struct seq_file *seq, void *offset)
{
- int n, fn_key, cpu_temp, ac_power;
+ int fn_key, cpu_temp, ac_power;
int left_fan, right_fan, left_speed, right_speed;
cpu_temp = i8k_get_cpu_temp(); /* 11100 ??s */
@@ -431,42 +435,18 @@ static int i8k_get_info(char *buffer, ch
* 9) AC power
* 10) Fn Key status
*/
- n = sprintf(buffer, "%s %s %s %d %d %d %d %d %d %d\n",
- I8K_PROC_FMT,
- bios_version,
- dmi_get_system_info(DMI_PRODUCT_SERIAL) ? : "N/A",
- cpu_temp,
- left_fan, right_fan, left_speed, right_speed,
- ac_power, fn_key);
-
- return n;
+ return seq_printf(seq, "%s %s %s %d %d %d %d %d %d %d\n",
+ I8K_PROC_FMT,
+ bios_version,
+ dmi_get_system_info(DMI_PRODUCT_SERIAL) ? : "N/A",
+ cpu_temp,
+ left_fan, right_fan, left_speed, right_speed,
+ ac_power, fn_key);
}
-static ssize_t i8k_read(struct file *f, char __user * buffer, size_t len,
- loff_t * fpos)
+static int i8k_open_fs(struct inode *inode, struct file *file)
{
- int n;
- char info[128];
-
- n = i8k_get_info(info, NULL, 0, 128);
- if (n <= 0) {
- return n;
- }
-
- if (*fpos >= n) {
- return 0;
- }
-
- if ((*fpos + len) >= n) {
- len = n - *fpos;
- }
-
- if (copy_to_user(buffer, info, len) != 0) {
- return -EFAULT;
- }
-
- *fpos += len;
- return len;
+ return single_open(file, i8k_proc_show, NULL);
}
static struct dmi_system_id __initdata i8k_dmi_table[] = {
@@ -562,10 +542,10 @@ int __init i8k_init(void)
return -ENODEV;
/* Register the proc entry */
- proc_i8k = create_proc_info_entry("i8k", 0, NULL, i8k_get_info);
- if (!proc_i8k) {
+ proc_i8k = create_proc_entry("i8k", 0, NULL);
+ if (!proc_i8k)
return -ENOENT;
- }
+
proc_i8k->proc_fops = &i8k_fops;
proc_i8k->owner = THIS_MODULE;
next prev parent reply other threads:[~2005-02-24 6:18 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-02-24 6:10 [PATCH 0/5] I8K driver facelift Dmitry Torokhov
2005-02-24 6:11 ` [PATCH 1/5] I8K - pass though Lindent Dmitry Torokhov
2005-02-24 6:12 ` [PATCH 2/5] I8K - use standard DMI functions Dmitry Torokhov
2005-02-24 6:12 ` Dmitry Torokhov [this message]
2005-02-24 6:14 ` [PATCH 4/5] I8K - switch to module_{init|exit} Dmitry Torokhov
2005-02-24 6:14 ` [PATCH 5/5] I8K - convert to platform device (sysfs) Dmitry Torokhov
2005-03-13 3:41 ` [PATCH 0/5] I8K driver facelift Frank Sorenson
2005-03-13 3:59 ` Dmitry Torokhov
2005-03-15 8:12 ` Valdis.Kletnieks
2005-03-15 10:59 ` Giuseppe Bilotta
2005-03-15 17:30 ` Valdis.Kletnieks
2005-03-15 22:34 ` Frank Sorenson
2005-03-16 21:38 ` Frank Sorenson
2005-03-17 6:40 ` Dmitry Torokhov
2005-03-17 9:37 ` Frank Sorenson
2005-03-17 15:05 ` Dmitry Torokhov
2005-03-17 9:46 ` Frank Sorenson
2005-03-21 5:12 ` Dmitry Torokhov
2005-03-21 22:53 ` Frank Sorenson
2005-03-21 23:55 ` Dmitry Torokhov
2005-03-24 7:25 ` Greg KH
2005-03-24 7:39 ` Dmitry Torokhov
2005-03-24 8:00 ` Greg KH
2005-03-24 14:44 ` Dmitry Torokhov
2005-03-17 8:16 ` Valdis.Kletnieks
2005-03-24 7:24 ` Greg KH
2005-04-13 6:33 ` Dmitry Torokhov
2005-04-13 8:00 ` Greg KH
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200502240112.56523.dtor_core@ameritech.net \
--to=dtor_core@ameritech.net \
--cc=dz@debian.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox