]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
clocksource/drivers/vt8500: Convert init function to return error
authorDaniel Lezcano <daniel.lezcano@linaro.org>
Mon, 6 Jun 2016 21:30:04 +0000 (23:30 +0200)
committerDaniel Lezcano <daniel.lezcano@linaro.org>
Tue, 28 Jun 2016 08:19:33 +0000 (10:19 +0200)
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>
drivers/clocksource/vt8500_timer.c

index ddb409274f45a72a6b3af5289ee1779396523f73..1bc8707b4f9d32894331b8acb49559ae40d475f7 100644 (file)
@@ -121,38 +121,48 @@ static struct irqaction irq = {
        .dev_id  = &clockevent,
 };
 
-static void __init vt8500_timer_init(struct device_node *np)
+static int __init vt8500_timer_init(struct device_node *np)
 {
-       int timer_irq;
+       int timer_irq, ret;
 
        regbase = of_iomap(np, 0);
        if (!regbase) {
                pr_err("%s: Missing iobase description in Device Tree\n",
                                                                __func__);
-               return;
+               return -ENXIO;
        }
+
        timer_irq = irq_of_parse_and_map(np, 0);
        if (!timer_irq) {
                pr_err("%s: Missing irq description in Device Tree\n",
                                                                __func__);
-               return;
+               return -EINVAL;
        }
 
        writel(1, regbase + TIMER_CTRL_VAL);
        writel(0xf, regbase + TIMER_STATUS_VAL);
        writel(~0, regbase + TIMER_MATCH_VAL);
 
-       if (clocksource_register_hz(&clocksource, VT8500_TIMER_HZ))
+       ret = clocksource_register_hz(&clocksource, VT8500_TIMER_HZ);
+       if (ret) {
                pr_err("%s: vt8500_timer_init: clocksource_register failed for %s\n",
-                                       __func__, clocksource.name);
+                      __func__, clocksource.name);
+               return ret;
+       }
 
        clockevent.cpumask = cpumask_of(0);
 
-       if (setup_irq(timer_irq, &irq))
+       ret = setup_irq(timer_irq, &irq);
+       if (ret) {
                pr_err("%s: setup_irq failed for %s\n", __func__,
                                                        clockevent.name);
+               return ret;
+       }
+
        clockevents_config_and_register(&clockevent, VT8500_TIMER_HZ,
                                        MIN_OSCR_DELTA * 2, 0xf0000000);
+
+       return 0;
 }
 
-CLOCKSOURCE_OF_DECLARE(vt8500, "via,vt8500-timer", vt8500_timer_init);
+CLOCKSOURCE_OF_DECLARE_RET(vt8500, "via,vt8500-timer", vt8500_timer_init);