Commit 0683d503 authored by Daniel Lezcano's avatar Daniel Lezcano

clocksource/drivers/tango_xtal: 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 leave the caller unaware of 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 returns an error code from the init function.
Signed-off-by: default avatarDaniel Lezcano <daniel.lezcano@linaro.org>
Acked-by: default avatarMarc Gonzalez <marc_gonzalez@sigmadesigns.com>
parent ce5dc743
...@@ -19,7 +19,7 @@ static u64 notrace read_sched_clock(void) ...@@ -19,7 +19,7 @@ static u64 notrace read_sched_clock(void)
return read_xtal_counter(); return read_xtal_counter();
} }
static void __init tango_clocksource_init(struct device_node *np) static int __init tango_clocksource_init(struct device_node *np)
{ {
struct clk *clk; struct clk *clk;
int xtal_freq, ret; int xtal_freq, ret;
...@@ -27,13 +27,13 @@ static void __init tango_clocksource_init(struct device_node *np) ...@@ -27,13 +27,13 @@ static void __init tango_clocksource_init(struct device_node *np)
xtal_in_cnt = of_iomap(np, 0); xtal_in_cnt = of_iomap(np, 0);
if (xtal_in_cnt == NULL) { if (xtal_in_cnt == NULL) {
pr_err("%s: invalid address\n", np->full_name); pr_err("%s: invalid address\n", np->full_name);
return; return -ENXIO;
} }
clk = of_clk_get(np, 0); clk = of_clk_get(np, 0);
if (IS_ERR(clk)) { if (IS_ERR(clk)) {
pr_err("%s: invalid clock\n", np->full_name); pr_err("%s: invalid clock\n", np->full_name);
return; return PTR_ERR(clk);
} }
xtal_freq = clk_get_rate(clk); xtal_freq = clk_get_rate(clk);
...@@ -44,11 +44,13 @@ static void __init tango_clocksource_init(struct device_node *np) ...@@ -44,11 +44,13 @@ static void __init tango_clocksource_init(struct device_node *np)
32, clocksource_mmio_readl_up); 32, clocksource_mmio_readl_up);
if (ret) { if (ret) {
pr_err("%s: registration failed\n", np->full_name); pr_err("%s: registration failed\n", np->full_name);
return; return ret;
} }
sched_clock_register(read_sched_clock, 32, xtal_freq); sched_clock_register(read_sched_clock, 32, xtal_freq);
register_current_timer_delay(&delay_timer); register_current_timer_delay(&delay_timer);
return 0;
} }
CLOCKSOURCE_OF_DECLARE(tango, "sigma,tick-counter", tango_clocksource_init); CLOCKSOURCE_OF_DECLARE_RET(tango, "sigma,tick-counter", tango_clocksource_init);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment