aboutsummaryrefslogtreecommitdiffstats
path: root/fs/proc
diff options
context:
space:
mode:
authorOleg Nesterov <oleg@redhat.com>2014-10-09 18:25:21 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-10-09 22:25:48 -0400
commit4db7d0ee198d417f4144c58048fcb173d90096ea (patch)
treeae5739057a1eb8d65d5b24ad7c5b8af87a548fa0 /fs/proc
parent46c298cf69d0e9a27d33ff992a81bd7b441c7933 (diff)
fs/proc/task_mmu.c: unify/simplify do_maps_open() and numa_maps_open()
do_maps_open() and numa_maps_open() are overcomplicated, they could use __seq_open_private(). Plus they do the same, just sizeof(*priv) Change them to use a new simple helper, proc_maps_open(ops, psize). This simplifies the code and allows us to do the next changes. Signed-off-by: Oleg Nesterov <oleg@redhat.com> Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Acked-by: Cyrill Gorcunov <gorcunov@openvz.org> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/proc')
-rw-r--r--fs/proc/task_mmu.c44
1 files changed, 16 insertions, 28 deletions
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index 289dfdc0ec09..4d716a09d500 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -231,23 +231,23 @@ static void m_stop(struct seq_file *m, void *v)
231 put_task_struct(priv->task); 231 put_task_struct(priv->task);
232} 232}
233 233
234static int proc_maps_open(struct inode *inode, struct file *file,
235 const struct seq_operations *ops, int psize)
236{
237 struct proc_maps_private *priv = __seq_open_private(file, ops, psize);
238
239 if (!priv)
240 return -ENOMEM;
241
242 priv->pid = proc_pid(inode);
243 return 0;
244}
245
234static int do_maps_open(struct inode *inode, struct file *file, 246static int do_maps_open(struct inode *inode, struct file *file,
235 const struct seq_operations *ops) 247 const struct seq_operations *ops)
236{ 248{
237 struct proc_maps_private *priv; 249 return proc_maps_open(inode, file, ops,
238 int ret = -ENOMEM; 250 sizeof(struct proc_maps_private));
239 priv = kzalloc(sizeof(*priv), GFP_KERNEL);
240 if (priv) {
241 priv->pid = proc_pid(inode);
242 ret = seq_open(file, ops);
243 if (!ret) {
244 struct seq_file *m = file->private_data;
245 m->private = priv;
246 } else {
247 kfree(priv);
248 }
249 }
250 return ret;
251} 251}
252 252
253static void 253static void
@@ -1526,20 +1526,8 @@ static const struct seq_operations proc_tid_numa_maps_op = {
1526static int numa_maps_open(struct inode *inode, struct file *file, 1526static int numa_maps_open(struct inode *inode, struct file *file,
1527 const struct seq_operations *ops) 1527 const struct seq_operations *ops)
1528{ 1528{
1529 struct numa_maps_private *priv; 1529 return proc_maps_open(inode, file, ops,
1530 int ret = -ENOMEM; 1530 sizeof(struct numa_maps_private));
1531 priv = kzalloc(sizeof(*priv), GFP_KERNEL);
1532 if (priv) {
1533 priv->proc_maps.pid = proc_pid(inode);
1534 ret = seq_open(file, ops);
1535 if (!ret) {
1536 struct seq_file *m = file->private_data;
1537 m->private = priv;
1538 } else {
1539 kfree(priv);
1540 }
1541 }
1542 return ret;
1543} 1531}
1544 1532
1545static int pid_numa_maps_open(struct inode *inode, struct file *file) 1533static int pid_numa_maps_open(struct inode *inode, struct file *file)