Commit 8f9ac032 authored by Rob Jones's avatar Rob Jones Committed by Linus Torvalds

fs/ocfs2/dlm/dlmdebug.c: use seq_open_private() not seq_open()

Reduce boilerplate code by using seq_open_private() instead of seq_open()
Signed-off-by: default avatarRob Jones <rob.jones@codethink.co.uk>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Mark Fasheh <mfasheh@suse.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 6ae07548
...@@ -647,41 +647,30 @@ static const struct seq_operations debug_lockres_ops = { ...@@ -647,41 +647,30 @@ static const struct seq_operations debug_lockres_ops = {
static int debug_lockres_open(struct inode *inode, struct file *file) static int debug_lockres_open(struct inode *inode, struct file *file)
{ {
struct dlm_ctxt *dlm = inode->i_private; struct dlm_ctxt *dlm = inode->i_private;
int ret = -ENOMEM; struct debug_lockres *dl;
struct seq_file *seq; void *buf;
struct debug_lockres *dl = NULL;
dl = kzalloc(sizeof(struct debug_lockres), GFP_KERNEL); buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
if (!dl) { if (!buf)
mlog_errno(ret);
goto bail; goto bail;
}
dl->dl_len = PAGE_SIZE; dl = __seq_open_private(file, &debug_lockres_ops, sizeof(*dl));
dl->dl_buf = kmalloc(dl->dl_len, GFP_KERNEL); if (!dl)
if (!dl->dl_buf) { goto bailfree;
mlog_errno(ret);
goto bail;
}
ret = seq_open(file, &debug_lockres_ops); dl->dl_len = PAGE_SIZE;
if (ret) { dl->dl_buf = buf;
mlog_errno(ret);
goto bail;
}
seq = file->private_data;
seq->private = dl;
dlm_grab(dlm); dlm_grab(dlm);
dl->dl_ctxt = dlm; dl->dl_ctxt = dlm;
return 0; return 0;
bailfree:
kfree(buf);
bail: bail:
if (dl) mlog_errno(-ENOMEM);
kfree(dl->dl_buf); return -ENOMEM;
kfree(dl);
return ret;
} }
static int debug_lockres_release(struct inode *inode, struct file *file) static int debug_lockres_release(struct inode *inode, struct file *file)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment