Whamcloud - gitweb
LU-5275 lprocfs: remove all non-seq file functions
[fs/lustre-release.git] / lustre / obdclass / lprocfs_jobstats.c
index c2eff71..930ca06 100644 (file)
@@ -19,7 +19,7 @@
  * GPL HEADER END
  */
 /*
- * Copyright (c) 2012, 2013, Intel Corporation.
+ * Copyright (c) 2012, 2014, Intel Corporation.
  * Use is subject to license terms.
  *
  * Author: Niu Yawei <niu@whamcloud.com>
@@ -35,7 +35,7 @@
 #include <lprocfs_status.h>
 #include <lustre/lustre_idl.h>
 
-#if defined(LPROCFS)
+#ifdef CONFIG_PROC_FS
 
 /*
  * JobID formats & JobID environment variable names for supported
@@ -404,7 +404,7 @@ static int lprocfs_jobstats_seq_show(struct seq_file *p, void *v)
        return 0;
 }
 
-struct seq_operations lprocfs_jobstats_seq_sops = {
+static const struct seq_operations lprocfs_jobstats_seq_sops = {
        start: lprocfs_jobstats_seq_start,
        stop:  lprocfs_jobstats_seq_stop,
        next:  lprocfs_jobstats_seq_next,
@@ -416,8 +416,9 @@ static int lprocfs_jobstats_seq_open(struct inode *inode, struct file *file)
        struct seq_file *seq;
        int rc;
 
-       if (LPROCFS_ENTRY_CHECK(PDE(inode)))
-               return -ENOENT;
+       rc = LPROCFS_ENTRY_CHECK(inode);
+       if (rc < 0)
+               return rc;
 
        rc = seq_open(file, &lprocfs_jobstats_seq_sops);
        if (rc)
@@ -472,7 +473,7 @@ static ssize_t lprocfs_jobstats_seq_write(struct file *file,
        return len;
 }
 
-struct file_operations lprocfs_jobstats_seq_fops = {
+static const struct file_operations lprocfs_jobstats_seq_fops = {
        .owner   = THIS_MODULE,
        .open    = lprocfs_jobstats_seq_open,
        .read    = seq_read,
@@ -517,11 +518,9 @@ int lprocfs_job_stats_init(struct obd_device *obd, int cntr_num,
        stats->ojs_cleanup_interval = 600; /* 10 mins by default */
        stats->ojs_last_cleanup = cfs_time_current_sec();
 
-       LPROCFS_WRITE_ENTRY();
-       entry = proc_create_data("job_stats", 0644, obd->obd_proc_entry,
-                               &lprocfs_jobstats_seq_fops, stats);
-       LPROCFS_WRITE_EXIT();
-       if (entry == NULL) {
+       entry = lprocfs_add_simple(obd->obd_proc_entry, "job_stats", stats,
+                                  &lprocfs_jobstats_seq_fops);
+       if (IS_ERR(entry)) {
                lprocfs_job_stats_fini(obd);
                RETURN(-ENOMEM);
        }
@@ -560,4 +559,4 @@ lprocfs_job_interval_seq_write(struct file *file, const char *buffer,
        return count;
 }
 EXPORT_SYMBOL(lprocfs_job_interval_seq_write);
-#endif /* LPROCFS*/
+#endif /* CONFIG_PROC_FS*/