Commit d8152bf8 authored by Daniel Lezcano's avatar Daniel Lezcano

clocksource/drivers/mips-gic-timer: 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: default avatarDaniel Lezcano <daniel.lezcano@linaro.org>
parent ca46acb9
...@@ -146,7 +146,7 @@ static struct clocksource gic_clocksource = { ...@@ -146,7 +146,7 @@ static struct clocksource gic_clocksource = {
.archdata = { .vdso_clock_mode = VDSO_CLOCK_GIC }, .archdata = { .vdso_clock_mode = VDSO_CLOCK_GIC },
}; };
static void __init __gic_clocksource_init(void) static int __init __gic_clocksource_init(void)
{ {
int ret; int ret;
...@@ -159,6 +159,8 @@ static void __init __gic_clocksource_init(void) ...@@ -159,6 +159,8 @@ static void __init __gic_clocksource_init(void)
ret = clocksource_register_hz(&gic_clocksource, gic_frequency); ret = clocksource_register_hz(&gic_clocksource, gic_frequency);
if (ret < 0) if (ret < 0)
pr_warn("GIC: Unable to register clocksource\n"); pr_warn("GIC: Unable to register clocksource\n");
return ret;
} }
void __init gic_clocksource_init(unsigned int frequency) void __init gic_clocksource_init(unsigned int frequency)
...@@ -179,31 +181,35 @@ static void __init gic_clocksource_of_init(struct device_node *node) ...@@ -179,31 +181,35 @@ static void __init gic_clocksource_of_init(struct device_node *node)
struct clk *clk; struct clk *clk;
int ret; int ret;
if (WARN_ON(!gic_present || !node->parent || if (!gic_present || !node->parent ||
!of_device_is_compatible(node->parent, "mti,gic"))) !of_device_is_compatible(node->parent, "mti,gic")) {
return; pr_warn("No DT definition for the mips gic driver");
return -ENXIO;
}
clk = of_clk_get(node, 0); clk = of_clk_get(node, 0);
if (!IS_ERR(clk)) { if (!IS_ERR(clk)) {
if (clk_prepare_enable(clk) < 0) { if (clk_prepare_enable(clk) < 0) {
pr_err("GIC failed to enable clock\n"); pr_err("GIC failed to enable clock\n");
clk_put(clk); clk_put(clk);
return; return PTR_ERR(clk);
} }
gic_frequency = clk_get_rate(clk); gic_frequency = clk_get_rate(clk);
} else if (of_property_read_u32(node, "clock-frequency", } else if (of_property_read_u32(node, "clock-frequency",
&gic_frequency)) { &gic_frequency)) {
pr_err("GIC frequency not specified.\n"); pr_err("GIC frequency not specified.\n");
return; return -EINVAL;;
} }
gic_timer_irq = irq_of_parse_and_map(node, 0); gic_timer_irq = irq_of_parse_and_map(node, 0);
if (!gic_timer_irq) { if (!gic_timer_irq) {
pr_err("GIC timer IRQ not specified.\n"); pr_err("GIC timer IRQ not specified.\n");
return; return -EINVAL;;
} }
__gic_clocksource_init(); ret = __gic_clocksource_init();
if (ret)
return ret;
ret = gic_clockevent_init(); ret = gic_clockevent_init();
if (!ret && !IS_ERR(clk)) { if (!ret && !IS_ERR(clk)) {
...@@ -213,6 +219,8 @@ static void __init gic_clocksource_of_init(struct device_node *node) ...@@ -213,6 +219,8 @@ static void __init gic_clocksource_of_init(struct device_node *node)
/* And finally start the counter */ /* And finally start the counter */
gic_start_count(); gic_start_count();
return 0;
} }
CLOCKSOURCE_OF_DECLARE(mips_gic_timer, "mti,gic-timer", CLOCKSOURCE_OF_DECLARE_RET(mips_gic_timer, "mti,gic-timer",
gic_clocksource_of_init); gic_clocksource_of_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