Skip to content

Commit ca46acb

Browse files
committed
clocksource/drivers/meson6_timer.c: 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 f2f9900 commit ca46acb

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

drivers/clocksource/meson6_timer.c

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,18 +126,22 @@ static struct irqaction meson6_timer_irq = {
126126
.dev_id = &meson6_clockevent,
127127
};
128128

129-
static void __init meson6_timer_init(struct device_node *node)
129+
static int __init meson6_timer_init(struct device_node *node)
130130
{
131131
u32 val;
132132
int ret, irq;
133133

134134
timer_base = of_io_request_and_map(node, 0, "meson6-timer");
135-
if (IS_ERR(timer_base))
136-
panic("Can't map registers");
135+
if (IS_ERR(timer_base)) {
136+
pr_err("Can't map registers");
137+
return -ENXIO;
138+
}
137139

138140
irq = irq_of_parse_and_map(node, 0);
139-
if (irq <= 0)
140-
panic("Can't parse IRQ");
141+
if (irq <= 0) {
142+
pr_err("Can't parse IRQ");
143+
return -EINVAL;
144+
}
141145

142146
/* Set 1us for timer E */
143147
val = readl(timer_base + TIMER_ISA_MUX);
@@ -158,14 +162,17 @@ static void __init meson6_timer_init(struct device_node *node)
158162
meson6_clkevt_time_stop(CED_ID);
159163

160164
ret = setup_irq(irq, &meson6_timer_irq);
161-
if (ret)
165+
if (ret) {
162166
pr_warn("failed to setup irq %d\n", irq);
167+
return ret;
168+
}
163169

164170
meson6_clockevent.cpumask = cpu_possible_mask;
165171
meson6_clockevent.irq = irq;
166172

167173
clockevents_config_and_register(&meson6_clockevent, USEC_PER_SEC,
168174
1, 0xfffe);
175+
return 0;
169176
}
170-
CLOCKSOURCE_OF_DECLARE(meson6, "amlogic,meson6-timer",
177+
CLOCKSOURCE_OF_DECLARE_RET(meson6, "amlogic,meson6-timer",
171178
meson6_timer_init);

0 commit comments

Comments
 (0)