Split up 'do_initcalls()' into two simpler functions

One function to just loop over the entries, one function to actually do
the call and the associated debugging code.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

+45 -40
+45 -40
init/main.c
··· 693 693 } 694 694 __setup("initcall_debug", initcall_debug_setup); 695 695 696 + static void __init do_one_initcall(initcall_t fn) 697 + { 698 + int count = preempt_count(); 699 + ktime_t t0, t1, delta; 700 + char msgbuf[40]; 701 + int result; 702 + 703 + if (initcall_debug) { 704 + print_fn_descriptor_symbol("calling %s\n", fn); 705 + t0 = ktime_get(); 706 + } 707 + 708 + result = fn(); 709 + 710 + if (initcall_debug) { 711 + t1 = ktime_get(); 712 + delta = ktime_sub(t1, t0); 713 + 714 + print_fn_descriptor_symbol("initcall %s", fn); 715 + printk(" returned %d after %Ld msecs\n", result, 716 + (unsigned long long) delta.tv64 >> 20); 717 + } 718 + 719 + msgbuf[0] = 0; 720 + 721 + if (result && result != -ENODEV && initcall_debug) 722 + sprintf(msgbuf, "error code %d ", result); 723 + 724 + if (preempt_count() != count) { 725 + strncat(msgbuf, "preemption imbalance ", sizeof(msgbuf)); 726 + preempt_count() = count; 727 + } 728 + if (irqs_disabled()) { 729 + strncat(msgbuf, "disabled interrupts ", sizeof(msgbuf)); 730 + local_irq_enable(); 731 + } 732 + if (msgbuf[0]) { 733 + print_fn_descriptor_symbol(KERN_WARNING "initcall %s", fn); 734 + printk(" returned with %s\n", msgbuf); 735 + } 736 + } 737 + 738 + 696 739 extern initcall_t __initcall_start[], __initcall_end[]; 697 740 698 741 static void __init do_initcalls(void) 699 742 { 700 743 initcall_t *call; 701 - int count = preempt_count(); 702 744 703 - for (call = __initcall_start; call < __initcall_end; call++) { 704 - ktime_t t0, t1, delta; 705 - char msgbuf[40]; 706 - int result; 707 - 708 - if (initcall_debug) { 709 - print_fn_descriptor_symbol("calling %s\n", *call); 710 - t0 = ktime_get(); 711 - } 712 - 713 - result = (*call)(); 714 - 715 - if (initcall_debug) { 716 - t1 = ktime_get(); 717 - delta = ktime_sub(t1, t0); 718 - 719 - print_fn_descriptor_symbol("initcall %s", *call); 720 - printk(" returned %d after %Ld msecs\n", result, 721 - (unsigned long long) delta.tv64 >> 20); 722 - } 723 - 724 - msgbuf[0] = 0; 725 - 726 - if (result && result != -ENODEV && initcall_debug) 727 - sprintf(msgbuf, "error code %d ", result); 728 - 729 - if (preempt_count() != count) { 730 - strncat(msgbuf, "preemption imbalance ", sizeof(msgbuf)); 731 - preempt_count() = count; 732 - } 733 - if (irqs_disabled()) { 734 - strncat(msgbuf, "disabled interrupts ", sizeof(msgbuf)); 735 - local_irq_enable(); 736 - } 737 - if (msgbuf[0]) { 738 - print_fn_descriptor_symbol(KERN_WARNING "initcall %s", *call); 739 - printk(" returned with %s\n", msgbuf); 740 - } 741 - } 745 + for (call = __initcall_start; call < __initcall_end; call++) 746 + do_one_initcall(*call); 742 747 743 748 /* Make sure there is no pending stuff from the initcall sequence */ 744 749 flush_scheduled_work();