diff options
author | Daniel Lezcano <daniel.lezcano@linaro.org> | 2016-06-16 12:10:58 -0400 |
---|---|---|
committer | Daniel Lezcano <daniel.lezcano@linaro.org> | 2016-06-28 04:19:35 -0400 |
commit | 8595b1ba14f763da8c406c8a243510fa13097214 (patch) | |
tree | 46b824569e29276717491e43a1dfcc7f5aabfd54 | |
parent | 43d7560494a264a34e8bb5257ef43b0be6134dac (diff) |
clocksource/drivers/oxnas-rps: 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>
Acked-by: Neil Armstrong <narmstrong@baylibre.com>
-rw-r--r-- | drivers/clocksource/timer-oxnas-rps.c | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/drivers/clocksource/timer-oxnas-rps.c b/drivers/clocksource/timer-oxnas-rps.c index c002e99c5760..0d99f40ee757 100644 --- a/drivers/clocksource/timer-oxnas-rps.c +++ b/drivers/clocksource/timer-oxnas-rps.c | |||
@@ -220,32 +220,37 @@ static int __init oxnas_rps_clocksource_init(struct oxnas_rps_timer *rps) | |||
220 | return 0; | 220 | return 0; |
221 | } | 221 | } |
222 | 222 | ||
223 | static void __init oxnas_rps_timer_init(struct device_node *np) | 223 | static int __init oxnas_rps_timer_init(struct device_node *np) |
224 | { | 224 | { |
225 | struct oxnas_rps_timer *rps; | 225 | struct oxnas_rps_timer *rps; |
226 | void __iomem *base; | 226 | void __iomem *base; |
227 | int ret; | 227 | int ret; |
228 | 228 | ||
229 | rps = kzalloc(sizeof(*rps), GFP_KERNEL); | 229 | rps = kzalloc(sizeof(*rps), GFP_KERNEL); |
230 | if (!rps) { | 230 | if (!rps) |
231 | pr_err("Failed to allocate rps structure\n"); | 231 | return -ENOMEM; |
232 | return; | ||
233 | } | ||
234 | 232 | ||
235 | rps->clk = of_clk_get(np, 0); | 233 | rps->clk = of_clk_get(np, 0); |
236 | if (WARN_ON(IS_ERR(rps->clk))) | 234 | if (IS_ERR(rps->clk)) { |
235 | ret = PTR_ERR(rps->clk); | ||
237 | goto err_alloc; | 236 | goto err_alloc; |
237 | } | ||
238 | 238 | ||
239 | if (WARN_ON(clk_prepare_enable(rps->clk))) | 239 | ret = clk_prepare_enable(rps->clk); |
240 | if (ret) | ||
240 | goto err_clk; | 241 | goto err_clk; |
241 | 242 | ||
242 | base = of_iomap(np, 0); | 243 | base = of_iomap(np, 0); |
243 | if (WARN_ON(!base)) | 244 | if (!base) { |
245 | ret = -ENXIO; | ||
244 | goto err_clk_prepare; | 246 | goto err_clk_prepare; |
247 | } | ||
245 | 248 | ||
246 | rps->irq = irq_of_parse_and_map(np, 0); | 249 | rps->irq = irq_of_parse_and_map(np, 0); |
247 | if (WARN_ON(rps->irq < 0)) | 250 | if (rps->irq < 0) { |
251 | ret = -EINVAL; | ||
248 | goto err_iomap; | 252 | goto err_iomap; |
253 | } | ||
249 | 254 | ||
250 | rps->clkevt_base = base + TIMER1_REG_OFFSET; | 255 | rps->clkevt_base = base + TIMER1_REG_OFFSET; |
251 | rps->clksrc_base = base + TIMER2_REG_OFFSET; | 256 | rps->clksrc_base = base + TIMER2_REG_OFFSET; |
@@ -261,7 +266,7 @@ static void __init oxnas_rps_timer_init(struct device_node *np) | |||
261 | ret = request_irq(rps->irq, oxnas_rps_timer_irq, | 266 | ret = request_irq(rps->irq, oxnas_rps_timer_irq, |
262 | IRQF_TIMER | IRQF_IRQPOLL, | 267 | IRQF_TIMER | IRQF_IRQPOLL, |
263 | "rps-timer", rps); | 268 | "rps-timer", rps); |
264 | if (WARN_ON(ret)) | 269 | if (ret) |
265 | goto err_iomap; | 270 | goto err_iomap; |
266 | 271 | ||
267 | ret = oxnas_rps_clocksource_init(rps); | 272 | ret = oxnas_rps_clocksource_init(rps); |
@@ -272,7 +277,7 @@ static void __init oxnas_rps_timer_init(struct device_node *np) | |||
272 | if (ret) | 277 | if (ret) |
273 | goto err_irqreq; | 278 | goto err_irqreq; |
274 | 279 | ||
275 | return; | 280 | return 0; |
276 | 281 | ||
277 | err_irqreq: | 282 | err_irqreq: |
278 | free_irq(rps->irq, rps); | 283 | free_irq(rps->irq, rps); |
@@ -284,7 +289,9 @@ err_clk: | |||
284 | clk_put(rps->clk); | 289 | clk_put(rps->clk); |
285 | err_alloc: | 290 | err_alloc: |
286 | kfree(rps); | 291 | kfree(rps); |
292 | |||
293 | return ret; | ||
287 | } | 294 | } |
288 | 295 | ||
289 | CLOCKSOURCE_OF_DECLARE(ox810se_rps, | 296 | CLOCKSOURCE_OF_DECLARE_RET(ox810se_rps, |
290 | "oxsemi,ox810se-rps-timer", oxnas_rps_timer_init); | 297 | "oxsemi,ox810se-rps-timer", oxnas_rps_timer_init); |