ide: convert to ->proc_fops
PATCH 1/1 ide: convert to ->proc_fops
->read_proc, ->write_proc are going away, ->proc_fops should be used instead.
The only tricky place is IDENTIFY handling: if for some reason taskfile_lib_get_identify() fails, buffer _is_ changed and at least first byte is overwritten. Emulate old behaviour with returning that first byte to userspace and reporting length=1 despite overall -E.
---
drivers/ide/ide-cd.c | 28 ++- drivers/ide/ide-disk_proc.c | 129 ++++++++++------ drivers/ide/ide-floppy_proc.c | 30 ++- drivers/ide/ide-proc.c | 330 +++++++++++++++++++++++++++--------------- drivers/ide/ide-tape.c | 31 ++- include/linux/ide.h | 24 --- 6 files changed, 365 insertions(+), 207 deletions(-)
drivers/ide/ide-cd.c +20 -8
@@ -30,6 +30,7 @@#include <linux/kernel.h> #include <linux/delay.h> #include <linux/timer.h> +#include <linux/seq_file.h> #include <linux/slab.h> #include <linux/interrupt.h> #include <linux/errno.h>
@@ -1389,19 +1390,30 @@ static sector_t ide_cdrom_capacity(ide_drive_t *drive)return capacity * sectors_per_frame; } -static int proc_idecd_read_capacity (char *page,char **start,off_t off, -int count,int *eof,void *data) +static int idecd_capacity_proc_show (struct seq_file *m,void *v) { -ide_drive_t *drive = data; -int len; +ide_drive_t *drive = m->private; - len =sprintf (page,"%llu\n" , (long long )ide_cdrom_capacity (drive)); -PROC_IDE_READ_RETURN (page, start, off, count, eof, len); +seq_printf (m,"%llu\n" , (long long )ide_cdrom_capacity (drive)); +return 0 ; +} + +static int idecd_capacity_proc_open (struct inode *inode,struct file *file) +{ +return single_open (file, idecd_capacity_proc_show,PDE (inode)->data); } +static const struct file_operations idecd_capacity_proc_fops = { + .owner =THIS_MODULE , + .open = idecd_capacity_proc_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, +}; +static ide_proc_entry_t idecd_proc[] = { - {"capacity" ,S_IFREG |S_IRUGO , proc_idecd_read_capacity,NULL }, - {NULL ,0 ,NULL ,NULL } + {"capacity" ,S_IFREG |S_IRUGO , &idecd_capacity_proc_fops }, + {} };static ide_proc_entry_t *ide_cd_proc_entries (ide_drive_t *drive)
drivers/ide/ide-disk_proc.c +85 -44
167 lines not on this page · raw message
drivers/ide/ide-floppy_proc.c +21 -9
@@ -1,22 +1,34 @@#include <linux/kernel.h> #include <linux/ide.h> +#include <linux/seq_file.h> #include "ide-floppy.h" -static int proc_idefloppy_read_capacity (char *page,char **start,off_t off, -int count,int *eof,void *data) +static int idefloppy_capacity_proc_show (struct seq_file *m,void *v) { -ide_drive_t *drive = (ide_drive_t *)data; -int len; +ide_drive_t *drive = (ide_drive_t *)m->private; - len =sprintf (page,"%llu\n" , (long long )ide_gd_capacity (drive)); -PROC_IDE_READ_RETURN (page, start, off, count, eof, len); +seq_printf (m,"%llu\n" , (long long )ide_gd_capacity (drive)); +return 0 ; } +static int idefloppy_capacity_proc_open (struct inode *inode,struct file *file) +{ +return single_open (file, idefloppy_capacity_proc_show,PDE (inode)->data); +} + +static const struct file_operations idefloppy_capacity_proc_fops = { + .owner =THIS_MODULE , + .open = idefloppy_capacity_proc_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, +}; +ide_proc_entry_t ide_floppy_proc[] = { - {"capacity" ,S_IFREG |S_IRUGO , proc_idefloppy_read_capacity,NULL }, - {"geometry" ,S_IFREG |S_IRUGO , proc_ide_read_geometry,NULL }, - {NULL ,0 ,NULL ,NULL } + {"capacity" ,S_IFREG |S_IRUGO , &idefloppy_capacity_proc_fops }, + {"geometry" ,S_IFREG |S_IRUGO , &ide_geometry_proc_fops }, + {} };ide_devset_rw_field (bios_cyl, bios_cyl);
drivers/ide/ide-proc.c +215 -115
468 lines not on this page · raw message
drivers/ide/ide-tape.c +21 -10
@@ -31,6 +31,7 @@#include <linux/major.h> #include <linux/errno.h> #include <linux/genhd.h> +#include <linux/seq_file.h> #include <linux/slab.h> #include <linux/pci.h> #include <linux/ide.h>
@@ -1833,22 +1834,32 @@ static void ide_tape_release(struct device *dev) }#ifdef CONFIG_IDE_PROC_FS -static int proc_idetape_read_name - (char *page,char **start,off_t off,int count,int *eof,void *data) +static int idetape_name_proc_show (struct seq_file *m,void *v) { -ide_drive_t *drive = (ide_drive_t *) data; +ide_drive_t *drive = (ide_drive_t *) m->private;idetape_tape_t *tape = drive->driver_data; -char *out = page; -int len; - len =sprintf (out,"%s\n" , tape->name); -PROC_IDE_READ_RETURN (page, start, off, count, eof, len); +seq_printf (m,"%s\n" , tape->name); +return 0 ; +} + +static int idetape_name_proc_open (struct inode *inode,struct file *file) +{ +return single_open (file, idetape_name_proc_show,PDE (inode)->data); } +static const struct file_operations idetape_name_proc_fops = { + .owner =THIS_MODULE , + .open = idetape_name_proc_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, +}; +static ide_proc_entry_t idetape_proc[] = { - {"capacity" ,S_IFREG |S_IRUGO , proc_ide_read_capacity,NULL }, - {"name" ,S_IFREG |S_IRUGO , proc_idetape_read_name,NULL }, - {NULL ,0 ,NULL ,NULL } + {"capacity" ,S_IFREG |S_IRUGO , &ide_capacity_proc_fops }, + {"name" ,S_IFREG |S_IRUGO , &idetape_name_proc_fops }, + {} };static ide_proc_entry_t *ide_tape_proc_entries (ide_drive_t *drive)
include/linux/ide.h +3 -21
@@ -918,8 +918,7 @@ __IDE_PROC_DEVSET(_name, _min, _max, NULL, NULL)typedef struct {const char *name;mode_t mode; -read_proc_t *read_proc; -write_proc_t *write_proc; +const struct file_operations *proc_fops; }ide_proc_entry_t ;void proc_ide_create (void );
@@ -931,24 +930,8 @@ void ide_proc_unregister_port(ide_hwif_t *);void ide_proc_register_driver (ide_drive_t *,struct ide_driver *);void ide_proc_unregister_driver (ide_drive_t *,struct ide_driver *); -read_proc_t proc_ide_read_capacity; -read_proc_t proc_ide_read_geometry; - -/* -* Standard exit stuff: -*/ -#define PROC_IDE_READ_RETURN (page,start,off,count,eof,len) \ -{ \ - len -= off; \ - if (len < count) { \ - *eof = 1; \ - if (len <= 0) \ - return 0; \ - } else \ - len = count; \ - *start = page + off; \ - return len; \ -} +extern const struct file_operations ide_capacity_proc_fops; +extern const struct file_operations ide_geometry_proc_fops;#else static inline void proc_ide_create (void ) { ; }static inline void proc_ide_destroy (void ) { ; }
@@ -960,7 +943,6 @@ static inline void ide_proc_register_driver(ide_drive_t *drive, struct ide_driver *driver) { ; }static inline void ide_proc_unregister_driver (ide_drive_t *drive,struct ide_driver *driver) { ; } -#define PROC_IDE_READ_RETURN (page,start,off,count,eof,len) return 0;#endif enum {
David Miller
AppliedFrom: Alexey Dobriyan <[email protected]>
Date: Tue, 1 Sep 2009 02:27:13 +0400
Quoted 8 lines
->read_proc, ->write_proc are going away, ->proc_fops should be used instead.
The only tricky place is IDENTIFY handling: if for some reason
taskfile_lib_get_identify()fails, buffer _is_ changed and at least first byte is overwritten. Emulate old behaviour with returning that first byte to userspace and reporting length=1 despite overall -E.Signed-off-by Alexey Dobriyan <[email protected]>
Applied, thanks.