Whamcloud - gitweb
LU-5275 lprocfs: reduce scope of params_tree.h
[fs/lustre-release.git] / lustre / obdclass / lprocfs_status.c
index b469fad..259b79c 100644 (file)
@@ -27,7 +27,7 @@
  * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2011, 2013, Intel Corporation.
+ * Copyright (c) 2011, 2014, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -124,26 +124,29 @@ static const struct file_operations lprocfs_generic_fops = { };
 ssize_t
 lprocfs_fops_read(struct file *f, char __user *buf, size_t size, loff_t *ppos)
 {
-        struct proc_dir_entry *dp = PDE(f->f_dentry->d_inode);
-        char *page, *start = NULL;
-        int rc = 0, eof = 1, count;
+       struct inode *inode = f->f_dentry->d_inode;
+       struct proc_dir_entry *dp = PDE(inode);
+       char *page, *start = NULL;
+       int rc, eof = 1, count;
 
        if (*ppos >= PAGE_CACHE_SIZE)
-                return 0;
+               return 0;
 
-        page = (char *)__get_free_page(GFP_KERNEL);
-        if (page == NULL)
-                return -ENOMEM;
+       page = (char *)__get_free_page(GFP_KERNEL);
+       if (page == NULL)
+               return -ENOMEM;
 
-       if (LPROCFS_ENTRY_CHECK(dp)) {
-                rc = -ENOENT;
-                goto out;
-        }
+       rc = LPROCFS_ENTRY_CHECK(inode);
+       if (rc < 0)
+               goto out;
 
-        OBD_FAIL_TIMEOUT(OBD_FAIL_LPROC_REMOVE, 10);
-        if (dp->read_proc)
+       OBD_FAIL_TIMEOUT(OBD_FAIL_LPROC_REMOVE, 10);
+       if (dp->read_proc != NULL)
                rc = dp->read_proc(page, &start, *ppos, PAGE_CACHE_SIZE,
-                                   &eof, dp->data);
+                                  &eof, dp->data);
+       else
+               rc = 0;
+
         if (rc <= 0)
                 goto out;
 
@@ -177,14 +180,20 @@ ssize_t
 lprocfs_fops_write(struct file *f, const char __user *buf, size_t size,
                   loff_t *ppos)
 {
-        struct proc_dir_entry *dp = PDE(f->f_dentry->d_inode);
-        int rc = -EIO;
+       struct inode *inode = f->f_dentry->d_inode;
+       struct proc_dir_entry *dp = PDE(inode);
+       int rc;
 
-       if (LPROCFS_ENTRY_CHECK(dp))
-                return -ENOENT;
-        if (dp->write_proc)
-                rc = dp->write_proc(f, buf, size, dp->data);
-        return rc;
+       rc = LPROCFS_ENTRY_CHECK(inode);
+       if (rc < 0)
+               return rc;
+
+       if (dp->write_proc != NULL)
+               rc = dp->write_proc(f, buf, size, dp->data);
+       else
+               rc = -EIO;
+
+       return rc;
 }
 
 static struct file_operations lprocfs_generic_fops = {
@@ -358,7 +367,7 @@ lprocfs_seq_add_vars(struct proc_dir_entry *root, struct lprocfs_seq_vars *list,
 EXPORT_SYMBOL(lprocfs_seq_add_vars);
 
 #ifndef HAVE_ONLY_PROCFS_SEQ
-void lprocfs_remove_nolock(struct proc_dir_entry **proot)
+static void lprocfs_remove_nolock(struct proc_dir_entry **proot)
 {
        struct proc_dir_entry *root = *proot;
        struct proc_dir_entry *temp = root;
@@ -1466,7 +1475,7 @@ out:
        return (rc < 0) ? rc : 0;
 }
 
-struct seq_operations lprocfs_stats_seq_sops = {
+static const struct seq_operations lprocfs_stats_seq_sops = {
        .start  = lprocfs_stats_seq_start,
        .stop   = lprocfs_stats_seq_stop,
        .next   = lprocfs_stats_seq_next,
@@ -1478,10 +1487,10 @@ static int lprocfs_stats_seq_open(struct inode *inode, struct file *file)
        struct seq_file *seq;
        int rc;
 
-#ifndef HAVE_ONLY_PROCFS_SEQ
-       if (LPROCFS_ENTRY_CHECK(PDE(inode)))
-               return -ENOENT;
-#endif
+       rc = LPROCFS_ENTRY_CHECK(inode);
+       if (rc < 0)
+               return rc;
+
        rc = seq_open(file, &lprocfs_stats_seq_sops);
        if (rc)
                return rc;
@@ -1490,7 +1499,7 @@ static int lprocfs_stats_seq_open(struct inode *inode, struct file *file)
        return 0;
 }
 
-struct file_operations lprocfs_stats_seq_fops = {
+static const struct file_operations lprocfs_stats_seq_fops = {
         .owner   = THIS_MODULE,
         .open    = lprocfs_stats_seq_open,
         .read    = seq_read,