]> git.proxmox.com Git - mirror_ubuntu-impish-kernel.git/commitdiff
UBUNTU: SAUCE: Input: i8042 - fix the selftest retry logic
authorYou-Sheng Yang <vicamo.yang@canonical.com>
Mon, 16 Mar 2020 09:27:21 +0000 (17:27 +0800)
committerAndrea Righi <andrea.righi@canonical.com>
Mon, 28 Jun 2021 06:03:50 +0000 (08:03 +0200)
BugLink: https://bugs.launchpad.net/bugs/1866734
It returns -NODEV at the first selftest timeout, so the retry logic
doesn't work. Move the return outside of the while loop to make it real
retry 5 times before returns -ENODEV.

BTW, the origin loop will retry 6 times, also fix this.

Signed-off-by: You-Sheng Yang <vicamo.yang@canonical.com>
(backported from
https://lore.kernel.org/linux-input/20200310033640.14440-1-vicamo@gmail.com/)
Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
drivers/input/serio/i8042.c

index f8617c1b242ef14113bc8f6ef1d6fd6235de8b1f..dbe1810e62427a5d2fdf8e884fe7586ec3dedf21 100644 (file)
@@ -943,25 +943,28 @@ static int i8042_controller_selftest(void)
 {
        unsigned char param;
        int i = 0;
+       int ret;
 
        /*
         * We try this 5 times; on some really fragile systems this does not
         * take the first time...
         */
-       do {
-
-               if (i8042_command(&param, I8042_CMD_CTL_TEST)) {
-                       pr_info("i8042 controller selftest timeout\n");
-                       return -ENODEV;
-               }
+       while (i++ < 5) {
 
-               if (param == I8042_RET_CTL_TEST)
+               ret = i8042_command(&param, I8042_CMD_CTL_TEST);
+               if (ret)
+                       pr_info("i8042 controller selftest timeout (%d/5)\n", i);
+               else if (param == I8042_RET_CTL_TEST)
                        return 0;
+               else
+                       dbg("i8042 controller selftest: %#x != %#x\n",
+                           param, I8042_RET_CTL_TEST);
 
-               dbg("i8042 controller selftest: %#x != %#x\n",
-                   param, I8042_RET_CTL_TEST);
                msleep(50);
-       } while (i++ < 5);
+       }
+
+       if (ret)
+               return -ENODEV;
 
 #ifdef CONFIG_X86
        /*