Input: iqs7222 - handle reset during ATI
authorJeff LaBundy <jeff@labundy.com>
Mon, 27 Jun 2022 22:15:09 +0000 (15:15 -0700)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Mon, 27 Jun 2022 22:25:57 +0000 (15:25 -0700)
If the device suffers a spurious reset during ATI, there is no point
in enduring any further retries. Instead, simply return successfully
from the polling loop.

In this case, the interrupt handler will intervene and recognize the
device has been reset. It then proceeds to initialize the device and
trigger ATI once more.

As part of this change, swap the order of status field evaluation to
match that of the interrupt handler, and correct a nearby off-by-one
error that causes an error message to suggest the final attempt will
be retried.

Fixes: e505edaedcb9 ("Input: add support for Azoteq IQS7222A/B/C")
Signed-off-by: Jeff LaBundy <jeff@labundy.com>
Link: https://lore.kernel.org/r/20220626072412.475211-6-jeff@labundy.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
drivers/input/misc/iqs7222.c

index aa46f2cd4d34a69b224f6460f733e8133afd798b..e65260d290cc6fe2bd4ae162f81bc0f087f5231c 100644 (file)
@@ -1314,12 +1314,15 @@ static int iqs7222_ati_trigger(struct iqs7222_private *iqs7222)
                        if (error)
                                return error;
 
-                       if (sys_status & IQS7222_SYS_STATUS_ATI_ACTIVE)
-                               continue;
+                       if (sys_status & IQS7222_SYS_STATUS_RESET)
+                               return 0;
 
                        if (sys_status & IQS7222_SYS_STATUS_ATI_ERROR)
                                break;
 
+                       if (sys_status & IQS7222_SYS_STATUS_ATI_ACTIVE)
+                               continue;
+
                        /*
                         * Use stream-in-touch mode if either slider reports
                         * absolute position.
@@ -1336,7 +1339,7 @@ static int iqs7222_ati_trigger(struct iqs7222_private *iqs7222)
                dev_err(&client->dev,
                        "ATI attempt %d of %d failed with status 0x%02X, %s\n",
                        i + 1, IQS7222_NUM_RETRIES, (u8)sys_status,
-                       i < IQS7222_NUM_RETRIES ? "retrying..." : "stopping");
+                       i + 1 < IQS7222_NUM_RETRIES ? "retrying" : "stopping");
        }
 
        return -ETIMEDOUT;