Declare the show function and let procfs open and free the seq_file.
->proc_open() only sets up the private data and preallocates the buffer
now and ->proc_release() no longer releases the seq_file. Reading an
entry then no longer holds up its removal when the card goes away.
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
---
sound/core/info.c | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)
diff --git a/sound/core/info.c b/sound/core/info.c
index 982087bc8575..8f905f398a0d 100644
--- a/sound/core/info.c
+++ b/sound/core/info.c
@@ -346,9 +346,11 @@ static int snd_info_seq_show(struct seq_file *seq, void *p)
return 0;
}
+/* procfs opens the seq_file */
static int snd_info_text_entry_open(struct inode *inode, struct file *file)
{
struct snd_info_entry *entry = pde_data(inode);
+ struct seq_file *m = file->private_data;
struct snd_info_private_data *data;
int err;
@@ -362,13 +364,12 @@ static int snd_info_text_entry_open(struct inode *inode, struct file *file)
err = -ENOMEM;
goto error;
}
- if (entry->size)
- err = single_open_size(file, snd_info_seq_show, data,
- entry->size);
- else
- err = single_open(file, snd_info_seq_show, data);
- if (err < 0)
- goto error;
+ if (entry->size) {
+ err = seq_preallocate(m, entry->size);
+ if (err < 0)
+ goto error;
+ }
+ m->private = data;
return 0;
error:@@ -387,7 +388,6 @@ static int snd_info_text_entry_release(struct inode *inode, struct file *file)
if (data->wbuffer && entry->c.text.write)
entry->c.text.write(entry, data->wbuffer);
- single_release(inode, file);
kfree(data->rbuffer);
if (data->wbuffer) {
kvfree(data->wbuffer->buffer);@@ -401,11 +401,10 @@ static int snd_info_text_entry_release(struct inode *inode, struct file *file)
static const struct proc_ops snd_info_text_entry_ops =
{
+ .proc_show = snd_info_seq_show,
.proc_open = snd_info_text_entry_open,
.proc_release = snd_info_text_entry_release,
.proc_write = snd_info_text_entry_write,
- .proc_lseek = seq_lseek,
- .proc_read = seq_read,
};
static struct snd_info_entry *create_subdir(struct module *mod,
--
2.53.0