input: i8042: Use remove() instead of exported functions
authorSimon Glass <sjg@chromium.org>
Sat, 24 Nov 2018 04:29:38 +0000 (21:29 -0700)
committerSimon Glass <sjg@chromium.org>
Wed, 5 Dec 2018 13:01:35 +0000 (06:01 -0700)
We should not have exported functions in a driver. The i8042_disable()
function is used to disable the keyboard. Provide a remove() method
instead, which is the standard way of disabling a device.

We could potentially add a method to flush input but that does not seem
necessary.

Signed-off-by: Simon Glass <sjg@chromium.org>
drivers/input/i8042.c
include/i8042.h

index 5678f8e..9a5dc46 100644 (file)
@@ -167,19 +167,8 @@ static int kbd_controller_present(void)
        return in8(I8042_STS_REG) != 0xff;
 }
 
-/*
- * Implement a weak default function for boards that optionally
- * need to skip the i8042 initialization.
- *
- * TODO(sjg@chromium.org): Use device tree for this?
- */
-int __weak board_i8042_skip(void)
-{
-       /* As default, don't skip */
-       return 0;
-}
-
-void i8042_flush(void)
+/** Flush all buffer from keyboard controller to host*/
+static void i8042_flush(void)
 {
        int timeout;
 
@@ -202,7 +191,13 @@ void i8042_flush(void)
        }
 }
 
-int i8042_disable(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
+ */
+static int i8042_disable(void)
 {
        if (kbd_input_empty() == 0)
                return -1;
@@ -266,7 +261,7 @@ static int i8042_start(struct udevice *dev)
        char *penv;
        int ret;
 
-       if (!kbd_controller_present() || board_i8042_skip()) {
+       if (!kbd_controller_present()) {
                debug("i8042 keyboard controller is not present\n");
                return -ENOENT;
        }
@@ -294,6 +289,15 @@ static int i8042_start(struct udevice *dev)
        return 0;
 }
 
+static int i8042_kbd_remove(struct udevice *dev)
+{
+       if (i8042_disable())
+               log_debug("i8042_disable() failed. fine, continue.\n");
+       i8042_flush();
+
+       return 0;
+}
+
 /**
  * Set up the i8042 keyboard. This is called by the stdio device handler
  *
@@ -348,6 +352,7 @@ U_BOOT_DRIVER(i8042_kbd) = {
        .id     = UCLASS_KEYBOARD,
        .of_match = i8042_kbd_ids,
        .probe = i8042_kbd_probe,
+       .remove = i8042_kbd_remove,
        .ops    = &i8042_kbd_ops,
        .priv_auto_alloc_size = sizeof(struct i8042_kbd_priv),
 };
index 2b9e5c4..8d69fa1 100644 (file)
 #define BRK            0x0100  /* make break flag for keyboard */
 #define ALT            0x0200  /* right alt */
 
-/* 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);
-
 #endif /* _I8042_H_ */