clocksource/drivers/atlas7: Convert init function to return error

The init functions do not return any error. They behave as the following:

  - panic, thus leading to a kernel crash while another timer may work and
       make the system boot up correctly

  or

  - print an error and let the caller unaware if the state of the system

Change that by converting the init functions to return an error conforming
to the CLOCKSOURCE_OF_RET prototype.

Proper error handling (rollback, errno value) will be changed later case
by case, thus this change just return back an error or success in the init
function.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
This commit is contained in:
Daniel Lezcano 2016-06-06 18:01:09 +02:00
parent 41505a208f
commit c41c96ddac

View file

@ -238,7 +238,7 @@ static struct notifier_block sirfsoc_cpu_nb = {
.notifier_call = sirfsoc_cpu_notify, .notifier_call = sirfsoc_cpu_notify,
}; };
static void __init sirfsoc_clockevent_init(void) static int __init sirfsoc_clockevent_init(void)
{ {
sirfsoc_clockevent = alloc_percpu(struct clock_event_device); sirfsoc_clockevent = alloc_percpu(struct clock_event_device);
BUG_ON(!sirfsoc_clockevent); BUG_ON(!sirfsoc_clockevent);
@ -246,11 +246,11 @@ static void __init sirfsoc_clockevent_init(void)
BUG_ON(register_cpu_notifier(&sirfsoc_cpu_nb)); BUG_ON(register_cpu_notifier(&sirfsoc_cpu_nb));
/* Immediately configure the timer on the boot CPU */ /* Immediately configure the timer on the boot CPU */
sirfsoc_local_timer_setup(this_cpu_ptr(sirfsoc_clockevent)); return sirfsoc_local_timer_setup(this_cpu_ptr(sirfsoc_clockevent));
} }
/* initialize the kernel jiffy timer source */ /* initialize the kernel jiffy timer source */
static void __init sirfsoc_atlas7_timer_init(struct device_node *np) static int __init sirfsoc_atlas7_timer_init(struct device_node *np)
{ {
struct clk *clk; struct clk *clk;
@ -279,23 +279,29 @@ static void __init sirfsoc_atlas7_timer_init(struct device_node *np)
BUG_ON(clocksource_register_hz(&sirfsoc_clocksource, atlas7_timer_rate)); BUG_ON(clocksource_register_hz(&sirfsoc_clocksource, atlas7_timer_rate));
sirfsoc_clockevent_init(); return sirfsoc_clockevent_init();
} }
static void __init sirfsoc_of_timer_init(struct device_node *np) static int __init sirfsoc_of_timer_init(struct device_node *np)
{ {
sirfsoc_timer_base = of_iomap(np, 0); sirfsoc_timer_base = of_iomap(np, 0);
if (!sirfsoc_timer_base) if (!sirfsoc_timer_base) {
panic("unable to map timer cpu registers\n"); pr_err("unable to map timer cpu registers\n");
return -ENXIO;
}
sirfsoc_timer_irq.irq = irq_of_parse_and_map(np, 0); sirfsoc_timer_irq.irq = irq_of_parse_and_map(np, 0);
if (!sirfsoc_timer_irq.irq) if (!sirfsoc_timer_irq.irq) {
panic("No irq passed for timer0 via DT\n"); pr_err("No irq passed for timer0 via DT\n");
return -EINVAL;
}
sirfsoc_timer1_irq.irq = irq_of_parse_and_map(np, 1); sirfsoc_timer1_irq.irq = irq_of_parse_and_map(np, 1);
if (!sirfsoc_timer1_irq.irq) if (!sirfsoc_timer1_irq.irq) {
panic("No irq passed for timer1 via DT\n"); pr_err("No irq passed for timer1 via DT\n");
return -EINVAL;
}
sirfsoc_atlas7_timer_init(np); return sirfsoc_atlas7_timer_init(np);
} }
CLOCKSOURCE_OF_DECLARE(sirfsoc_atlas7_timer, "sirf,atlas7-tick", sirfsoc_of_timer_init); CLOCKSOURCE_OF_DECLARE_RET(sirfsoc_atlas7_timer, "sirf,atlas7-tick", sirfsoc_of_timer_init);