Revert "Revert "input: touch: maxim_sti: Check thread stop condition""
Bo Kim [Tue, 12 Nov 2013 05:44:39 +0000 (14:44 +0900)]
This reverts commit 1bc450b4caa8c4278f1319762831c4eac9d35af2.

Bug 404490

Change-Id: I3741958a904b64e3e9ccd8d4b5d4607bb321805f
Signed-off-by: Bo Kim <bok@nvidia.com>
Reviewed-on: http://git-master/r/329442
Reviewed-by: Harry Hong <hhong@nvidia.com>
Tested-by: Harry Hong <hhong@nvidia.com>

drivers/input/touchscreen/maxim_sti.c

index 23910d6..67b4356 100644 (file)
 #include <linux/maxim_sti.h>
 #include <asm/byteorder.h>  /* MUST include this header to get byte order */
 
+#ifdef CONFIG_PM_WAKELOCKS
+#include <linux/pm_wakeup.h>
+#endif
+
 #define CREATE_TRACE_POINTS
 #include <trace/events/touchscreen_maxim.h>
 
@@ -100,6 +104,9 @@ struct dev_data {
 #if NV_ENABLE_CPU_BOOST
        unsigned long                last_irq_jiffies;
 #endif
+#ifdef CONFIG_PM_WAKELOCKS
+       struct wakeup_source         ws;
+#endif
 };
 
 atomic_t touch_dvdd_on = ATOMIC_INIT(1);
@@ -784,6 +791,9 @@ static int suspend(struct device *dev)
                return ret;
 #endif
 
+#ifdef CONFIG_PM_WAKELOCKS
+       __pm_relax(&dd->ws);
+#endif
        INFO("suspend...done");
 
        return 0;
@@ -800,6 +810,10 @@ static int resume(struct device *dev)
        if (!dd->suspend_in_progress)
                return 0;
 
+#ifdef CONFIG_PM_WAKELOCKS
+       __pm_stay_awake(&dd->ws);
+#endif
+
 #if SUSPEND_POWER_OFF
        /* power-up and reset-high */
        pdata->reset(pdata, 0);
@@ -1611,11 +1625,16 @@ static int processing_thread(void *arg)
                        complete(&dd->suspend_resume);
 
                        INFO("%s: suspended.", __func__);
-                       while (!dd->resume_in_progress) {
+
+                       dd->expect_resume_ack = true;
+                       while (!dd->resume_in_progress &&
+                                       !kthread_should_stop()) {
                                /* the line below is a MUST */
                                set_current_state(TASK_INTERRUPTIBLE);
                                schedule();
                        }
+                       if (kthread_should_stop())
+                               break;
 
                        INFO("%s: resuming.", __func__);
 
@@ -1660,11 +1679,13 @@ static int processing_thread(void *arg)
                                if (ret2 < 0)
                                        ERROR("could not allocate outgoing " \
                                              "skb (%d)", ret2);
-                       } while (ret != 0);
-                       if (fusion_dead)
-                               continue;
+                       } while (ret != 0 && !kthread_should_stop());
+                       if (kthread_should_stop())
+                               break;
                        if (ret == 0)
                                INFO("%s: resumed.", __func__);
+                       if (fusion_dead)
+                               continue;
                }
 
                /* priority 4: service interrupt */
@@ -1810,6 +1831,10 @@ static int probe(struct spi_device *spi)
        dd->last_irq_jiffies = jiffies;
 #endif
 
+#ifdef CONFIG_PM_WAKELOCKS
+       wakeup_source_init(&dd->ws, "touch_fusion");
+       __pm_stay_awake(&dd->ws);
+#endif
        /* start up Touch Fusion */
        wake_up_process(dd->thread);
        INFO("driver loaded; version %s; release date %s", DRIVER_VERSION,
@@ -1854,8 +1879,6 @@ static int remove(struct spi_device *spi)
        /* 4) above step (3) insures that all Netlink senders are           */
        /*    definitely gone and it is safe to free up outgoing skb buffer */
        /*    and incoming skb queue                                        */
-       dd->nl_enabled = false;
-       (void)kthread_stop(dd->thread);
        genl_unregister_family(&dd->nl_family);
        kfree_skb(dd->outgoing_skb);
        skb_queue_purge(&dd->incoming_skb_queue);