Skip to content

Commit d8152bf

Browse files
committed
clocksource/drivers/mips-gic-timer: 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 ca46acb commit d8152bf

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

drivers/clocksource/mips-gic-timer.c

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ static struct clocksource gic_clocksource = {
146146
.archdata = { .vdso_clock_mode = VDSO_CLOCK_GIC },
147147
};
148148

149-
static void __init __gic_clocksource_init(void)
149+
static int __init __gic_clocksource_init(void)
150150
{
151151
int ret;
152152

@@ -159,6 +159,8 @@ static void __init __gic_clocksource_init(void)
159159
ret = clocksource_register_hz(&gic_clocksource, gic_frequency);
160160
if (ret < 0)
161161
pr_warn("GIC: Unable to register clocksource\n");
162+
163+
return ret;
162164
}
163165

164166
void __init gic_clocksource_init(unsigned int frequency)
@@ -179,31 +181,35 @@ static void __init gic_clocksource_of_init(struct device_node *node)
179181
struct clk *clk;
180182
int ret;
181183

182-
if (WARN_ON(!gic_present || !node->parent ||
183-
!of_device_is_compatible(node->parent, "mti,gic")))
184-
return;
184+
if (!gic_present || !node->parent ||
185+
!of_device_is_compatible(node->parent, "mti,gic")) {
186+
pr_warn("No DT definition for the mips gic driver");
187+
return -ENXIO;
188+
}
185189

186190
clk = of_clk_get(node, 0);
187191
if (!IS_ERR(clk)) {
188192
if (clk_prepare_enable(clk) < 0) {
189193
pr_err("GIC failed to enable clock\n");
190194
clk_put(clk);
191-
return;
195+
return PTR_ERR(clk);
192196
}
193197

194198
gic_frequency = clk_get_rate(clk);
195199
} else if (of_property_read_u32(node, "clock-frequency",
196200
&gic_frequency)) {
197201
pr_err("GIC frequency not specified.\n");
198-
return;
202+
return -EINVAL;;
199203
}
200204
gic_timer_irq = irq_of_parse_and_map(node, 0);
201205
if (!gic_timer_irq) {
202206
pr_err("GIC timer IRQ not specified.\n");
203-
return;
207+
return -EINVAL;;
204208
}
205209

206-
__gic_clocksource_init();
210+
ret = __gic_clocksource_init();
211+
if (ret)
212+
return ret;
207213

208214
ret = gic_clockevent_init();
209215
if (!ret && !IS_ERR(clk)) {
@@ -213,6 +219,8 @@ static void __init gic_clocksource_of_init(struct device_node *node)
213219

214220
/* And finally start the counter */
215221
gic_start_count();
222+
223+
return 0;
216224
}
217-
CLOCKSOURCE_OF_DECLARE(mips_gic_timer, "mti,gic-timer",
225+
CLOCKSOURCE_OF_DECLARE_RET(mips_gic_timer, "mti,gic-timer",
218226
gic_clocksource_of_init);

0 commit comments

Comments
 (0)