From 191d5eca2405b58cece0e572f694abd1230b0efe Mon Sep 17 00:00:00 2001 From: Stephan Linz Date: Wed, 20 Jun 2012 22:36:37 +0200 Subject: microblaze: Improve failure handling for GPIO reset Early exit from of_platform_reset_gpio_probe() if there was no GPIO reset line configured. Avoid kernel oops in gpio_system_reset(): [ 27.413294] Restarting system. [ 27.415674] Machine restart... [ 27.418787] Oops: kernel access of bad area, sig: 11 [ 27.423252] Registers dump: mode=83871D1C [ 27.427428] r1=00000000, r2=00000000, r3=FFFFFEF8, r4=00000000 [ 27.433310] r5=C026AED0, r6=00000001, r7=00000068, r8=00000000 [ 27.439189] r9=C3871DAC, r10=000011A5, r11=00000000, r12=0000000A [ 27.445318] r13=00000000, r14=0000000F, r15=C00029BC, r16=00000000 [ 27.451558] r17=C011DE8C, r18=80000115, r19=0000000F, r20=48184ED8 [ 27.457770] r21=00000000, r22=FFFFFFEA, r23=00000001, r24=FEE1DEAD [ 27.463982] r25=00000054, r26=1000B1C8, r27=00000000, r28=00000000 [ 27.470208] r29=00000000, r30=00000000, r31=C32D30C0, rPC=C011DE8C [ 27.476433] msr=000042A2, ear=0000004B, esr=00000872, fsr=342E3732 And remove useless dump_stack from machine_restart. Signed-off-by: Stephan Linz Signed-off-by: Michal Simek --- arch/microblaze/kernel/reset.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'arch/microblaze/kernel/reset.c') diff --git a/arch/microblaze/kernel/reset.c b/arch/microblaze/kernel/reset.c index 88a01636f785..6ce60fb24ac5 100644 --- a/arch/microblaze/kernel/reset.c +++ b/arch/microblaze/kernel/reset.c @@ -28,6 +28,7 @@ void of_platform_reset_gpio_probe(void) if (!gpio_is_valid(handle)) { printk(KERN_INFO "Skipping unavailable RESET gpio %d (%s)\n", handle, "reset"); + return; } ret = gpio_request(handle, "reset"); @@ -60,7 +61,10 @@ err: static void gpio_system_reset(void) { - gpio_set_value(handle, 1 - reset_val); + if (gpio_is_valid(handle)) + gpio_set_value(handle, 1 - reset_val); + else + pr_notice("Reset GPIO unavailable - halting!\n"); } #else #define gpio_system_reset() do {} while (0) @@ -74,7 +78,6 @@ void machine_restart(char *cmd) { printk(KERN_NOTICE "Machine restart...\n"); gpio_system_reset(); - dump_stack(); while (1) ; } -- cgit v1.2.3 From aaa5241ebb53733663775c8a044004d63a126eb6 Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Thu, 4 Oct 2012 14:24:58 +0200 Subject: microblaze: Prefer to use pr_XXX instead of printk(KERN_XX) Fix reset.c, timer.c, setup.c file. Signed-off-by: Michal Simek --- arch/microblaze/kernel/reset.c | 14 +++++++------- arch/microblaze/kernel/setup.c | 2 +- arch/microblaze/kernel/timer.c | 14 +++++++------- 3 files changed, 15 insertions(+), 15 deletions(-) (limited to 'arch/microblaze/kernel/reset.c') diff --git a/arch/microblaze/kernel/reset.c b/arch/microblaze/kernel/reset.c index 6ce60fb24ac5..2e5079ab53d2 100644 --- a/arch/microblaze/kernel/reset.c +++ b/arch/microblaze/kernel/reset.c @@ -26,14 +26,14 @@ void of_platform_reset_gpio_probe(void) "hard-reset-gpios", 0); if (!gpio_is_valid(handle)) { - printk(KERN_INFO "Skipping unavailable RESET gpio %d (%s)\n", + pr_info("Skipping unavailable RESET gpio %d (%s)\n", handle, "reset"); return; } ret = gpio_request(handle, "reset"); if (ret < 0) { - printk(KERN_INFO "GPIO pin is already allocated\n"); + pr_info("GPIO pin is already allocated\n"); return; } @@ -50,7 +50,7 @@ void of_platform_reset_gpio_probe(void) /* Setup output direction */ gpio_set_value(handle, 0); - printk(KERN_INFO "RESET: Registered gpio device: %d, current val: %d\n", + pr_info("RESET: Registered gpio device: %d, current val: %d\n", handle, reset_val); return; err: @@ -76,7 +76,7 @@ void of_platform_reset_gpio_probe(void) void machine_restart(char *cmd) { - printk(KERN_NOTICE "Machine restart...\n"); + pr_notice("Machine restart...\n"); gpio_system_reset(); while (1) ; @@ -84,21 +84,21 @@ void machine_restart(char *cmd) void machine_shutdown(void) { - printk(KERN_NOTICE "Machine shutdown...\n"); + pr_notice("Machine shutdown...\n"); while (1) ; } void machine_halt(void) { - printk(KERN_NOTICE "Machine halt...\n"); + pr_notice("Machine halt...\n"); while (1) ; } void machine_power_off(void) { - printk(KERN_NOTICE "Machine power off...\n"); + pr_notice("Machine power off...\n"); while (1) ; } diff --git a/arch/microblaze/kernel/setup.c b/arch/microblaze/kernel/setup.c index 9dbc9ecb28f1..954348f83505 100644 --- a/arch/microblaze/kernel/setup.c +++ b/arch/microblaze/kernel/setup.c @@ -69,7 +69,7 @@ void __init setup_arch(char **cmdline_p) xilinx_pci_init(); #if defined(CONFIG_SELFMOD_INTC) || defined(CONFIG_SELFMOD_TIMER) - printk(KERN_NOTICE "Self modified code enable\n"); + pr_notice("Self modified code enable\n"); #endif #ifdef CONFIG_VT diff --git a/arch/microblaze/kernel/timer.c b/arch/microblaze/kernel/timer.c index edd3f835e7df..aec5020a6e31 100644 --- a/arch/microblaze/kernel/timer.c +++ b/arch/microblaze/kernel/timer.c @@ -116,21 +116,21 @@ static void microblaze_timer_set_mode(enum clock_event_mode mode, { switch (mode) { case CLOCK_EVT_MODE_PERIODIC: - printk(KERN_INFO "%s: periodic\n", __func__); + pr_info("%s: periodic\n", __func__); microblaze_timer0_start_periodic(freq_div_hz); break; case CLOCK_EVT_MODE_ONESHOT: - printk(KERN_INFO "%s: oneshot\n", __func__); + pr_info("%s: oneshot\n", __func__); break; case CLOCK_EVT_MODE_UNUSED: - printk(KERN_INFO "%s: unused\n", __func__); + pr_info("%s: unused\n", __func__); break; case CLOCK_EVT_MODE_SHUTDOWN: - printk(KERN_INFO "%s: shutdown\n", __func__); + pr_info("%s: shutdown\n", __func__); microblaze_timer0_stop(); break; case CLOCK_EVT_MODE_RESUME: - printk(KERN_INFO "%s: resume\n", __func__); + pr_info("%s: resume\n", __func__); break; } } @@ -274,14 +274,14 @@ void __init time_init(void) timer_num = be32_to_cpup(of_get_property(timer, "xlnx,one-timer-only", NULL)); if (timer_num) { - printk(KERN_EMERG "Please enable two timers in HW\n"); + pr_emerg("Please enable two timers in HW\n"); BUG(); } #ifdef CONFIG_SELFMOD_TIMER selfmod_function((int *) arr_func, timer_baseaddr); #endif - printk(KERN_INFO "%s #0 at 0x%08x, irq=%d\n", + pr_info("%s #0 at 0x%08x, irq=%d\n", timer->name, timer_baseaddr, irq); /* If there is clock-frequency property than use it */ -- cgit v1.2.3