@@ -152,27 +152,21 @@ static const struct seq_operations allocinfo_seq_op = {
};
/*
- * Initializes seq_file operations and allocates private state when opening
- * the /proc/allocinfo procfs entry.
+ * Initializes the private state when opening the /proc/allocinfo procfs
+ * entry. procfs opened the seq_file and allocated the state.
*/
static int allocinfo_open(struct inode *inode, struct file *file)
{
- int ret;
-
- ret = seq_open_private(file, &allocinfo_seq_op,
- sizeof(struct allocinfo_private));
- if (!ret) {
- struct seq_file *m = file->private_data;
- struct allocinfo_private *priv = m->private;
+ struct seq_file *m = file->private_data;
+ struct allocinfo_private *priv = m->private;
- mutex_init(&priv->ioctl_lock);
- }
- return ret;
+ mutex_init(&priv->ioctl_lock);
+ return 0;
}
/*
- * Cleans up the seq_file state and frees up the private state allocated in
- * allocinfo_open() when closing the /proc/allocinfo file descriptor.
+ * Undoes allocinfo_open() when closing the /proc/allocinfo file descriptor.
+ * procfs frees the seq_file and the private state.
*/
static int allocinfo_release(struct inode *inode, struct file *file)
{
@@ -180,7 +174,7 @@ static int allocinfo_release(struct inode *inode, struct file *file)
struct allocinfo_private *priv = m->private;
mutex_destroy(&priv->ioctl_lock);
- return seq_release_private(inode, file);
+ return 0;
}
/*
@@ -475,9 +469,9 @@ static long allocinfo_compat_ioctl(struct file *file, unsigned int cmd,
#endif
static const struct proc_ops allocinfo_proc_ops = {
+ .proc_seq_ops = &allocinfo_seq_op,
+ .proc_state_size = sizeof(struct allocinfo_private),
.proc_open = allocinfo_open,
- .proc_read_iter = seq_read_iter,
- .proc_lseek = seq_lseek,
.proc_release = allocinfo_release,
.proc_ioctl = allocinfo_ioctl,
#ifdef CONFIG_COMPAT
Declare the seq_operations and the size of the private state and let procfs open and free the seq_file. ->proc_open() and ->proc_release() only set up and destroy the ioctl lock now. Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org> --- mm/alloc_tag.c | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-)