From 3b8c3ece320af51df07b7d438ee281b5b9f050d0 Mon Sep 17 00:00:00 2001 From: Marius Strobl Date: Sat, 21 May 2005 20:26:30 +0000 Subject: [PATCH] - Sprinkle some KBD_IS_* and KBD_*_DONE macros in sunkbd_configure() as a band-aid allowing to call this function savely multiple times, e.g. during sckbdprobe() and sc_probe_unit(). Otherwise calling it a second time results in a non-working keyboard. This needs a lot of more work to actually do the right thing and work like expected. - Let sunkbd_configure() return the number of the found keyboards, i.e. 1 in case probing succeeds, as it's expected. The return values of the keyboard configure functions however currently aren't checked so this doesn't make a difference at the moment. - Use FBSDID. --- sys/dev/uart/uart_kbd_sun.c | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/sys/dev/uart/uart_kbd_sun.c b/sys/dev/uart/uart_kbd_sun.c index 03496595933..97c8bc5efe3 100644 --- a/sys/dev/uart/uart_kbd_sun.c +++ b/sys/dev/uart/uart_kbd_sun.c @@ -22,10 +22,11 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * $FreeBSD$ */ +#include +__FBSDID("$FreeBSD$"); + #include "opt_kbd.h" #include @@ -189,15 +190,21 @@ sunkbd_configure(int flags) { struct sunkbd_softc *sc; - if (uart_cpu_getdev(UART_DEV_KEYBOARD, &uart_keyboard)) - return (0); - if (uart_probe(&uart_keyboard)) - return (0); - uart_init(&uart_keyboard); + if (KBD_IS_CONFIGURED(&sunkbd_softc.sc_kbd)) + goto found; - uart_keyboard.type = UART_DEV_KEYBOARD; - uart_keyboard.attach = sunkbd_attach; - uart_add_sysdev(&uart_keyboard); + if (!KBD_IS_INITIALIZED(&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); + KBD_INIT_DONE(&sunkbd_softc.sc_kbd); + } if (sunkbd_probe_keyboard(&uart_keyboard) == -1) return (0); @@ -215,8 +222,11 @@ sunkbd_configure(int flags) kbd_register(&sc->sc_kbd); sc->sc_sysdev = &uart_keyboard; + KBD_CONFIG_DONE(&sc->sc_kbd); - return (0); + found: + /* Return number of found keyboards. */ + return (1); } static int