Skip to content

Commit b7357e6

Browse files
author
Daniel Lezcano
committed
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>
1 parent d8152bf commit b7357e6

1 file changed

Lines changed: 27 additions & 14 deletions

File tree

‎drivers/clocksource/moxart_timer.c‎

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -119,34 +119,45 @@ static struct irqaction moxart_timer_irq = {
119119
.dev_id = &moxart_clockevent,
120120
};
121121

122-
static void __init moxart_timer_init(struct device_node *node)
122+
static int __init moxart_timer_init(struct device_node *node)
123123
{
124124
int ret, irq;
125125
unsigned long pclk;
126126
struct clk *clk;
127127

128128
base = of_iomap(node, 0);
129-
if (!base)
130-
panic("%s: of_iomap failed\n", node->full_name);
129+
if (!base) {
130+
pr_err("%s: of_iomap failed\n", node->full_name);
131+
return -ENXIO;
132+
}
131133

132134
irq = irq_of_parse_and_map(node, 0);
133-
if (irq <= 0)
134-
panic("%s: irq_of_parse_and_map failed\n", node->full_name);
135+
if (irq <= 0) {
136+
pr_err("%s: irq_of_parse_and_map failed\n", node->full_name);
137+
return -EINVAL;
138+
}
135139

136140
ret = setup_irq(irq, &moxart_timer_irq);
137-
if (ret)
138-
panic("%s: setup_irq failed\n", node->full_name);
141+
if (ret) {
142+
pr_err("%s: setup_irq failed\n", node->full_name);
143+
return ret;
144+
}
139145

140146
clk = of_clk_get(node, 0);
141-
if (IS_ERR(clk))
142-
panic("%s: of_clk_get failed\n", node->full_name);
147+
if (IS_ERR(clk)) {
148+
pr_err("%s: of_clk_get failed\n", node->full_name);
149+
return PTR_ERR(clk);
150+
}
143151

144152
pclk = clk_get_rate(clk);
145153

146-
if (clocksource_mmio_init(base + TIMER2_BASE + REG_COUNT,
147-
"moxart_timer", pclk, 200, 32,
148-
clocksource_mmio_readl_down))
149-
panic("%s: clocksource_mmio_init failed\n", node->full_name);
154+
ret = clocksource_mmio_init(base + TIMER2_BASE + REG_COUNT,
155+
"moxart_timer", pclk, 200, 32,
156+
clocksource_mmio_readl_down);
157+
if (ret) {
158+
pr_err("%s: clocksource_mmio_init failed\n", node->full_name);
159+
return ret;
160+
}
150161

151162
clock_count_per_tick = DIV_ROUND_CLOSEST(pclk, HZ);
152163

@@ -164,5 +175,7 @@ static void __init moxart_timer_init(struct device_node *node)
164175
*/
165176
clockevents_config_and_register(&moxart_clockevent, pclk,
166177
0x4, 0xfffffffe);
178+
179+
return 0;
167180
}
168-
CLOCKSOURCE_OF_DECLARE(moxart, "moxa,moxart-timer", moxart_timer_init);
181+
CLOCKSOURCE_OF_DECLARE_RET(moxart, "moxa,moxart-timer", moxart_timer_init);

0 commit comments

Comments
 (0)