Revert "net: activity_stats: Stop using obsolete create_proc_read_entry api"
authorAmit Pundir <amit.pundir@linaro.org>
Mon, 25 Apr 2016 11:30:57 +0000 (17:00 +0530)
committerAmit Pundir <amit.pundir@linaro.org>
Mon, 25 Apr 2016 16:49:46 +0000 (22:19 +0530)
This reverts commit 7c121720fa14889d59e933aad0a8b9ce948a39ae.

Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
net/activity_stats.c

index 4609ce2043eb3677905b5ad5decc803e9cd40b7b..8a3e93470069cf0e6ebfab76bc5acfe631878974 100644 (file)
@@ -15,7 +15,6 @@
  */
 
 #include <linux/proc_fs.h>
-#include <linux/seq_file.h>
 #include <linux/suspend.h>
 #include <net/net_namespace.h>
 
@@ -60,20 +59,29 @@ void activity_stats_update(void)
        spin_unlock_irqrestore(&activity_lock, flags);
 }
 
-static int activity_stats_show(struct seq_file *m, void *v)
+static int activity_stats_read_proc(char *page, char **start, off_t off,
+                                       int count, int *eof, void *data)
 {
        int i;
-       int ret;
+       int len;
+       char *p = page;
 
-       seq_printf(m, "Min Bucket(sec) Count\n");
+       /* Only print if offset is 0, or we have enough buffer space */
+       if (off || count < (30 * BUCKET_MAX + 22))
+               return -ENOMEM;
+
+       len = snprintf(p, count, "Min Bucket(sec) Count\n");
+       count -= len;
+       p += len;
 
        for (i = 0; i < BUCKET_MAX; i++) {
-               ret = seq_printf(m, "%15d %lu\n", 1 << i, activity_stats[i]);
-               if (ret)
-                       return ret;
+               len = snprintf(p, count, "%15d %lu\n", 1 << i, activity_stats[i]);
+               count -= len;
+               p += len;
        }
+       *eof = 1;
 
-       return 0;
+       return p - page;
 }
 
 static int activity_stats_notifier(struct notifier_block *nb,
@@ -92,26 +100,14 @@ static int activity_stats_notifier(struct notifier_block *nb,
        return 0;
 }
 
-static int activity_stats_open(struct inode *inode, struct file *file)
-{
-       return single_open(file, activity_stats_show, PDE_DATA(inode));
-}
-
-static const struct file_operations activity_stats_fops = {
-       .open           = activity_stats_open,
-       .read           = seq_read,
-       .llseek         = seq_lseek,
-       .release        = seq_release,
-};
-
 static struct notifier_block activity_stats_notifier_block = {
        .notifier_call = activity_stats_notifier,
 };
 
 static int  __init activity_stats_init(void)
 {
-       proc_create("activity", S_IRUGO,
-                   init_net.proc_net_stat, &activity_stats_fops);
+       create_proc_read_entry("activity", S_IRUGO,
+                       init_net.proc_net_stat, activity_stats_read_proc, NULL);
        return register_pm_notifier(&activity_stats_notifier_block);
 }