Pass the integer they show as the data of the entry and declare the show function, procfs then opens and frees the seq_file. That makes the open functions unnecessary.
Signed-off-by: Christian Brauner (Amutable) <[email protected]> --- drivers/scsi/sg.c | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-) diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index 3f9e08725602..c7386fbe5580 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c @@ -2287,26 +2287,18 @@ sg_get_dev(int dev) #ifdef CONFIG_SCSI_PROC_FS static int sg_proc_seq_show_int(struct seq_file *s, void *v); -static int sg_proc_single_open_adio(struct inode *inode, struct file *file); static ssize_t sg_proc_write_adio(struct file *filp, const char __user *buffer, size_t count, loff_t *off); static const struct proc_ops adio_proc_ops = { - .proc_open = sg_proc_single_open_adio, - .proc_read = seq_read, - .proc_lseek = seq_lseek, + .proc_show = sg_proc_seq_show_int, .proc_write = sg_proc_write_adio, - .proc_release = single_release, }; -static int sg_proc_single_open_dressz(struct inode *inode, struct file *file); static ssize_t sg_proc_write_dressz(struct file *filp, const char __user *buffer, size_t count, loff_t *off); static const struct proc_ops dressz_proc_ops = { - .proc_open = sg_proc_single_open_dressz, - .proc_read = seq_read, - .proc_lseek = seq_lseek, + .proc_show = sg_proc_seq_show_int, .proc_write = sg_proc_write_dressz, - .proc_release = single_release, }; static int sg_proc_seq_show_version(struct seq_file *s, void *v); @@ -2347,9 +2339,11 @@ sg_proc_init(void) if (!p) return 1; - proc_create("allow_dio", S_IRUGO | S_IWUSR, p, &adio_proc_ops); + proc_create_data("allow_dio", S_IRUGO | S_IWUSR, p, &adio_proc_ops, + &sg_allow_dio); proc_create_seq("debug", S_IRUGO, p, &debug_seq_ops); - proc_create("def_reserved_size", S_IRUGO | S_IWUSR, p, &dressz_proc_ops); + proc_create_data("def_reserved_size", S_IRUGO | S_IWUSR, p, + &dressz_proc_ops, &def_reserved_size); proc_create_single("device_hdr", S_IRUGO, p, sg_proc_seq_show_devhdr); proc_create_seq("devices", S_IRUGO, p, &dev_seq_ops); proc_create_seq("device_strs", S_IRUGO, p, &devstrs_seq_ops); @@ -2364,11 +2358,6 @@ static int sg_proc_seq_show_int(struct seq_file *s, void *v) return 0; } -static int sg_proc_single_open_adio(struct inode *inode, struct file *file) -{ - return single_open(file, sg_proc_seq_show_int, &sg_allow_dio); -} - static ssize_t sg_proc_write_adio(struct file *filp, const char __user *buffer, size_t count, loff_t *off) @@ -2385,11 +2374,6 @@ sg_proc_write_adio(struct file *filp, const char __user *buffer, return count; } -static int sg_proc_single_open_dressz(struct inode *inode, struct file *file) -{ - return single_open(file, sg_proc_seq_show_int, &def_reserved_size); -} - static ssize_t sg_proc_write_dressz(struct file *filp, const char __user *buffer, size_t count, loff_t *off) -- 2.53.0
