clocksource/drivers/nomadik-mtu: 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
e1d2b9f024
commit
e46105aff5
@ -193,10 +193,11 @@ static struct irqaction nmdk_timer_irq = {
|
|||||||
.dev_id = &nmdk_clkevt,
|
.dev_id = &nmdk_clkevt,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void __init nmdk_timer_init(void __iomem *base, int irq,
|
static int __init nmdk_timer_init(void __iomem *base, int irq,
|
||||||
struct clk *pclk, struct clk *clk)
|
struct clk *pclk, struct clk *clk)
|
||||||
{
|
{
|
||||||
unsigned long rate;
|
unsigned long rate;
|
||||||
|
int ret;
|
||||||
|
|
||||||
mtu_base = base;
|
mtu_base = base;
|
||||||
|
|
||||||
@ -226,10 +227,12 @@ static void __init nmdk_timer_init(void __iomem *base, int irq,
|
|||||||
/* Timer 0 is the free running clocksource */
|
/* Timer 0 is the free running clocksource */
|
||||||
nmdk_clksrc_reset();
|
nmdk_clksrc_reset();
|
||||||
|
|
||||||
if (clocksource_mmio_init(mtu_base + MTU_VAL(0), "mtu_0",
|
ret = clocksource_mmio_init(mtu_base + MTU_VAL(0), "mtu_0",
|
||||||
rate, 200, 32, clocksource_mmio_readl_down))
|
rate, 200, 32, clocksource_mmio_readl_down);
|
||||||
pr_err("timer: failed to initialize clock source %s\n",
|
if (ret) {
|
||||||
"mtu_0");
|
pr_err("timer: failed to initialize clock source %s\n", "mtu_0");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_CLKSRC_NOMADIK_MTU_SCHED_CLOCK
|
#ifdef CONFIG_CLKSRC_NOMADIK_MTU_SCHED_CLOCK
|
||||||
sched_clock_register(nomadik_read_sched_clock, 32, rate);
|
sched_clock_register(nomadik_read_sched_clock, 32, rate);
|
||||||
@ -244,9 +247,11 @@ static void __init nmdk_timer_init(void __iomem *base, int irq,
|
|||||||
mtu_delay_timer.read_current_timer = &nmdk_timer_read_current_timer;
|
mtu_delay_timer.read_current_timer = &nmdk_timer_read_current_timer;
|
||||||
mtu_delay_timer.freq = rate;
|
mtu_delay_timer.freq = rate;
|
||||||
register_current_timer_delay(&mtu_delay_timer);
|
register_current_timer_delay(&mtu_delay_timer);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __init nmdk_timer_of_init(struct device_node *node)
|
static int __init nmdk_timer_of_init(struct device_node *node)
|
||||||
{
|
{
|
||||||
struct clk *pclk;
|
struct clk *pclk;
|
||||||
struct clk *clk;
|
struct clk *clk;
|
||||||
@ -254,22 +259,30 @@ static void __init nmdk_timer_of_init(struct device_node *node)
|
|||||||
int irq;
|
int irq;
|
||||||
|
|
||||||
base = of_iomap(node, 0);
|
base = of_iomap(node, 0);
|
||||||
if (!base)
|
if (!base) {
|
||||||
panic("Can't remap registers");
|
pr_err("Can't remap registers");
|
||||||
|
return -ENXIO;
|
||||||
|
}
|
||||||
|
|
||||||
pclk = of_clk_get_by_name(node, "apb_pclk");
|
pclk = of_clk_get_by_name(node, "apb_pclk");
|
||||||
if (IS_ERR(pclk))
|
if (IS_ERR(pclk)) {
|
||||||
panic("could not get apb_pclk");
|
pr_err("could not get apb_pclk");
|
||||||
|
return PTR_ERR(pclk);
|
||||||
|
}
|
||||||
|
|
||||||
clk = of_clk_get_by_name(node, "timclk");
|
clk = of_clk_get_by_name(node, "timclk");
|
||||||
if (IS_ERR(clk))
|
if (IS_ERR(clk)) {
|
||||||
panic("could not get timclk");
|
pr_err("could not get timclk");
|
||||||
|
return PTR_ERR(clk);
|
||||||
|
}
|
||||||
|
|
||||||
irq = irq_of_parse_and_map(node, 0);
|
irq = irq_of_parse_and_map(node, 0);
|
||||||
if (irq <= 0)
|
if (irq <= 0) {
|
||||||
panic("Can't parse IRQ");
|
pr_err("Can't parse IRQ");
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
nmdk_timer_init(base, irq, pclk, clk);
|
return nmdk_timer_init(base, irq, pclk, clk);
|
||||||
}
|
}
|
||||||
CLOCKSOURCE_OF_DECLARE(nomadik_mtu, "st,nomadik-mtu",
|
CLOCKSOURCE_OF_DECLARE_RET(nomadik_mtu, "st,nomadik-mtu",
|
||||||
nmdk_timer_of_init);
|
nmdk_timer_of_init);
|
||||||
|
Loading…
Reference in New Issue
Block a user