OSDN Git Service

input: touchscreen: don't allow ITE tech driver to do infinite i2c checks
authorShantanu Jain <shjain@codeaurora.org>
Thu, 10 Dec 2015 10:57:17 +0000 (16:27 +0530)
committerAbinaya P <abinayap@codeaurora.org>
Fri, 5 Aug 2016 14:52:47 +0000 (20:22 +0530)
Don't allow ITE tech driver to check the status of the controller forever
before any i2c read/write, instead make it to 10 times only.
In case of firmware flashing and external calibration features, this is
made to 500 times.

This is a propagated patch from 3.18 kernel
'commit 5e8c98c6705b ("input: touchscreen: don't allow ITE tech driver
to do infinite i2c checks")'

Change-Id: I88e024700de43cc9f712fd7fa509fcb387f9cd21
Signed-off-by: Shantanu Jain <shjain@codeaurora.org>
drivers/input/touchscreen/it7258_ts_i2c.c

index 5faad26..44abee3 100644 (file)
 #define FW_WRITE_RETRY_COUNT           4
 #define CHIP_FLASH_SIZE                        0x8000
 #define DEVICE_READY_MAX_WAIT          500
+#define DEVICE_READY_WAIT_10           10
 
 /* result of reading with BUF_QUERY bits */
 #define CMD_STATUS_BITS                        0x07
@@ -284,7 +285,10 @@ static bool IT7260_i2cWriteNoReadyCheck(uint8_t buf_index,
 static bool IT7260_waitDeviceReady(bool forever, bool slowly)
 {
        uint8_t query;
-       uint32_t count = DEVICE_READY_MAX_WAIT;
+       uint32_t count = DEVICE_READY_WAIT_10;
+
+       if (gl_ts->fw_cfg_uploading || forever)
+               count = DEVICE_READY_MAX_WAIT;
 
        do {
                if (!IT7260_i2cReadNoReadyCheck(BUF_QUERY, &query,
@@ -293,10 +297,7 @@ static bool IT7260_waitDeviceReady(bool forever, bool slowly)
 
                if (slowly)
                        msleep(IT_I2C_WAIT);
-               if (!forever)
-                       count--;
-
-       } while ((query & CMD_STATUS_BUSY) && count);
+       } while ((query & CMD_STATUS_BUSY) && --count);
 
        return !query;
 }