diff options
author | David Howells <dhowells@redhat.com> | 2013-04-10 22:04:20 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2013-04-29 15:41:59 -0400 |
commit | 1eb5b23ae72b2b858800c8eee6adeef7c098e767 (patch) | |
tree | 49d5b57230c63ac4f4034d2a55b4e6d5ec66cf51 /arch/cris/arch-v32/kernel/fasttimer.c | |
parent | 210b834a964c775387098bbc9e3836d3cd0e9b14 (diff) |
cris: 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>
Acked-by: Jesper Nilsson <jesper.nilsson@axis.com>
cc: Mikael Starvik <starvik@axis.com>
cc: linux-cris-kernel@axis.com
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'arch/cris/arch-v32/kernel/fasttimer.c')
-rw-r--r-- | arch/cris/arch-v32/kernel/fasttimer.c | 296 |
1 files changed, 132 insertions, 164 deletions
diff --git a/arch/cris/arch-v32/kernel/fasttimer.c b/arch/cris/arch-v32/kernel/fasttimer.c index dd1c998070e9..e43dd70acd96 100644 --- a/arch/cris/arch-v32/kernel/fasttimer.c +++ b/arch/cris/arch-v32/kernel/fasttimer.c | |||
@@ -23,6 +23,7 @@ | |||
23 | #include <hwregs/timer_defs.h> | 23 | #include <hwregs/timer_defs.h> |
24 | #include <asm/fasttimer.h> | 24 | #include <asm/fasttimer.h> |
25 | #include <linux/proc_fs.h> | 25 | #include <linux/proc_fs.h> |
26 | #include <linux/seq_file.h> | ||
26 | 27 | ||
27 | /* | 28 | /* |
28 | * timer0 is running at 100MHz and generating jiffies timer ticks | 29 | * timer0 is running at 100MHz and generating jiffies timer ticks |
@@ -463,194 +464,161 @@ void schedule_usleep(unsigned long us) | |||
463 | } | 464 | } |
464 | 465 | ||
465 | #ifdef CONFIG_PROC_FS | 466 | #ifdef CONFIG_PROC_FS |
466 | static int proc_fasttimer_read(char *buf, char **start, off_t offset, int len | ||
467 | ,int *eof, void *data_unused); | ||
468 | #endif /* CONFIG_PROC_FS */ | ||
469 | |||
470 | #ifdef CONFIG_PROC_FS | ||
471 | |||
472 | /* This value is very much based on testing */ | 467 | /* This value is very much based on testing */ |
473 | #define BIG_BUF_SIZE (500 + NUM_TIMER_STATS * 300) | 468 | #define BIG_BUF_SIZE (500 + NUM_TIMER_STATS * 300) |
474 | 469 | ||
475 | static int proc_fasttimer_read(char *buf, char **start, off_t offset, int len | 470 | static int proc_fasttimer_show(struct seq_file *m, void *v) |
476 | ,int *eof, void *data_unused) | ||
477 | { | 471 | { |
478 | unsigned long flags; | 472 | unsigned long flags; |
479 | int i = 0; | 473 | int i = 0; |
480 | int num_to_show; | 474 | int num_to_show; |
481 | struct fasttime_t tv; | 475 | struct fasttime_t tv; |
482 | struct fast_timer *t, *nextt; | 476 | struct fast_timer *t, *nextt; |
483 | static char *bigbuf = NULL; | 477 | |
484 | static unsigned long used; | 478 | do_gettimeofday_fast(&tv); |
485 | 479 | ||
486 | if (!bigbuf) { | 480 | seq_printf(m, "Fast timers added: %i\n", fast_timers_added); |
487 | bigbuf = vmalloc(BIG_BUF_SIZE); | 481 | seq_printf(m, "Fast timers started: %i\n", fast_timers_started); |
488 | if (!bigbuf) { | 482 | seq_printf(m, "Fast timer interrupts: %i\n", fast_timer_ints); |
489 | used = 0; | 483 | seq_printf(m, "Fast timers expired: %i\n", fast_timers_expired); |
490 | if (buf) | 484 | seq_printf(m, "Fast timers deleted: %i\n", fast_timers_deleted); |
491 | buf[0] = '\0'; | 485 | seq_printf(m, "Fast timer running: %s\n", |
492 | return 0; | 486 | fast_timer_running ? "yes" : "no"); |
493 | } | 487 | seq_printf(m, "Current time: %lu.%06lu\n", |
494 | } | 488 | (unsigned long)tv.tv_jiff, |
495 | 489 | (unsigned long)tv.tv_usec); | |
496 | if (!offset || !used) { | ||
497 | do_gettimeofday_fast(&tv); | ||
498 | |||
499 | used = 0; | ||
500 | used += sprintf(bigbuf + used, "Fast timers added: %i\n", | ||
501 | fast_timers_added); | ||
502 | used += sprintf(bigbuf + used, "Fast timers started: %i\n", | ||
503 | fast_timers_started); | ||
504 | used += sprintf(bigbuf + used, "Fast timer interrupts: %i\n", | ||
505 | fast_timer_ints); | ||
506 | used += sprintf(bigbuf + used, "Fast timers expired: %i\n", | ||
507 | fast_timers_expired); | ||
508 | used += sprintf(bigbuf + used, "Fast timers deleted: %i\n", | ||
509 | fast_timers_deleted); | ||
510 | used += sprintf(bigbuf + used, "Fast timer running: %s\n", | ||
511 | fast_timer_running ? "yes" : "no"); | ||
512 | used += sprintf(bigbuf + used, "Current time: %lu.%06lu\n", | ||
513 | (unsigned long)tv.tv_jiff, | ||
514 | (unsigned long)tv.tv_usec); | ||
515 | #ifdef FAST_TIMER_SANITY_CHECKS | 490 | #ifdef FAST_TIMER_SANITY_CHECKS |
516 | used += sprintf(bigbuf + used, "Sanity failed: %i\n", | 491 | seq_printf(m, "Sanity failed: %i\n", sanity_failed); |
517 | sanity_failed); | ||
518 | #endif | 492 | #endif |
519 | used += sprintf(bigbuf + used, "\n"); | 493 | seq_putc(m, '\n'); |
520 | 494 | ||
521 | #ifdef DEBUG_LOG_INCLUDED | 495 | #ifdef DEBUG_LOG_INCLUDED |
522 | { | 496 | { |
523 | int end_i = debug_log_cnt; | 497 | int end_i = debug_log_cnt; |
524 | i = 0; | 498 | i = 0; |
525 | 499 | ||
526 | if (debug_log_cnt_wrapped) | 500 | if (debug_log_cnt_wrapped) |
527 | i = debug_log_cnt; | 501 | i = debug_log_cnt; |
528 | 502 | ||
529 | while ((i != end_i || (debug_log_cnt_wrapped && !used)) && | 503 | while ((i != end_i || debug_log_cnt_wrapped)) { |
530 | used+100 < BIG_BUF_SIZE) | 504 | if (seq_printf(m, debug_log_string[i], debug_log_value[i]) < 0) |
531 | { | 505 | return 0; |
532 | used += sprintf(bigbuf + used, debug_log_string[i], | 506 | i = (i+1) % DEBUG_LOG_MAX; |
533 | debug_log_value[i]); | 507 | } |
534 | i = (i+1) % DEBUG_LOG_MAX; | 508 | } |
535 | } | 509 | seq_putc(m, '\n'); |
536 | } | ||
537 | used += sprintf(bigbuf + used, "\n"); | ||
538 | #endif | 510 | #endif |
539 | 511 | ||
540 | num_to_show = (fast_timers_started < NUM_TIMER_STATS ? fast_timers_started: | 512 | num_to_show = (fast_timers_started < NUM_TIMER_STATS ? fast_timers_started: |
541 | NUM_TIMER_STATS); | 513 | NUM_TIMER_STATS); |
542 | used += sprintf(bigbuf + used, "Timers started: %i\n", fast_timers_started); | 514 | seq_printf(m, "Timers started: %i\n", fast_timers_started); |
543 | for (i = 0; i < num_to_show && (used+100 < BIG_BUF_SIZE) ; i++) | 515 | for (i = 0; i < num_to_show; i++) { |
544 | { | 516 | int cur = (fast_timers_started - i - 1) % NUM_TIMER_STATS; |
545 | int cur = (fast_timers_started - i - 1) % NUM_TIMER_STATS; | ||
546 | 517 | ||
547 | #if 1 //ndef FAST_TIMER_LOG | 518 | #if 1 //ndef FAST_TIMER_LOG |
548 | used += sprintf(bigbuf + used, "div: %i delay: %i" | 519 | seq_printf(m, "div: %i delay: %i" |
549 | "\n", | 520 | "\n", |
550 | timer_div_settings[cur], | 521 | timer_div_settings[cur], |
551 | timer_delay_settings[cur] | 522 | timer_delay_settings[cur]); |
552 | ); | ||
553 | #endif | 523 | #endif |
554 | #ifdef FAST_TIMER_LOG | 524 | #ifdef FAST_TIMER_LOG |
555 | t = &timer_started_log[cur]; | 525 | t = &timer_started_log[cur]; |
556 | used += sprintf(bigbuf + used, "%-14s s: %6lu.%06lu e: %6lu.%06lu " | 526 | if (seq_printf(m, "%-14s s: %6lu.%06lu e: %6lu.%06lu " |
557 | "d: %6li us data: 0x%08lX" | 527 | "d: %6li us data: 0x%08lX" |
558 | "\n", | 528 | "\n", |
559 | t->name, | 529 | t->name, |
560 | (unsigned long)t->tv_set.tv_jiff, | 530 | (unsigned long)t->tv_set.tv_jiff, |
561 | (unsigned long)t->tv_set.tv_usec, | 531 | (unsigned long)t->tv_set.tv_usec, |
562 | (unsigned long)t->tv_expires.tv_jiff, | 532 | (unsigned long)t->tv_expires.tv_jiff, |
563 | (unsigned long)t->tv_expires.tv_usec, | 533 | (unsigned long)t->tv_expires.tv_usec, |
564 | t->delay_us, | 534 | t->delay_us, |
565 | t->data | 535 | t->data) < 0) |
566 | ); | 536 | return 0; |
567 | #endif | 537 | #endif |
568 | } | 538 | } |
569 | used += sprintf(bigbuf + used, "\n"); | 539 | seq_putc(m, '\n'); |
570 | 540 | ||
571 | #ifdef FAST_TIMER_LOG | 541 | #ifdef FAST_TIMER_LOG |
572 | num_to_show = (fast_timers_added < NUM_TIMER_STATS ? fast_timers_added: | 542 | num_to_show = (fast_timers_added < NUM_TIMER_STATS ? fast_timers_added: |
573 | NUM_TIMER_STATS); | 543 | NUM_TIMER_STATS); |
574 | used += sprintf(bigbuf + used, "Timers added: %i\n", fast_timers_added); | 544 | seq_printf(m, "Timers added: %i\n", fast_timers_added); |
575 | for (i = 0; i < num_to_show && (used+100 < BIG_BUF_SIZE); i++) | 545 | for (i = 0; i < num_to_show; i++) { |
576 | { | 546 | t = &timer_added_log[(fast_timers_added - i - 1) % NUM_TIMER_STATS]; |
577 | t = &timer_added_log[(fast_timers_added - i - 1) % NUM_TIMER_STATS]; | 547 | if (seq_printf(m, "%-14s s: %6lu.%06lu e: %6lu.%06lu " |
578 | used += sprintf(bigbuf + used, "%-14s s: %6lu.%06lu e: %6lu.%06lu " | 548 | "d: %6li us data: 0x%08lX" |
579 | "d: %6li us data: 0x%08lX" | 549 | "\n", |
580 | "\n", | 550 | t->name, |
581 | t->name, | 551 | (unsigned long)t->tv_set.tv_jiff, |
582 | (unsigned long)t->tv_set.tv_jiff, | 552 | (unsigned long)t->tv_set.tv_usec, |
583 | (unsigned long)t->tv_set.tv_usec, | 553 | (unsigned long)t->tv_expires.tv_jiff, |
584 | (unsigned long)t->tv_expires.tv_jiff, | 554 | (unsigned long)t->tv_expires.tv_usec, |
585 | (unsigned long)t->tv_expires.tv_usec, | 555 | t->delay_us, |
586 | t->delay_us, | 556 | t->data) < 0) |
587 | t->data | 557 | return 0; |
588 | ); | 558 | } |
589 | } | 559 | seq_putc(m, '\n'); |
590 | used += sprintf(bigbuf + used, "\n"); | 560 | |
591 | 561 | num_to_show = (fast_timers_expired < NUM_TIMER_STATS ? fast_timers_expired: | |
592 | num_to_show = (fast_timers_expired < NUM_TIMER_STATS ? fast_timers_expired: | 562 | NUM_TIMER_STATS); |
593 | NUM_TIMER_STATS); | 563 | seq_printf(m, "Timers expired: %i\n", fast_timers_expired); |
594 | used += sprintf(bigbuf + used, "Timers expired: %i\n", fast_timers_expired); | 564 | for (i = 0; i < num_to_show; i++){ |
595 | for (i = 0; i < num_to_show && (used+100 < BIG_BUF_SIZE); i++) | 565 | t = &timer_expired_log[(fast_timers_expired - i - 1) % NUM_TIMER_STATS]; |
596 | { | 566 | if (seq_printf(m, "%-14s s: %6lu.%06lu e: %6lu.%06lu " |
597 | t = &timer_expired_log[(fast_timers_expired - i - 1) % NUM_TIMER_STATS]; | 567 | "d: %6li us data: 0x%08lX" |
598 | used += sprintf(bigbuf + used, "%-14s s: %6lu.%06lu e: %6lu.%06lu " | 568 | "\n", |
599 | "d: %6li us data: 0x%08lX" | 569 | t->name, |
600 | "\n", | 570 | (unsigned long)t->tv_set.tv_jiff, |
601 | t->name, | 571 | (unsigned long)t->tv_set.tv_usec, |
602 | (unsigned long)t->tv_set.tv_jiff, | 572 | (unsigned long)t->tv_expires.tv_jiff, |
603 | (unsigned long)t->tv_set.tv_usec, | 573 | (unsigned long)t->tv_expires.tv_usec, |
604 | (unsigned long)t->tv_expires.tv_jiff, | 574 | t->delay_us, |
605 | (unsigned long)t->tv_expires.tv_usec, | 575 | t->data) < 0) |
606 | t->delay_us, | 576 | return 0; |
607 | t->data | 577 | } |
608 | ); | 578 | seq_putc(m, '\n'); |
609 | } | ||
610 | used += sprintf(bigbuf + used, "\n"); | ||
611 | #endif | 579 | #endif |
612 | 580 | ||
613 | used += sprintf(bigbuf + used, "Active timers:\n"); | 581 | seq_puts(m, "Active timers:\n"); |
614 | local_irq_save(flags); | 582 | local_irq_save(flags); |
615 | t = fast_timer_list; | 583 | t = fast_timer_list; |
616 | while (t != NULL && (used+100 < BIG_BUF_SIZE)) | 584 | while (t != NULL){ |
617 | { | 585 | nextt = t->next; |
618 | nextt = t->next; | 586 | local_irq_restore(flags); |
619 | local_irq_restore(flags); | 587 | if (seq_printf(m, "%-14s s: %6lu.%06lu e: %6lu.%06lu " |
620 | used += sprintf(bigbuf + used, "%-14s s: %6lu.%06lu e: %6lu.%06lu " | 588 | "d: %6li us data: 0x%08lX" |
621 | "d: %6li us data: 0x%08lX" | ||
622 | /* " func: 0x%08lX" */ | 589 | /* " func: 0x%08lX" */ |
623 | "\n", | 590 | "\n", |
624 | t->name, | 591 | t->name, |
625 | (unsigned long)t->tv_set.tv_jiff, | 592 | (unsigned long)t->tv_set.tv_jiff, |
626 | (unsigned long)t->tv_set.tv_usec, | 593 | (unsigned long)t->tv_set.tv_usec, |
627 | (unsigned long)t->tv_expires.tv_jiff, | 594 | (unsigned long)t->tv_expires.tv_jiff, |
628 | (unsigned long)t->tv_expires.tv_usec, | 595 | (unsigned long)t->tv_expires.tv_usec, |
629 | t->delay_us, | 596 | t->delay_us, |
630 | t->data | 597 | t->data |
631 | /* , t->function */ | 598 | /* , t->function */ |
632 | ); | 599 | ) < 0) |
633 | local_irq_save(flags); | 600 | return 0; |
634 | if (t->next != nextt) | 601 | local_irq_save(flags); |
635 | { | 602 | if (t->next != nextt) |
636 | printk("timer removed!\n"); | 603 | printk("timer removed!\n"); |
637 | } | 604 | t = nextt; |
638 | t = nextt; | 605 | } |
639 | } | 606 | local_irq_restore(flags); |
640 | local_irq_restore(flags); | 607 | return 0; |
641 | } | 608 | } |
642 | 609 | ||
643 | if (used - offset < len) | 610 | static int proc_fasttimer_open(struct inode *inode, struct file *file) |
644 | { | 611 | { |
645 | len = used - offset; | 612 | return single_open_size(file, proc_fasttimer_show, PDE_DATA(inode), BIG_BUF_SIZE); |
646 | } | 613 | } |
647 | 614 | ||
648 | memcpy(buf, bigbuf + offset, len); | 615 | static const struct file_operations proc_fasttimer_fops = { |
649 | *start = buf; | 616 | .open = proc_fasttimer_open, |
650 | *eof = 1; | 617 | .read = seq_read, |
618 | .llseek = seq_lseek, | ||
619 | .release = seq_release, | ||
620 | }; | ||
651 | 621 | ||
652 | return len; | ||
653 | } | ||
654 | #endif /* PROC_FS */ | 622 | #endif /* PROC_FS */ |
655 | 623 | ||
656 | #ifdef FAST_TIMER_TEST | 624 | #ifdef FAST_TIMER_TEST |
@@ -815,7 +783,7 @@ int fast_timer_init(void) | |||
815 | printk("fast_timer_init()\n"); | 783 | printk("fast_timer_init()\n"); |
816 | 784 | ||
817 | #ifdef CONFIG_PROC_FS | 785 | #ifdef CONFIG_PROC_FS |
818 | create_proc_read_entry("fasttimer", 0, NULL, proc_fasttimer_read, NULL); | 786 | proc_create("fasttimer", 0, NULL, &proc_fasttimer_fops); |
819 | #endif /* PROC_FS */ | 787 | #endif /* PROC_FS */ |
820 | if (request_irq(TIMER0_INTR_VECT, timer_trig_interrupt, | 788 | if (request_irq(TIMER0_INTR_VECT, timer_trig_interrupt, |
821 | IRQF_SHARED | IRQF_DISABLED, | 789 | IRQF_SHARED | IRQF_DISABLED, |