From 3a61f787fbef3a9d79c236c3ef304872c4c752c8 Mon Sep 17 00:00:00 2001 From: Marius Strobl Date: Sat, 4 Jun 2005 21:54:31 +0000 Subject: Replace the band-aid for allowing to call sunkbd_configure() multiple times which was added in the last revision with what should be a proper solution as long as keyboards that were pluggged in after the kernel has fully booted aren't supported. I.e. when sunkbd_configure() is called for the high-level console probe make sure that the keyboard is both successfully configured (i.e. also probed) and attached. The band- aid left the possibility to attach the keyboard device to the high-level console without attaching the keyboard device itself when the keyboard is plugged in after uart(4) attached but before syscons(4) does. --- sys/dev/uart/uart_kbd_sun.c | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) (limited to 'sys/dev/uart') diff --git a/sys/dev/uart/uart_kbd_sun.c b/sys/dev/uart/uart_kbd_sun.c index 97c8bc5efe31..4d024d2ea878 100644 --- a/sys/dev/uart/uart_kbd_sun.c +++ b/sys/dev/uart/uart_kbd_sun.c @@ -190,22 +190,27 @@ sunkbd_configure(int flags) { struct sunkbd_softc *sc; - if (KBD_IS_CONFIGURED(&sunkbd_softc.sc_kbd)) - goto found; - - if (!KBD_IS_INITIALIZED(&sunkbd_softc.sc_kbd)) { - if (uart_cpu_getdev(UART_DEV_KEYBOARD, &uart_keyboard)) - return (0); - if (uart_probe(&uart_keyboard)) + /* + * We are only prepared to be used for the high-level console + * when the keyboard is both configured and attached. + */ + if (!(flags & KB_CONF_PROBE_ONLY)) { + if (KBD_IS_INITIALIZED(&sunkbd_softc.sc_kbd)) + goto found; + else return (0); - uart_init(&uart_keyboard); - - uart_keyboard.type = UART_DEV_KEYBOARD; - uart_keyboard.attach = sunkbd_attach; - uart_add_sysdev(&uart_keyboard); - KBD_INIT_DONE(&sunkbd_softc.sc_kbd); } + if (uart_cpu_getdev(UART_DEV_KEYBOARD, &uart_keyboard)) + return (0); + if (uart_probe(&uart_keyboard)) + return (0); + uart_init(&uart_keyboard); + + uart_keyboard.type = UART_DEV_KEYBOARD; + uart_keyboard.attach = sunkbd_attach; + uart_add_sysdev(&uart_keyboard); + if (sunkbd_probe_keyboard(&uart_keyboard) == -1) return (0); @@ -222,7 +227,6 @@ sunkbd_configure(int flags) kbd_register(&sc->sc_kbd); sc->sc_sysdev = &uart_keyboard; - KBD_CONFIG_DONE(&sc->sc_kbd); found: /* Return number of found keyboards. */ @@ -254,6 +258,7 @@ sunkbd_attach(struct uart_softc *sc) &sunkbd_softc, SWI_TTY, INTR_TYPE_TTY, &sc->sc_softih); sc->sc_opened = 1; + KBD_INIT_DONE(&sunkbd_softc.sc_kbd); } return (0); -- cgit v1.3