ARM: OMAP: CPUidle: Unregister drivere on device registration failure
authorSantosh Shilimkar <santosh.shilimkar@ti.com>
Mon, 25 Mar 2013 10:05:05 +0000 (15:35 +0530)
committerKevin Hilman <khilman@linaro.org>
Tue, 9 Apr 2013 16:45:45 +0000 (09:45 -0700)
If the CPUidle device registration fails for some reason, we should
unregister the driver on error path.

Fix the code accordingly. Also when at it, check of the driver registration
failure too.

Acked-by: Nishanth Menon <nm@ti.com>
Signed-off-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
Signed-off-by: Kevin Hilman <khilman@linaro.org>
arch/arm/mach-omap2/cpuidle34xx.c
arch/arm/mach-omap2/cpuidle44xx.c

index 4f67a5b..a300122 100644 (file)
@@ -359,7 +359,10 @@ int __init omap3_idle_init(void)
        if (!mpu_pd || !core_pd || !per_pd || !cam_pd)
                return -ENODEV;
 
-       cpuidle_register_driver(&omap3_idle_driver);
+       if (cpuidle_register_driver(&omap3_idle_driver)) {
+               pr_err("%s: CPUidle driver register failed\n", __func__);
+               return -EIO;
+       }
 
        dev = &per_cpu(omap3_idle_dev, smp_processor_id());
        dev->cpu = 0;
@@ -367,6 +370,7 @@ int __init omap3_idle_init(void)
        if (cpuidle_register_device(dev)) {
                printk(KERN_ERR "%s: CPUidle register device failed\n",
                       __func__);
+               cpuidle_unregister_driver(&omap3_idle_driver);
                return -EIO;
        }
 
index 72c5407..aeeb8e6 100644 (file)
@@ -222,7 +222,10 @@ int __init omap4_idle_init(void)
        if (!cpu_clkdm[0] || !cpu_clkdm[1])
                return -ENODEV;
 
-       cpuidle_register_driver(&omap4_idle_driver);
+       if (cpuidle_register_driver(&omap4_idle_driver)) {
+               pr_err("%s: CPUidle driver register failed\n", __func__);
+               return -EIO;
+       }
 
        for_each_cpu(cpu_id, cpu_online_mask) {
                dev = &per_cpu(omap4_idle_dev, cpu_id);
@@ -232,6 +235,7 @@ int __init omap4_idle_init(void)
 #endif
                if (cpuidle_register_device(dev)) {
                        pr_err("%s: CPUidle register failed\n", __func__);
+                       cpuidle_unregister_driver(&omap4_idle_driver);
                        return -EIO;
                }
        }