diff mbox

[U-Boot,v2,12/28] i8042: Adjust keyboard init to assume success

Message ID 1445224657-20622-13-git-send-email-sjg@chromium.org
State Accepted
Delegated to: Simon Glass
Headers show

Commit Message

Simon Glass Oct. 19, 2015, 3:17 a.m. UTC
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>
---

Changes in v2: None

 drivers/input/i8042.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

Comments

Simon Glass Oct. 30, 2015, 8:24 p.m. UTC | #1
Applied to u-boot-dm.
diff mbox

Patch

diff --git a/drivers/input/i8042.c b/drivers/input/i8042.c
index 4c887f4..b1ada86 100644
--- a/drivers/input/i8042.c
+++ b/drivers/input/i8042.c
@@ -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;
 }
 
 /*