提交 b71306e6 编写于 作者: D Daniel Lezcano

clocksource/drivers/vf_pit_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: NDaniel Lezcano <daniel.lezcano@linaro.org>
上级 86de9628
...@@ -156,15 +156,18 @@ static int __init pit_clockevent_init(unsigned long rate, int irq) ...@@ -156,15 +156,18 @@ static int __init pit_clockevent_init(unsigned long rate, int irq)
return 0; return 0;
} }
static void __init pit_timer_init(struct device_node *np) static int __init pit_timer_init(struct device_node *np)
{ {
struct clk *pit_clk; struct clk *pit_clk;
void __iomem *timer_base; void __iomem *timer_base;
unsigned long clk_rate; unsigned long clk_rate;
int irq; int irq, ret;
timer_base = of_iomap(np, 0); timer_base = of_iomap(np, 0);
BUG_ON(!timer_base); if (!timer_base) {
pr_err("Failed to iomap");
return -ENXIO;
}
/* /*
* PIT0 and PIT1 can be chained to build a 64-bit timer, * PIT0 and PIT1 can be chained to build a 64-bit timer,
...@@ -175,12 +178,16 @@ static void __init pit_timer_init(struct device_node *np) ...@@ -175,12 +178,16 @@ static void __init pit_timer_init(struct device_node *np)
clkevt_base = timer_base + PITn_OFFSET(3); clkevt_base = timer_base + PITn_OFFSET(3);
irq = irq_of_parse_and_map(np, 0); irq = irq_of_parse_and_map(np, 0);
BUG_ON(irq <= 0); if (irq <= 0)
return -EINVAL;
pit_clk = of_clk_get(np, 0); pit_clk = of_clk_get(np, 0);
BUG_ON(IS_ERR(pit_clk)); if (IS_ERR(pit_clk))
return PTR_ERR(pit_clk);
BUG_ON(clk_prepare_enable(pit_clk)); ret = clk_prepare_enable(pit_clk);
if (ret)
return ret;
clk_rate = clk_get_rate(pit_clk); clk_rate = clk_get_rate(pit_clk);
cycle_per_jiffy = clk_rate / (HZ); cycle_per_jiffy = clk_rate / (HZ);
...@@ -188,8 +195,10 @@ static void __init pit_timer_init(struct device_node *np) ...@@ -188,8 +195,10 @@ static void __init pit_timer_init(struct device_node *np)
/* enable the pit module */ /* enable the pit module */
__raw_writel(~PITMCR_MDIS, timer_base + PITMCR); __raw_writel(~PITMCR_MDIS, timer_base + PITMCR);
BUG_ON(pit_clocksource_init(clk_rate)); ret = pit_clocksource_init(clk_rate);
if (ret)
return ret;
pit_clockevent_init(clk_rate, irq); return pit_clockevent_init(clk_rate, irq);
} }
CLOCKSOURCE_OF_DECLARE(vf610, "fsl,vf610-pit", pit_timer_init); CLOCKSOURCE_OF_DECLARE_RET(vf610, "fsl,vf610-pit", pit_timer_init);
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册