Message ID | 1441773171-4575-14-git-send-email-sjg@chromium.org |
---|---|
State | Superseded |
Delegated to: | Simon Glass |
Headers | show |
On Wed, Sep 9, 2015 at 12:32 PM, Simon Glass <sjg@chromium.org> wrote: > 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> > --- > > drivers/input/i8042.c | 19 +++++++++---------- > 1 file changed, 9 insertions(+), 10 deletions(-) > > diff --git a/drivers/input/i8042.c b/drivers/input/i8042.c > index ef01bd0..1c6a31e 100644 > --- a/drivers/input/i8042.c > +++ b/drivers/input/i8042.c > @@ -587,18 +587,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; > } > > /* > -- Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
diff --git a/drivers/input/i8042.c b/drivers/input/i8042.c index ef01bd0..1c6a31e 100644 --- a/drivers/input/i8042.c +++ b/drivers/input/i8042.c @@ -587,18 +587,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; } /*
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> --- drivers/input/i8042.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-)