genrtc: Don't use create_proc_read_entry()
authorDavid Howells <dhowells@redhat.com>
Wed, 10 Apr 2013 15:11:53 +0000 (16:11 +0100)
committerAl Viro <viro@zeniv.linux.org.uk>
Mon, 29 Apr 2013 19:41:54 +0000 (15:41 -0400)
Don't use create_proc_read_entry() as that is deprecated, but rather use
proc_create_data() and seq_file instead.

Signed-off-by: David Howells <dhowells@redhat.com>
cc: Arnd Bergmann <arnd@arndb.de>
cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
drivers/char/genrtc.c

index 21cb980f115782a2e80c4f46c442585f75ca806d..bc9b84d56ee4aed6f8e83ede52039f6f5ffa0def 100644 (file)
@@ -52,6 +52,7 @@
 #include <linux/init.h>
 #include <linux/poll.h>
 #include <linux/proc_fs.h>
+#include <linux/seq_file.h>
 #include <linux/mutex.h>
 #include <linux/workqueue.h>
 
@@ -386,18 +387,15 @@ static int gen_rtc_release(struct inode *inode, struct file *file)
  *     Info exported via "/proc/driver/rtc".
  */
 
-static int gen_rtc_proc_output(char *buf)
+static int gen_rtc_proc_show(struct seq_file *m, void *v)
 {
-       char *p;
        struct rtc_time tm;
        unsigned int flags;
        struct rtc_pll_info pll;
 
-       p = buf;
-
        flags = get_rtc_time(&tm);
 
-       p += sprintf(p,
+       seq_printf(m,
                     "rtc_time\t: %02d:%02d:%02d\n"
                     "rtc_date\t: %04d-%02d-%02d\n"
                     "rtc_epoch\t: %04u\n",
@@ -406,23 +404,23 @@ static int gen_rtc_proc_output(char *buf)
 
        tm.tm_hour = tm.tm_min = tm.tm_sec = 0;
 
-       p += sprintf(p, "alarm\t\t: ");
+       seq_puts(m, "alarm\t\t: ");
        if (tm.tm_hour <= 24)
-               p += sprintf(p, "%02d:", tm.tm_hour);
+               seq_printf(m, "%02d:", tm.tm_hour);
        else
-               p += sprintf(p, "**:");
+               seq_puts(m, "**:");
 
        if (tm.tm_min <= 59)
-               p += sprintf(p, "%02d:", tm.tm_min);
+               seq_printf(m, "%02d:", tm.tm_min);
        else
-               p += sprintf(p, "**:");
+               seq_puts(m, "**:");
 
        if (tm.tm_sec <= 59)
-               p += sprintf(p, "%02d\n", tm.tm_sec);
+               seq_printf(m, "%02d\n", tm.tm_sec);
        else
-               p += sprintf(p, "**\n");
+               seq_puts(m, "**\n");
 
-       p += sprintf(p,
+       seq_printf(m,
                     "DST_enable\t: %s\n"
                     "BCD\t\t: %s\n"
                     "24hr\t\t: %s\n"
@@ -442,7 +440,7 @@ static int gen_rtc_proc_output(char *buf)
                     0L /* freq */,
                     (flags & RTC_BATT_BAD) ? "bad" : "okay");
        if (!get_rtc_pll(&pll))
-           p += sprintf(p,
+           seq_printf(m,
                         "PLL adjustment\t: %d\n"
                         "PLL max +ve adjustment\t: %d\n"
                         "PLL max -ve adjustment\t: %d\n"
@@ -455,26 +453,26 @@ static int gen_rtc_proc_output(char *buf)
                         pll.pll_posmult,
                         pll.pll_negmult,
                         pll.pll_clock);
-       return p - buf;
+       return 0;
 }
 
-static int gen_rtc_read_proc(char *page, char **start, off_t off,
-                            int count, int *eof, void *data)
+static int gen_rtc_proc_open(struct inode *inode, struct file *file)
 {
-       int len = gen_rtc_proc_output (page);
-        if (len <= off+count) *eof = 1;
-       *start = page + off;
-       len -= off;
-        if (len>count) len = count;
-        if (len<0) len = 0;
-       return len;
+       return single_open(file, gen_rtc_proc_show, NULL);
 }
 
+static const struct file_operations gen_rtc_proc_fops = {
+       .open           = gen_rtc_proc_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = seq_release,
+};
+
 static int __init gen_rtc_proc_init(void)
 {
        struct proc_dir_entry *r;
 
-       r = create_proc_read_entry("driver/rtc", 0, NULL, gen_rtc_read_proc, NULL);
+       r = proc_create("driver/rtc", 0, NULL, &gen_rtc_proc_fops);
        if (!r)
                return -ENOMEM;
        return 0;