]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
i8042: Adjust keyboard init to assume success
authorSimon Glass <sjg@chromium.org>
Mon, 19 Oct 2015 03:17:21 +0000 (21:17 -0600)
committerSimon Glass <sjg@chromium.org>
Fri, 20 Nov 2015 03:13:40 +0000 (20:13 -0700)
Modify i8042_kbd_init() so that the normal pass is sucessful init and
failure exits early. This will make the code easier to extend and is easier
to read.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
drivers/input/i8042.c

index 4c887f4071db054c250b370a676d5fb68e6f9f23..b1ada867e400a281d8a07ff706ad293455f1726e 100644 (file)
@@ -585,18 +585,17 @@ int i8042_kbd_init(void)
                        keymap = KBD_GER;
        }
 
-       for (try = 0; try < KBD_RESET_TRIES; try++) {
-               if (kbd_reset() == 0) {
-                       kbd_mapping = keymap;
-                       kbd_flags   = NORMAL;
-                       kbd_state   = 0;
-                       kbd_led_set();
-
-                       return 0;
-               }
+       for (try = 0; kbd_reset() != 0; try++) {
+               if (try >= KBD_RESET_TRIES)
+                       return -1;
        }
 
-       return -1;
+       kbd_mapping = keymap;
+       kbd_flags   = NORMAL;
+       kbd_state   = 0;
+       kbd_led_set();
+
+       return 0;
 }
 
 /*