diff options
author | David Howells <dhowells@redhat.com> | 2013-04-10 11:11:53 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2013-04-29 15:41:54 -0400 |
commit | a6d935a5b1d945c7bec2afe21dcf6f22b653acef (patch) | |
tree | 2ca003ee55ebf7dabbeeffbabcb637b50ac3393c /drivers/char | |
parent | c18bd9a1ff477bd010d7607a8e575da24de0b08b (diff) |
genrtc: Don't use create_proc_read_entry()
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>
Diffstat (limited to 'drivers/char')
-rw-r--r-- | drivers/char/genrtc.c | 48 |
1 files changed, 23 insertions, 25 deletions
diff --git a/drivers/char/genrtc.c b/drivers/char/genrtc.c index 21cb980f1157..bc9b84d56ee4 100644 --- a/drivers/char/genrtc.c +++ b/drivers/char/genrtc.c | |||
@@ -52,6 +52,7 @@ | |||
52 | #include <linux/init.h> | 52 | #include <linux/init.h> |
53 | #include <linux/poll.h> | 53 | #include <linux/poll.h> |
54 | #include <linux/proc_fs.h> | 54 | #include <linux/proc_fs.h> |
55 | #include <linux/seq_file.h> | ||
55 | #include <linux/mutex.h> | 56 | #include <linux/mutex.h> |
56 | #include <linux/workqueue.h> | 57 | #include <linux/workqueue.h> |
57 | 58 | ||
@@ -386,18 +387,15 @@ static int gen_rtc_release(struct inode *inode, struct file *file) | |||
386 | * Info exported via "/proc/driver/rtc". | 387 | * Info exported via "/proc/driver/rtc". |
387 | */ | 388 | */ |
388 | 389 | ||
389 | static int gen_rtc_proc_output(char *buf) | 390 | static int gen_rtc_proc_show(struct seq_file *m, void *v) |
390 | { | 391 | { |
391 | char *p; | ||
392 | struct rtc_time tm; | 392 | struct rtc_time tm; |
393 | unsigned int flags; | 393 | unsigned int flags; |
394 | struct rtc_pll_info pll; | 394 | struct rtc_pll_info pll; |
395 | 395 | ||
396 | p = buf; | ||
397 | |||
398 | flags = get_rtc_time(&tm); | 396 | flags = get_rtc_time(&tm); |
399 | 397 | ||
400 | p += sprintf(p, | 398 | seq_printf(m, |
401 | "rtc_time\t: %02d:%02d:%02d\n" | 399 | "rtc_time\t: %02d:%02d:%02d\n" |
402 | "rtc_date\t: %04d-%02d-%02d\n" | 400 | "rtc_date\t: %04d-%02d-%02d\n" |
403 | "rtc_epoch\t: %04u\n", | 401 | "rtc_epoch\t: %04u\n", |
@@ -406,23 +404,23 @@ static int gen_rtc_proc_output(char *buf) | |||
406 | 404 | ||
407 | tm.tm_hour = tm.tm_min = tm.tm_sec = 0; | 405 | tm.tm_hour = tm.tm_min = tm.tm_sec = 0; |
408 | 406 | ||
409 | p += sprintf(p, "alarm\t\t: "); | 407 | seq_puts(m, "alarm\t\t: "); |
410 | if (tm.tm_hour <= 24) | 408 | if (tm.tm_hour <= 24) |
411 | p += sprintf(p, "%02d:", tm.tm_hour); | 409 | seq_printf(m, "%02d:", tm.tm_hour); |
412 | else | 410 | else |
413 | p += sprintf(p, "**:"); | 411 | seq_puts(m, "**:"); |
414 | 412 | ||
415 | if (tm.tm_min <= 59) | 413 | if (tm.tm_min <= 59) |
416 | p += sprintf(p, "%02d:", tm.tm_min); | 414 | seq_printf(m, "%02d:", tm.tm_min); |
417 | else | 415 | else |
418 | p += sprintf(p, "**:"); | 416 | seq_puts(m, "**:"); |
419 | 417 | ||
420 | if (tm.tm_sec <= 59) | 418 | if (tm.tm_sec <= 59) |
421 | p += sprintf(p, "%02d\n", tm.tm_sec); | 419 | seq_printf(m, "%02d\n", tm.tm_sec); |
422 | else | 420 | else |
423 | p += sprintf(p, "**\n"); | 421 | seq_puts(m, "**\n"); |
424 | 422 | ||
425 | p += sprintf(p, | 423 | seq_printf(m, |
426 | "DST_enable\t: %s\n" | 424 | "DST_enable\t: %s\n" |
427 | "BCD\t\t: %s\n" | 425 | "BCD\t\t: %s\n" |
428 | "24hr\t\t: %s\n" | 426 | "24hr\t\t: %s\n" |
@@ -442,7 +440,7 @@ static int gen_rtc_proc_output(char *buf) | |||
442 | 0L /* freq */, | 440 | 0L /* freq */, |
443 | (flags & RTC_BATT_BAD) ? "bad" : "okay"); | 441 | (flags & RTC_BATT_BAD) ? "bad" : "okay"); |
444 | if (!get_rtc_pll(&pll)) | 442 | if (!get_rtc_pll(&pll)) |
445 | p += sprintf(p, | 443 | seq_printf(m, |
446 | "PLL adjustment\t: %d\n" | 444 | "PLL adjustment\t: %d\n" |
447 | "PLL max +ve adjustment\t: %d\n" | 445 | "PLL max +ve adjustment\t: %d\n" |
448 | "PLL max -ve adjustment\t: %d\n" | 446 | "PLL max -ve adjustment\t: %d\n" |
@@ -455,26 +453,26 @@ static int gen_rtc_proc_output(char *buf) | |||
455 | pll.pll_posmult, | 453 | pll.pll_posmult, |
456 | pll.pll_negmult, | 454 | pll.pll_negmult, |
457 | pll.pll_clock); | 455 | pll.pll_clock); |
458 | return p - buf; | 456 | return 0; |
459 | } | 457 | } |
460 | 458 | ||
461 | static int gen_rtc_read_proc(char *page, char **start, off_t off, | 459 | static int gen_rtc_proc_open(struct inode *inode, struct file *file) |
462 | int count, int *eof, void *data) | ||
463 | { | 460 | { |
464 | int len = gen_rtc_proc_output (page); | 461 | return single_open(file, gen_rtc_proc_show, NULL); |
465 | if (len <= off+count) *eof = 1; | ||
466 | *start = page + off; | ||
467 | len -= off; | ||
468 | if (len>count) len = count; | ||
469 | if (len<0) len = 0; | ||
470 | return len; | ||
471 | } | 462 | } |
472 | 463 | ||
464 | static const struct file_operations gen_rtc_proc_fops = { | ||
465 | .open = gen_rtc_proc_open, | ||
466 | .read = seq_read, | ||
467 | .llseek = seq_lseek, | ||
468 | .release = seq_release, | ||
469 | }; | ||
470 | |||
473 | static int __init gen_rtc_proc_init(void) | 471 | static int __init gen_rtc_proc_init(void) |
474 | { | 472 | { |
475 | struct proc_dir_entry *r; | 473 | struct proc_dir_entry *r; |
476 | 474 | ||
477 | r = create_proc_read_entry("driver/rtc", 0, NULL, gen_rtc_read_proc, NULL); | 475 | r = proc_create("driver/rtc", 0, NULL, &gen_rtc_proc_fops); |
478 | if (!r) | 476 | if (!r) |
479 | return -ENOMEM; | 477 | return -ENOMEM; |
480 | return 0; | 478 | return 0; |