Skip to content

Commit

Permalink
clocksource/drivers/mxs: Convert init function to return error
Browse files Browse the repository at this point in the history
The init function does not return any error, it prints a message, returns and
lets 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 0cc7afc commit e1d2b9f
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions drivers/clocksource/mxs_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,21 +226,23 @@ static int __init mxs_clocksource_init(struct clk *timer_clk)
return 0;
}

static void __init mxs_timer_init(struct device_node *np)
static int __init mxs_timer_init(struct device_node *np)
{
struct clk *timer_clk;
int irq;
int irq, ret;

mxs_timrot_base = of_iomap(np, 0);
WARN_ON(!mxs_timrot_base);

timer_clk = of_clk_get(np, 0);
if (IS_ERR(timer_clk)) {
pr_err("%s: failed to get clk\n", __func__);
return;
return PTR_ERR(timer_clk);
}

clk_prepare_enable(timer_clk);
ret = clk_prepare_enable(timer_clk);
if (ret)
return ret;

/*
* Initialize timers to a known state
Expand Down Expand Up @@ -278,11 +280,19 @@ static void __init mxs_timer_init(struct device_node *np)
mxs_timrot_base + HW_TIMROT_FIXED_COUNTn(1));

/* init and register the timer to the framework */
mxs_clocksource_init(timer_clk);
mxs_clockevent_init(timer_clk);
ret = mxs_clocksource_init(timer_clk);
if (ret)
return ret;

ret = mxs_clockevent_init(timer_clk);
if (ret)
return ret;

/* Make irqs happen */
irq = irq_of_parse_and_map(np, 0);
setup_irq(irq, &mxs_timer_irq);
if (irq <= 0)
return -EINVAL;

return setup_irq(irq, &mxs_timer_irq);
}
CLOCKSOURCE_OF_DECLARE(mxs, "fsl,timrot", mxs_timer_init);
CLOCKSOURCE_OF_DECLARE_RET(mxs, "fsl,timrot", mxs_timer_init);

0 comments on commit e1d2b9f

Please sign in to comment.