Skip to content

Commit

Permalink
clocksource/drivers/asm9260: Convert init function to return error
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Daniel Lezcano committed Jun 28, 2016
1 parent 5e558eb commit be5eb33
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions drivers/clocksource/asm9260_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,28 +184,34 @@ static irqreturn_t asm9260_timer_interrupt(int irq, void *dev_id)
* Timer initialization
* ---------------------------------------------------------------------------
*/
static void __init asm9260_timer_init(struct device_node *np)
static int __init asm9260_timer_init(struct device_node *np)
{
int irq;
struct clk *clk;
int ret;
unsigned long rate;

priv.base = of_io_request_and_map(np, 0, np->name);
if (IS_ERR(priv.base))
panic("%s: unable to map resource", np->name);
if (IS_ERR(priv.base)) {
pr_err("%s: unable to map resource", np->name);
return PTR_ERR(priv.base);
}

clk = of_clk_get(np, 0);

ret = clk_prepare_enable(clk);
if (ret)
panic("Failed to enable clk!\n");
if (ret) {
pr_err("Failed to enable clk!\n");
return ret;
}

irq = irq_of_parse_and_map(np, 0);
ret = request_irq(irq, asm9260_timer_interrupt, IRQF_TIMER,
DRIVER_NAME, &event_dev);
if (ret)
panic("Failed to setup irq!\n");
if (ret) {
pr_err("Failed to setup irq!\n");
return ret;
}

/* set all timers for count-up */
writel_relaxed(BM_DIR_DEFAULT, priv.base + HW_DIR);
Expand All @@ -229,6 +235,8 @@ static void __init asm9260_timer_init(struct device_node *np)
priv.ticks_per_jiffy = DIV_ROUND_CLOSEST(rate, HZ);
event_dev.cpumask = cpumask_of(0);
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);

0 comments on commit be5eb33

Please sign in to comment.