From: Dmitry Torokhov <dtor_core@ameritech.net>
To: Andrew Morton <akpm@osdl.org>
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH 4/6] I8K: convert to seqfile
Date: Wed, 27 Apr 2005 01:53:30 -0500 [thread overview]
Message-ID: <200504270153.30586.dtor_core@ameritech.net> (raw)
In-Reply-To: <200504270149.13450.dtor_core@ameritech.net>
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8", Size: 3363 bytes --]
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[] = {
@@ -560,10 +540,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-04-27 7:03 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-04-27 6:49 [PATCH 0/6] I8K and Toshiba legacy driver cleanup Dmitry Torokhov
2005-04-27 6:50 ` [PATCH 1/6] Toshiba " Dmitry Torokhov
2005-04-27 7:33 ` Andrew Morton
2005-04-27 13:42 ` Dmitry Torokhov
2005-04-28 4:58 ` Dmitry Torokhov
2005-04-27 6:52 ` [PATCH 2/6] I8K: pass through lindent Dmitry Torokhov
2005-04-27 6:52 ` [PATCH 3/6] I8K: use standard DMI interface Dmitry Torokhov
2005-04-28 5:02 ` Dmitry Torokhov
2005-04-27 6:53 ` Dmitry Torokhov [this message]
2005-04-27 6:54 ` [PATCH 5/6] I8K: initialization code cleanup; formatting Dmitry Torokhov
2005-04-27 6:55 ` [PATCH 6/6] I8K: add new BIOS signatures Dmitry Torokhov
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=200504270153.30586.dtor_core@ameritech.net \
--to=dtor_core@ameritech.net \
--cc=akpm@osdl.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