mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-04-01 11:54:10 +00:00
clocksource/drivers/moxart: 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
d8152bf85d
commit
b7357e656c
1 changed files with 27 additions and 14 deletions
|
@ -119,34 +119,45 @@ static struct irqaction moxart_timer_irq = {
|
||||||
.dev_id = &moxart_clockevent,
|
.dev_id = &moxart_clockevent,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void __init moxart_timer_init(struct device_node *node)
|
static int __init moxart_timer_init(struct device_node *node)
|
||||||
{
|
{
|
||||||
int ret, irq;
|
int ret, irq;
|
||||||
unsigned long pclk;
|
unsigned long pclk;
|
||||||
struct clk *clk;
|
struct clk *clk;
|
||||||
|
|
||||||
base = of_iomap(node, 0);
|
base = of_iomap(node, 0);
|
||||||
if (!base)
|
if (!base) {
|
||||||
panic("%s: of_iomap failed\n", node->full_name);
|
pr_err("%s: of_iomap failed\n", node->full_name);
|
||||||
|
return -ENXIO;
|
||||||
|
}
|
||||||
|
|
||||||
irq = irq_of_parse_and_map(node, 0);
|
irq = irq_of_parse_and_map(node, 0);
|
||||||
if (irq <= 0)
|
if (irq <= 0) {
|
||||||
panic("%s: irq_of_parse_and_map failed\n", node->full_name);
|
pr_err("%s: irq_of_parse_and_map failed\n", node->full_name);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
ret = setup_irq(irq, &moxart_timer_irq);
|
ret = setup_irq(irq, &moxart_timer_irq);
|
||||||
if (ret)
|
if (ret) {
|
||||||
panic("%s: setup_irq failed\n", node->full_name);
|
pr_err("%s: setup_irq failed\n", node->full_name);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
clk = of_clk_get(node, 0);
|
clk = of_clk_get(node, 0);
|
||||||
if (IS_ERR(clk))
|
if (IS_ERR(clk)) {
|
||||||
panic("%s: of_clk_get failed\n", node->full_name);
|
pr_err("%s: of_clk_get failed\n", node->full_name);
|
||||||
|
return PTR_ERR(clk);
|
||||||
|
}
|
||||||
|
|
||||||
pclk = clk_get_rate(clk);
|
pclk = clk_get_rate(clk);
|
||||||
|
|
||||||
if (clocksource_mmio_init(base + TIMER2_BASE + REG_COUNT,
|
ret = clocksource_mmio_init(base + TIMER2_BASE + REG_COUNT,
|
||||||
"moxart_timer", pclk, 200, 32,
|
"moxart_timer", pclk, 200, 32,
|
||||||
clocksource_mmio_readl_down))
|
clocksource_mmio_readl_down);
|
||||||
panic("%s: clocksource_mmio_init failed\n", node->full_name);
|
if (ret) {
|
||||||
|
pr_err("%s: clocksource_mmio_init failed\n", node->full_name);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
clock_count_per_tick = DIV_ROUND_CLOSEST(pclk, HZ);
|
clock_count_per_tick = DIV_ROUND_CLOSEST(pclk, HZ);
|
||||||
|
|
||||||
|
@ -164,5 +175,7 @@ static void __init moxart_timer_init(struct device_node *node)
|
||||||
*/
|
*/
|
||||||
clockevents_config_and_register(&moxart_clockevent, pclk,
|
clockevents_config_and_register(&moxart_clockevent, pclk,
|
||||||
0x4, 0xfffffffe);
|
0x4, 0xfffffffe);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
CLOCKSOURCE_OF_DECLARE(moxart, "moxa,moxart-timer", moxart_timer_init);
|
CLOCKSOURCE_OF_DECLARE_RET(moxart, "moxa,moxart-timer", moxart_timer_init);
|
||||||
|
|
Loading…
Add table
Reference in a new issue