Commit eacf2091 authored by Daniel Lezcano's avatar Daniel Lezcano

clocksource/drivers/h8300_timer16: 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 5a54c187
...@@ -126,7 +126,7 @@ static struct timer16_priv timer16_priv = { ...@@ -126,7 +126,7 @@ static struct timer16_priv timer16_priv = {
#define REG_CH 0 #define REG_CH 0
#define REG_COMM 1 #define REG_COMM 1
static void __init h8300_16timer_init(struct device_node *node) static int __init h8300_16timer_init(struct device_node *node)
{ {
void __iomem *base[2]; void __iomem *base[2];
int ret, irq; int ret, irq;
...@@ -136,9 +136,10 @@ static void __init h8300_16timer_init(struct device_node *node) ...@@ -136,9 +136,10 @@ static void __init h8300_16timer_init(struct device_node *node)
clk = of_clk_get(node, 0); clk = of_clk_get(node, 0);
if (IS_ERR(clk)) { if (IS_ERR(clk)) {
pr_err("failed to get clock for clocksource\n"); pr_err("failed to get clock for clocksource\n");
return; return PTR_ERR(clk);
} }
ret = -ENXIO;
base[REG_CH] = of_iomap(node, 0); base[REG_CH] = of_iomap(node, 0);
if (!base[REG_CH]) { if (!base[REG_CH]) {
pr_err("failed to map registers for clocksource\n"); pr_err("failed to map registers for clocksource\n");
...@@ -151,6 +152,7 @@ static void __init h8300_16timer_init(struct device_node *node) ...@@ -151,6 +152,7 @@ static void __init h8300_16timer_init(struct device_node *node)
goto unmap_ch; goto unmap_ch;
} }
ret = -EINVAL;
irq = irq_of_parse_and_map(node, 0); irq = irq_of_parse_and_map(node, 0);
if (!irq) { if (!irq) {
pr_err("failed to get irq for clockevent\n"); pr_err("failed to get irq for clockevent\n");
...@@ -174,7 +176,7 @@ static void __init h8300_16timer_init(struct device_node *node) ...@@ -174,7 +176,7 @@ static void __init h8300_16timer_init(struct device_node *node)
clocksource_register_hz(&timer16_priv.cs, clocksource_register_hz(&timer16_priv.cs,
clk_get_rate(clk) / 8); clk_get_rate(clk) / 8);
return; return 0;
unmap_comm: unmap_comm:
iounmap(base[REG_COMM]); iounmap(base[REG_COMM]);
...@@ -182,6 +184,8 @@ static void __init h8300_16timer_init(struct device_node *node) ...@@ -182,6 +184,8 @@ static void __init h8300_16timer_init(struct device_node *node)
iounmap(base[REG_CH]); iounmap(base[REG_CH]);
free_clk: free_clk:
clk_put(clk); clk_put(clk);
return ret;
} }
CLOCKSOURCE_OF_DECLARE(h8300_16bit, "renesas,16bit-timer", h8300_16timer_init); CLOCKSOURCE_OF_DECLARE_RET(h8300_16bit, "renesas,16bit-timer",
h8300_16timer_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