Reduce warnings/errors in libpayload when using picky compiler options
[coreboot.git] / payloads / libpayload / drivers / keyboard.c
index 95827463ca2b3827fd0ac47c265413857a4175b7..0663f47bc636f2e1acd88f0ef2aafceb118555bb 100644 (file)
@@ -27,8 +27,8 @@
  * SUCH DAMAGE.
  */
 
+#include <libpayload-config.h>
 #include <libpayload.h>
-#include <config.h>
 #include <curses.h>
 
 #define I8042_CMD_READ_MODE  0x20
 
 #define I8042_MODE_XLATE     0x40
 
-static void (*reset_handler)(void) = NULL;
-
 struct layout_maps {
-       char *country;
-       unsigned short map[4][0x57];
+       const char *country;
+       const unsigned short map[4][0x57];
 };
 
-struct layout_maps *map;
+static struct layout_maps *map;
 
-struct layout_maps keyboard_layouts[] = {
+static struct layout_maps keyboard_layouts[] = {
 #ifdef CONFIG_PC_KEYBOARD_LAYOUT_US
 { .country = "us", .map = {
        { /* No modifier */
@@ -263,22 +261,22 @@ int keyboard_getchar(void)
 
 static int keyboard_wait_read(void)
 {
-       int timeout = 10000;
+       int retries = 10000;
 
-       while(timeout-- && !(inb(0x64) & 0x01))
+       while(retries-- && !(inb(0x64) & 0x01))
                udelay(50);
 
-       return (timeout <= 0) ? -1 : 0;
+       return (retries <= 0) ? -1 : 0;
 }
 
 static int keyboard_wait_write(void)
 {
-       int timeout = 10000;
+       int retries = 10000;
 
-       while(timeout-- && (inb(0x64) & 0x02))
+       while(retries-- && (inb(0x64) & 0x02))
                udelay(50);
 
-       return (timeout <= 0) ? -1 : 0;
+       return (retries <= 0) ? -1 : 0;
 }
 
 static unsigned char keyboard_get_mode(void)
@@ -297,7 +295,7 @@ static void keyboard_set_mode(unsigned char mode)
 
 /**
  * Set keyboard layout
- * @param country string describing the keyboard layout language. 
+ * @param country string describing the keyboard layout language.
  * Valid values are "us", "de".
  */
 
@@ -319,12 +317,10 @@ int keyboard_set_layout(char *country)
        return -1;
 }
 
-int keyboard_add_reset_handler(void (*new_handler)(void))
-{
-       reset_handler = new_handler;
-
-       return 0;
-}
+static struct console_input_driver cons = {
+       .havekey = keyboard_havechar,
+       .getchar = keyboard_getchar
+};
 
 void keyboard_init(void)
 {
@@ -350,5 +346,7 @@ void keyboard_init(void)
 
        /* Write the new mode */
        keyboard_set_mode(mode);
+
+       console_add_input_driver(&cons);
 }