clocksource/drivers/asm9260: 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:
@@ -184,7 +184,7 @@ static irqreturn_t asm9260_timer_interrupt(int irq, void *dev_id)
|
|||||||
* Timer initialization
|
* Timer initialization
|
||||||
* ---------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
static void __init asm9260_timer_init(struct device_node *np)
|
static int __init asm9260_timer_init(struct device_node *np)
|
||||||
{
|
{
|
||||||
int irq;
|
int irq;
|
||||||
struct clk *clk;
|
struct clk *clk;
|
||||||
@@ -192,20 +192,26 @@ static void __init asm9260_timer_init(struct device_node *np)
|
|||||||
unsigned long rate;
|
unsigned long rate;
|
||||||
|
|
||||||
priv.base = of_io_request_and_map(np, 0, np->name);
|
priv.base = of_io_request_and_map(np, 0, np->name);
|
||||||
if (IS_ERR(priv.base))
|
if (IS_ERR(priv.base)) {
|
||||||
panic("%s: unable to map resource", np->name);
|
pr_err("%s: unable to map resource", np->name);
|
||||||
|
return PTR_ERR(priv.base);
|
||||||
|
}
|
||||||
|
|
||||||
clk = of_clk_get(np, 0);
|
clk = of_clk_get(np, 0);
|
||||||
|
|
||||||
ret = clk_prepare_enable(clk);
|
ret = clk_prepare_enable(clk);
|
||||||
if (ret)
|
if (ret) {
|
||||||
panic("Failed to enable clk!\n");
|
pr_err("Failed to enable clk!\n");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
irq = irq_of_parse_and_map(np, 0);
|
irq = irq_of_parse_and_map(np, 0);
|
||||||
ret = request_irq(irq, asm9260_timer_interrupt, IRQF_TIMER,
|
ret = request_irq(irq, asm9260_timer_interrupt, IRQF_TIMER,
|
||||||
DRIVER_NAME, &event_dev);
|
DRIVER_NAME, &event_dev);
|
||||||
if (ret)
|
if (ret) {
|
||||||
panic("Failed to setup irq!\n");
|
pr_err("Failed to setup irq!\n");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
/* set all timers for count-up */
|
/* set all timers for count-up */
|
||||||
writel_relaxed(BM_DIR_DEFAULT, priv.base + HW_DIR);
|
writel_relaxed(BM_DIR_DEFAULT, priv.base + HW_DIR);
|
||||||
@@ -229,6 +235,8 @@ static void __init asm9260_timer_init(struct device_node *np)
|
|||||||
priv.ticks_per_jiffy = DIV_ROUND_CLOSEST(rate, HZ);
|
priv.ticks_per_jiffy = DIV_ROUND_CLOSEST(rate, HZ);
|
||||||
event_dev.cpumask = cpumask_of(0);
|
event_dev.cpumask = cpumask_of(0);
|
||||||
clockevents_config_and_register(&event_dev, rate, 0x2c00, 0xfffffffe);
|
clockevents_config_and_register(&event_dev, rate, 0x2c00, 0xfffffffe);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
CLOCKSOURCE_OF_DECLARE(asm9260_timer, "alphascale,asm9260-timer",
|
CLOCKSOURCE_OF_DECLARE_RET(asm9260_timer, "alphascale,asm9260-timer",
|
||||||
asm9260_timer_init);
|
asm9260_timer_init);
|
||||||
|
Reference in New Issue
Block a user