clocksource/drivers/fsl_ftm_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: Daniel Lezcano <daniel.lezcano@linaro.org>
This commit is contained in:
parent
108a4ed965
commit
17c8669d80
|
@ -316,15 +316,16 @@ static int __init ftm_calc_closest_round_cyc(unsigned long freq)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __init ftm_timer_init(struct device_node *np)
|
static int __init ftm_timer_init(struct device_node *np)
|
||||||
{
|
{
|
||||||
unsigned long freq;
|
unsigned long freq;
|
||||||
int irq;
|
int ret, irq;
|
||||||
|
|
||||||
priv = kzalloc(sizeof(*priv), GFP_KERNEL);
|
priv = kzalloc(sizeof(*priv), GFP_KERNEL);
|
||||||
if (!priv)
|
if (!priv)
|
||||||
return;
|
return -ENOMEM;
|
||||||
|
|
||||||
|
ret = -ENXIO;
|
||||||
priv->clkevt_base = of_iomap(np, 0);
|
priv->clkevt_base = of_iomap(np, 0);
|
||||||
if (!priv->clkevt_base) {
|
if (!priv->clkevt_base) {
|
||||||
pr_err("ftm: unable to map event timer registers\n");
|
pr_err("ftm: unable to map event timer registers\n");
|
||||||
|
@ -337,6 +338,7 @@ static void __init ftm_timer_init(struct device_node *np)
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ret = -EINVAL;
|
||||||
irq = irq_of_parse_and_map(np, 0);
|
irq = irq_of_parse_and_map(np, 0);
|
||||||
if (irq <= 0) {
|
if (irq <= 0) {
|
||||||
pr_err("ftm: unable to get IRQ from DT, %d\n", irq);
|
pr_err("ftm: unable to get IRQ from DT, %d\n", irq);
|
||||||
|
@ -349,18 +351,22 @@ static void __init ftm_timer_init(struct device_node *np)
|
||||||
if (!freq)
|
if (!freq)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
if (ftm_calc_closest_round_cyc(freq))
|
ret = ftm_calc_closest_round_cyc(freq);
|
||||||
|
if (ret)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
if (ftm_clocksource_init(freq))
|
ret = ftm_clocksource_init(freq);
|
||||||
|
if (ret)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
if (ftm_clockevent_init(freq, irq))
|
ret = ftm_clockevent_init(freq, irq);
|
||||||
|
if (ret)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
return;
|
return 0;
|
||||||
|
|
||||||
err:
|
err:
|
||||||
kfree(priv);
|
kfree(priv);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
CLOCKSOURCE_OF_DECLARE(flextimer, "fsl,ftm-timer", ftm_timer_init);
|
CLOCKSOURCE_OF_DECLARE_RET(flextimer, "fsl,ftm-timer", ftm_timer_init);
|
||||||
|
|
Loading…
Reference in New Issue