From 3049ea7e04408abf35dc295014cb6f1eabcf9b8c Mon Sep 17 00:00:00 2001 From: Cyrill Gorcunov Date: Tue, 2 Oct 2007 13:30:09 -0700 Subject: [POWERPC] Sky Cpu and Nexus: use seq_file/single_open on proc interface This patch changes proc interface to be used with single_file/seq_open calls. Signed-off-by: Cyrill Gorcunov Signed-off-by: Andrew Morton Signed-off-by: Paul Mackerras --- drivers/misc/hdpuftrs/hdpu_nexus.c | 52 ++++++++++++++++++++++++++++---------- 1 file changed, 39 insertions(+), 13 deletions(-) (limited to 'drivers/misc/hdpuftrs/hdpu_nexus.c') diff --git a/drivers/misc/hdpuftrs/hdpu_nexus.c b/drivers/misc/hdpuftrs/hdpu_nexus.c index cc818532c7e..2887b214798 100644 --- a/drivers/misc/hdpuftrs/hdpu_nexus.c +++ b/drivers/misc/hdpuftrs/hdpu_nexus.c @@ -18,18 +18,38 @@ #include #include #include - #include +#include #include static int hdpu_nexus_probe(struct platform_device *pdev); static int hdpu_nexus_remove(struct platform_device *pdev); +static int hdpu_slot_id_open(struct inode *inode, struct file *file); +static int hdpu_slot_id_read(struct seq_file *seq, void *offset); +static int hdpu_chassis_id_open(struct inode *inode, struct file *file); +static int hdpu_chassis_id_read(struct seq_file *seq, void *offset); static struct proc_dir_entry *hdpu_slot_id; static struct proc_dir_entry *hdpu_chassis_id; static int slot_id = -1; static int chassis_id = -1; +static const struct file_operations proc_slot_id = { + .open = hdpu_slot_id_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, + .owner = THIS_MODULE, +}; + +static const struct file_operations proc_chassis_id = { + .open = hdpu_chassis_id_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, + .owner = THIS_MODULE, +}; + static struct platform_driver hdpu_nexus_driver = { .probe = hdpu_nexus_probe, .remove = hdpu_nexus_remove, @@ -38,22 +58,26 @@ static struct platform_driver hdpu_nexus_driver = { }, }; -int hdpu_slot_id_read(char *buffer, char **buffer_location, off_t offset, - int buffer_length, int *zero, void *ptr) +static int hdpu_slot_id_open(struct inode *inode, struct file *file) { - if (offset > 0) - return 0; + return single_open(file, hdpu_slot_id_read, NULL); +} - return sprintf(buffer, "%d\n", slot_id); +static int hdpu_slot_id_read(struct seq_file *seq, void *offset) +{ + seq_printf(seq, "%d\n", slot_id); + return 0; } -int hdpu_chassis_id_read(char *buffer, char **buffer_location, off_t offset, - int buffer_length, int *zero, void *ptr) +static int hdpu_chassis_id_open(struct inode *inode, struct file *file) { - if (offset > 0) - return 0; + return single_open(file, hdpu_chassis_id_read, NULL); +} - return sprintf(buffer, "%d\n", chassis_id); +static int hdpu_chassis_id_read(struct seq_file *seq, void *offset) +{ + seq_printf(seq, "%d\n", chassis_id); + return 0; } static int hdpu_nexus_probe(struct platform_device *pdev) @@ -82,7 +106,8 @@ static int hdpu_nexus_probe(struct platform_device *pdev) printk(KERN_WARNING "sky_nexus: " "Unable to create proc dir entry: sky_slot_id\n"); } else { - hdpu_slot_id->read_proc = hdpu_slot_id_read; + hdpu_slot_id->proc_fops = &proc_slot_id; + hdpu_slot_id->owner = THIS_MODULE; } hdpu_chassis_id = create_proc_entry("sky_chassis_id", 0666, &proc_root); @@ -90,7 +115,8 @@ static int hdpu_nexus_probe(struct platform_device *pdev) printk(KERN_WARNING "sky_nexus: " "Unable to create proc dir entry: sky_chassis_id\n"); } else { - hdpu_chassis_id->read_proc = hdpu_chassis_id_read; + hdpu_chassis_id->proc_fops = &proc_chassis_id; + hdpu_chassis_id->owner = THIS_MODULE; } return 0; -- cgit v1.2.3