mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-03-30 19:07:15 +00:00
clocksource/drivers/atmel-st: 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
504f34c9e4
commit
adbaf52541
1 changed files with 28 additions and 16 deletions
|
@ -194,15 +194,17 @@ static struct clock_event_device clkevt = {
|
||||||
/*
|
/*
|
||||||
* ST (system timer) module supports both clockevents and clocksource.
|
* ST (system timer) module supports both clockevents and clocksource.
|
||||||
*/
|
*/
|
||||||
static void __init atmel_st_timer_init(struct device_node *node)
|
static int __init atmel_st_timer_init(struct device_node *node)
|
||||||
{
|
{
|
||||||
struct clk *sclk;
|
struct clk *sclk;
|
||||||
unsigned int sclk_rate, val;
|
unsigned int sclk_rate, val;
|
||||||
int irq, ret;
|
int irq, ret;
|
||||||
|
|
||||||
regmap_st = syscon_node_to_regmap(node);
|
regmap_st = syscon_node_to_regmap(node);
|
||||||
if (IS_ERR(regmap_st))
|
if (IS_ERR(regmap_st)) {
|
||||||
panic(pr_fmt("Unable to get regmap\n"));
|
pr_err("Unable to get regmap\n");
|
||||||
|
return PTR_ERR(regmap_st);
|
||||||
|
}
|
||||||
|
|
||||||
/* Disable all timer interrupts, and clear any pending ones */
|
/* Disable all timer interrupts, and clear any pending ones */
|
||||||
regmap_write(regmap_st, AT91_ST_IDR,
|
regmap_write(regmap_st, AT91_ST_IDR,
|
||||||
|
@ -211,27 +213,37 @@ static void __init atmel_st_timer_init(struct device_node *node)
|
||||||
|
|
||||||
/* Get the interrupts property */
|
/* Get the interrupts property */
|
||||||
irq = irq_of_parse_and_map(node, 0);
|
irq = irq_of_parse_and_map(node, 0);
|
||||||
if (!irq)
|
if (!irq) {
|
||||||
panic(pr_fmt("Unable to get IRQ from DT\n"));
|
pr_err("Unable to get IRQ from DT\n");
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
/* Make IRQs happen for the system timer */
|
/* Make IRQs happen for the system timer */
|
||||||
ret = request_irq(irq, at91rm9200_timer_interrupt,
|
ret = request_irq(irq, at91rm9200_timer_interrupt,
|
||||||
IRQF_SHARED | IRQF_TIMER | IRQF_IRQPOLL,
|
IRQF_SHARED | IRQF_TIMER | IRQF_IRQPOLL,
|
||||||
"at91_tick", regmap_st);
|
"at91_tick", regmap_st);
|
||||||
if (ret)
|
if (ret) {
|
||||||
panic(pr_fmt("Unable to setup IRQ\n"));
|
pr_err("Unable to setup IRQ\n");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
sclk = of_clk_get(node, 0);
|
sclk = of_clk_get(node, 0);
|
||||||
if (IS_ERR(sclk))
|
if (IS_ERR(sclk)) {
|
||||||
panic(pr_fmt("Unable to get slow clock\n"));
|
pr_err("Unable to get slow clock\n");
|
||||||
|
return PTR_ERR(sclk);
|
||||||
|
}
|
||||||
|
|
||||||
clk_prepare_enable(sclk);
|
ret = clk_prepare_enable(sclk);
|
||||||
if (ret)
|
if (ret) {
|
||||||
panic(pr_fmt("Could not enable slow clock\n"));
|
pr_err("Could not enable slow clock\n");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
sclk_rate = clk_get_rate(sclk);
|
sclk_rate = clk_get_rate(sclk);
|
||||||
if (!sclk_rate)
|
if (!sclk_rate) {
|
||||||
panic(pr_fmt("Invalid slow clock rate\n"));
|
pr_err("Invalid slow clock rate\n");
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
timer_latch = (sclk_rate + HZ / 2) / HZ;
|
timer_latch = (sclk_rate + HZ / 2) / HZ;
|
||||||
|
|
||||||
/* The 32KiHz "Slow Clock" (tick every 30517.58 nanoseconds) is used
|
/* The 32KiHz "Slow Clock" (tick every 30517.58 nanoseconds) is used
|
||||||
|
@ -246,7 +258,7 @@ static void __init atmel_st_timer_init(struct device_node *node)
|
||||||
2, AT91_ST_ALMV);
|
2, AT91_ST_ALMV);
|
||||||
|
|
||||||
/* register clocksource */
|
/* register clocksource */
|
||||||
clocksource_register_hz(&clk32k, sclk_rate);
|
return clocksource_register_hz(&clk32k, sclk_rate);
|
||||||
}
|
}
|
||||||
CLOCKSOURCE_OF_DECLARE(atmel_st_timer, "atmel,at91rm9200-st",
|
CLOCKSOURCE_OF_DECLARE_RET(atmel_st_timer, "atmel,at91rm9200-st",
|
||||||
atmel_st_timer_init);
|
atmel_st_timer_init);
|
||||||
|
|
Loading…
Add table
Reference in a new issue