]> rtime.felk.cvut.cz Git - hercules2020/nv-tegra/linux-4.4.git/commitdiff
input: touch: raydium: wait in suspend if driver is resuming
authorDarren Sun <darrens@nvidia.com>
Tue, 20 Jun 2017 09:18:42 +0000 (17:18 +0800)
committermobile promotions <svcmobile_promotions@nvidia.com>
Thu, 22 Jun 2017 14:47:00 +0000 (07:47 -0700)
If we press power button to enable/disable touch
within a short period, the driver will send
suspend command via spi when the resume step is
still processing. This will lead to a crash.

Add a check before we do suspend process and
set the timeout to 1 second.

Bug 200317440

Change-Id: Id72045856793f726ac5a6c644945dc7325097c8b
Signed-off-by: Darren Sun <darrens@nvidia.com>
(cherry picked from commit 0550360fcf3c352516e5f99912e4190c768e8e5b)
Reviewed-on: http://git-master/r/1506233
GVS: Gerrit_Virtual_Submit
Reviewed-by: Jordan Nien <jnien@nvidia.com>
Reviewed-by: Hayden Du <haydend@nvidia.com>
drivers/input/touchscreen/rm31080a_ts.c

index 3d4e4682d1b55facaf034eb3eb7cc1c0cc412cf3..91fe2e1a35da0220086c9b1f0878eaf4fd4c635d 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (C) 2012-2016, Raydium Semiconductor Corporation.
  * All Rights Reserved.
- * Copyright (C) 2012-2016, NVIDIA Corporation.  All Rights Reserved.
+ * Copyright (C) 2012-2017, NVIDIA Corporation.  All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
@@ -87,7 +87,7 @@
 #define RM_NEED_TO_READ_RAW_DATA       0x02
 #define RM_NEED_TO_SEND_SIGNAL         0x04
 
-#define TCH_WAKE_LOCK_TIMEOUT          (HZ/2)
+#define TCH_WAKE_LOCK_TIMEOUT          (1*HZ)
 
 #if ENABLE_FREQ_HOPPING  /*ENABLE_SCAN_DATA_HEADER*/
 #define QUEUE_HEADER_NUM                       (8)
@@ -3267,7 +3267,16 @@ static void rm_ctrl_suspend(struct rm_tch_ts *ts)
 static int rm_tch_suspend(struct rm_tch_ts *ts)
 {
        if (g_st_ts.b_init_service) {
+               int timeout = 1000; /* timeout 1000ms */
                dev_info(ts->dev, "Raydium - Disable input device\n");
+               while (g_st_ts.u8_resume_cnt != 0 &&
+                               g_st_ts.b_init_finish != 1 &&
+                               timeout > 0) {
+                       usleep_range(5000, 6000); /* msleep(5) */
+                       timeout -= 5;
+               }
+               if (timeout <= 0)
+                       dev_warn(ts->dev, "Raydium - resume timeout, try to suspend directly\n");
                rm_ctrl_suspend(ts);
                dev_info(ts->dev, "Raydium - Disable input device done\n");
        }