cyttsp: move early_suspend registration to the end of probe
authorJianwei Yang <jianwei.yang@intel.com>
Wed, 3 Aug 2011 04:36:55 +0000 (12:36 +0800)
committermgross <mark.gross@intel.com>
Wed, 9 Nov 2011 20:37:52 +0000 (12:37 -0800)
BZ: 6424

early_suspend may be registered even if driver probe fails, this
will cause kernel panic when the early_suspend is executed without
driver registered.

Change-Id: If898bce838f40a4c28e7c4b997e742c541891618
Signed-off-by: Jianwei Yang <jianwei.yang@intel.com>
drivers/input/touchscreen/cyttsp_core.c

index 47d8e18..bf2de56 100644 (file)
@@ -1563,13 +1563,6 @@ int cyttsp_core_init(void *bus_priv, struct cyttsp_bus_ops *bus_ops,
        ts->bus_ops = bus_ops;
        ts->bus_priv = bus_priv;
 
-#ifdef CONFIG_HAS_EARLYSUSPEND
-       ts->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1;
-       ts->early_suspend.suspend = cyttsp_early_suspend;
-       ts->early_suspend.resume = cyttsp_late_resume;
-       register_early_suspend(&ts->early_suspend);
-#endif
-
        if (ts->platform_data->init)
                retval = ts->platform_data->init(1);
        if (retval) {
@@ -1683,6 +1676,14 @@ int cyttsp_core_init(void *bus_priv, struct cyttsp_bus_ops *bus_ops,
                goto device_create_error;
        }
        dev_set_drvdata(pdev, ts);
+
+#ifdef CONFIG_HAS_EARLYSUSPEND
+       ts->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1;
+       ts->early_suspend.suspend = cyttsp_early_suspend;
+       ts->early_suspend.resume = cyttsp_late_resume;
+       register_early_suspend(&ts->early_suspend);
+#endif
+
        return 0;
 
 device_create_error:
@@ -1717,6 +1718,8 @@ void cyttsp_core_release(void *handle)
                free_irq(ts->irq, ts);
        input_unregister_device(ts->input);
        input_free_device(ts->input);
+       unregister_early_suspend(&ts->early_suspend);
+
        if (ts->platform_data->init)
                ts->platform_data->init(0);
        kfree(ts);