aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorRob Jones <rob.jones@codethink.co.uk>2014-10-09 18:25:05 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-10-09 22:25:47 -0400
commit8f9ac032322b855ff9f578efcb5de891dcf85e9b (patch)
tree770737a8f777c615f86c36f934b73911603c3988 /fs
parent6ae075485e2d91921bdd64e49896b1bae87d1ba2 (diff)
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: Rob Jones <rob.jones@codethink.co.uk> Cc: Joel Becker <jlbec@evilplan.org> Cc: Mark Fasheh <mfasheh@suse.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/ocfs2/dlm/dlmdebug.c39
1 files changed, 14 insertions, 25 deletions
diff --git a/fs/ocfs2/dlm/dlmdebug.c b/fs/ocfs2/dlm/dlmdebug.c
index 18f13c2e4a10..149eb556b8c6 100644
--- a/fs/ocfs2/dlm/dlmdebug.c
+++ b/fs/ocfs2/dlm/dlmdebug.c
@@ -647,41 +647,30 @@ static const struct seq_operations debug_lockres_ops = {
647static int debug_lockres_open(struct inode *inode, struct file *file) 647static int debug_lockres_open(struct inode *inode, struct file *file)
648{ 648{
649 struct dlm_ctxt *dlm = inode->i_private; 649 struct dlm_ctxt *dlm = inode->i_private;
650 int ret = -ENOMEM; 650 struct debug_lockres *dl;
651 struct seq_file *seq; 651 void *buf;
652 struct debug_lockres *dl = NULL;
653 652
654 dl = kzalloc(sizeof(struct debug_lockres), GFP_KERNEL); 653 buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
655 if (!dl) { 654 if (!buf)
656 mlog_errno(ret);
657 goto bail; 655 goto bail;
658 }
659 656
660 dl->dl_len = PAGE_SIZE; 657 dl = __seq_open_private(file, &debug_lockres_ops, sizeof(*dl));
661 dl->dl_buf = kmalloc(dl->dl_len, GFP_KERNEL); 658 if (!dl)
662 if (!dl->dl_buf) { 659 goto bailfree;
663 mlog_errno(ret);
664 goto bail;
665 }
666 660
667 ret = seq_open(file, &debug_lockres_ops); 661 dl->dl_len = PAGE_SIZE;
668 if (ret) { 662 dl->dl_buf = buf;
669 mlog_errno(ret);
670 goto bail;
671 }
672
673 seq = file->private_data;
674 seq->private = dl;
675 663
676 dlm_grab(dlm); 664 dlm_grab(dlm);
677 dl->dl_ctxt = dlm; 665 dl->dl_ctxt = dlm;
678 666
679 return 0; 667 return 0;
668
669bailfree:
670 kfree(buf);
680bail: 671bail:
681 if (dl) 672 mlog_errno(-ENOMEM);
682 kfree(dl->dl_buf); 673 return -ENOMEM;
683 kfree(dl);
684 return ret;
685} 674}
686 675
687static int debug_lockres_release(struct inode *inode, struct file *file) 676static int debug_lockres_release(struct inode *inode, struct file *file)