[PATCH 2/3] UBUNTU: SAUCE: toshiba_acpi -- convert to modern seq_file proc interfaces

Andy Whitcroft apw at canonical.com
Tue Nov 18 16:27:14 UTC 2008


The deprecated procfs interface create_proc_info_entry has now actually
been removed.  Refactor in terms of the modern seq_file interfaces.

Signed-off-by: Andy Whitcroft <apw at canonical.com>
---
 drivers/acpi/toshiba_acpi.c |   24 ++++++++++++++++++------
 1 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/drivers/acpi/toshiba_acpi.c b/drivers/acpi/toshiba_acpi.c
index f320918..ea34164 100644
--- a/drivers/acpi/toshiba_acpi.c
+++ b/drivers/acpi/toshiba_acpi.c
@@ -59,6 +59,7 @@
 #include <linux/toshiba.h>
 #include <asm/io.h>
 #include <linux/backlight.h>
+#include <linux/seq_file.h>
 
 #include <asm/uaccess.h>
 
@@ -629,9 +630,8 @@ setup_tosh_info(void __iomem *bios)
 
 /* /proc/toshiba read handler */
 static int
-tosh_get_info(char* buffer, char** start, off_t fpos, int length)
+old_toshiba_proc_show(struct seq_file *m, void *v)
 {
-	char* temp = buffer;
 	/* TODO: tosh_fn_status() */
 	int key = 0;
 
@@ -643,8 +643,7 @@ tosh_get_info(char* buffer, char** start, off_t fpos, int length)
 	 *    4) BIOS date (in SCI date format)
 	 *    5) Fn Key status
 	 */
-
-	temp += sprintf(temp, "1.1 0x%04x %d.%d %d.%d 0x%04x 0x%02x\n",
+	seq_printf(m, "1.1 0x%04x %d.%d %d.%d 0x%04x 0x%02x\n",
 		tosh_id,
 		(tosh_sci & 0xff00)>>8,
 		tosh_sci & 0xff,
@@ -653,9 +652,22 @@ tosh_get_info(char* buffer, char** start, off_t fpos, int length)
 		tosh_date,
 		key);
 
-	return temp-buffer;
+	return 0;
 }
 
+static int old_toshiba_proc_open(struct inode *inode, struct file *file)
+{
+	return single_open(file, old_toshiba_proc_show, NULL);
+}
+
+static const struct file_operations old_toshiba_proc_fops = {
+	.owner          = THIS_MODULE,
+	.open           = old_toshiba_proc_open,
+	.read           = seq_read,
+	.llseek         = seq_lseek,
+	.release        = single_release,
+};
+
 static int __init
 old_driver_emulation_init(void)
 {
@@ -671,7 +683,7 @@ old_driver_emulation_init(void)
 	}
 
 	setup_tosh_info(bios);
-	create_proc_info_entry(OLD_PROC_TOSHIBA, 0, NULL, tosh_get_info);
+	proc_create(OLD_PROC_TOSHIBA, 0, NULL, &old_toshiba_proc_fops);
 
 	iounmap(bios);
 
-- 
1.6.0.4.911.gc990





More information about the kernel-team mailing list