[U-Boot] [PATCH v2 2/7] x86: i8042: Remove unused codes

Simon Glass sjg at chromium.org
Sat Aug 22 01:27:53 CEST 2015


Hi Bin,

On 21 August 2015 at 01:18, Bin Meng <bmeng.cn at gmail.com> wrote:
> - Remove unused routines i8042_flush() and i8042_disable()
> - Remove unused CONFIG_USE_CPCIDVI wrapped codes
> - Remove __weak board_i8042_skip()
>
> Signed-off-by: Bin Meng <bmeng.cn at gmail.com>
> Acked-by: Simon Glass <sjg at chromium.org>
>
> ---
>
> Changes in v2:
> - Split the removing of unused codes into this patch
>
>  drivers/input/i8042.c | 67 +--------------------------------------------------
>  include/i8042.h       | 13 ----------
>  2 files changed, 1 insertion(+), 79 deletions(-)
>
> diff --git a/drivers/input/i8042.c b/drivers/input/i8042.c
> index 1769c5e..8401181 100644
> --- a/drivers/input/i8042.c
> +++ b/drivers/input/i8042.c
> @@ -10,16 +10,6 @@
>  /* includes */
>
>  #include <common.h>
> -#include <linux/compiler.h>
> -
> -#ifdef CONFIG_USE_CPCIDVI
> -extern u8 gt_cpcidvi_in8(u32 offset);
> -extern void gt_cpcidvi_out8(u32 offset, u8 data);
> -
> -#define in8(a)    gt_cpcidvi_in8(a)
> -#define out8(a, b) gt_cpcidvi_out8(a, b)
> -#endif

Yes good to drop that. Can you also please drop it (perhaps separate
patch) in drivers/video/ct69000.c?

> -
>  #include <i8042.h>
>
>  /* defines */
> @@ -305,54 +295,6 @@ static int kbd_controller_present(void)
>         return in8(I8042_STATUS_REG) != 0xff;
>  }
>
> -/*
> - * Implement a weak default function for boards that optionally
> - * need to skip the i8042 initialization.
> - */
> -int __weak board_i8042_skip(void)
> -{
> -       /* As default, don't skip */
> -       return 0;
> -}
> -
> -void i8042_flush(void)
> -{
> -       int timeout;
> -
> -       /*
> -        * The delay is to give the keyboard controller some time to fill the
> -        * next byte.
> -        */
> -       while (1) {
> -               timeout = 100;  /* wait for no longer than 100us */
> -               while (timeout > 0 && !(in8(I8042_STATUS_REG) & 0x01)) {
> -                       udelay(1);
> -                       timeout--;
> -               }
> -
> -               /* Try to pull next byte if not timeout. */
> -               if (in8(I8042_STATUS_REG) & 0x01)
> -                       in8(I8042_DATA_REG);
> -               else
> -                       break;
> -       }
> -}
> -
> -int i8042_disable(void)
> -{
> -       if (kbd_input_empty() == 0)
> -               return -1;
> -
> -       /* Disable keyboard */
> -       out8(I8042_COMMAND_REG, 0xad);
> -
> -       if (kbd_input_empty() == 0)
> -               return -1;
> -
> -       return 0;
> -}
> -
> -
>  /*******************************************************************************
>   *
>   * i8042_kbd_init - reset keyboard and init state flags
> @@ -362,16 +304,9 @@ int i8042_kbd_init(void)
>         int keymap, try;
>         char *penv;
>
> -       if (!kbd_controller_present() || board_i8042_skip())
> +       if (!kbd_controller_present())
>                 return -1;
>
> -#ifdef CONFIG_USE_CPCIDVI
> -       penv = getenv("console");
> -       if (penv != NULL) {
> -               if (strncmp(penv, "serial", 7) == 0)
> -                       return -1;
> -       }
> -#endif
>         /* Init keyboard device (default US layout) */
>         keymap = KBD_US;
>         penv = getenv("keymap");
> diff --git a/include/i8042.h b/include/i8042.h
> index 58c85ec..e68b8d8 100644
> --- a/include/i8042.h
> +++ b/include/i8042.h
> @@ -59,19 +59,6 @@ enum {
>
>  /* exports */
>
> -/**
> - * Flush all buffer from keyboard controller to host.
> - */
> -void i8042_flush(void);
> -
> -/**
> - * Disables the keyboard so that key strokes no longer generate scancodes to
> - * the host.
> - *
> - * @return 0 if ok, -1 if keyboard input was found while disabling
> - */
> -int i8042_disable(void);
> -
>  struct stdio_dev;
>
>  int i8042_kbd_init(void);
> --
> 1.8.2.1
>

For the moment I'd like to keep these functions. They are used for Chrome OS:

/* Disable keyboard and flush buffer so that further key strokes
* won't interfere kernel driver init. */
#ifdef CONFIG_I8042_KBD
if (i8042_disable())
VBDEBUG("i8042_disable() failed. fine, continue.\n");
i8042_flush();
#endif

int board_i8042_skip(void)
{
struct vboot_flag_details devsw;

vboot_flag_fetch(VBOOT_FLAG_DEVELOPER, &devsw);
if (devsw.value)
return 0;

return fdtdec_get_config_int(gd->fdt_blob, "skip-i8042", 0);
}

I'm sure these can be done in a better way at some point, and in the
meantime I'll add some code to use them in coreboot (looks like there
are a few patches I did not upstream).

Regards,
Simon


More information about the U-Boot mailing list