usb4bsd: Port input devices (uep, uhid, ukbd, ums) and hook into build.
authorSascha Wildner <saw@online.de>
Wed, 10 Oct 2012 22:55:15 +0000 (00:55 +0200)
committerSascha Wildner <saw@online.de>
Thu, 11 Oct 2012 09:27:48 +0000 (11:27 +0200)
Submitted-by: Markus Pfeiffer <markus.pfeiffer@morphism.de>
sys/bus/u4b/Makefile
sys/bus/u4b/input/Makefile [new file with mode: 0644]
sys/bus/u4b/input/uep.c
sys/bus/u4b/input/uep/Makefile [new file with mode: 0644]
sys/bus/u4b/input/uhid.c
sys/bus/u4b/input/uhid/Makefile [new file with mode: 0644]
sys/bus/u4b/input/ukbd.c
sys/bus/u4b/input/ukbd/Makefile [new file with mode: 0644]
sys/bus/u4b/input/ums.c
sys/bus/u4b/input/ums/Makefile [new file with mode: 0644]

index 107cd87..3347092 100644 (file)
@@ -1,5 +1,5 @@
 #SUBDIR=       controller input misc net quirk serial storage template
 
 #SUBDIR=       controller input misc net quirk serial storage template
 
-SUBDIR=        usb audio controller storage
+SUBDIR=        usb audio controller input storage
 
 .include <bsd.subdir.mk>
 
 .include <bsd.subdir.mk>
diff --git a/sys/bus/u4b/input/Makefile b/sys/bus/u4b/input/Makefile
new file mode 100644 (file)
index 0000000..288bacf
--- /dev/null
@@ -0,0 +1,3 @@
+SUBDIR=        uep uhid ukbd ums
+
+.include <bsd.subdir.mk>
index e534b27..f475747 100644 (file)
 #include <sys/sysctl.h>
 #include <sys/systm.h>
 
 #include <sys/sysctl.h>
 #include <sys/systm.h>
 
-#include <dev/usb/usb.h>
-#include <dev/usb/usbdi.h>
-#include <dev/usb/usbdi_util.h>
-#include <dev/usb/usbhid.h>
-#include "usbdevs.h"
+#include <bus/u4b/usb.h>
+#include <bus/u4b/usbdi.h>
+#include <bus/u4b/usbdi_util.h>
+#include <bus/u4b/usbhid.h>
+#include <bus/u4b/usbdevs.h>
 
 #include <sys/ioccom.h>
 #include <sys/fcntl.h>
 #include <sys/tty.h>
 
 #define USB_DEBUG_VAR uep_debug
 
 #include <sys/ioccom.h>
 #include <sys/fcntl.h>
 #include <sys/tty.h>
 
 #define USB_DEBUG_VAR uep_debug
-#include <dev/usb/usb_debug.h>
+#include <bus/u4b/usb_debug.h>
 
 #ifdef USB_DEBUG
 static int uep_debug = 0;
 
 #ifdef USB_DEBUG
 static int uep_debug = 0;
@@ -85,7 +85,7 @@ enum {
 };
 
 struct uep_softc {
 };
 
 struct uep_softc {
-       struct mtx mtx;
+       struct lock lock;
 
        struct usb_xfer *xfer[UEP_N_TRANSFER];
        struct usb_fifo_sc fifo;
 
        struct usb_xfer *xfer[UEP_N_TRANSFER];
        struct usb_fifo_sc fifo;
@@ -318,17 +318,17 @@ uep_attach(device_t dev)
 
        device_set_usb_desc(dev);
 
 
        device_set_usb_desc(dev);
 
-       mtx_init(&sc->mtx, "uep lock", NULL, MTX_DEF);
+       lockinit(&sc->lock, "uep lock", 0, 0);
 
        error = usbd_transfer_setup(uaa->device, &uaa->info.bIfaceIndex,
 
        error = usbd_transfer_setup(uaa->device, &uaa->info.bIfaceIndex,
-           sc->xfer, uep_config, UEP_N_TRANSFER, sc, &sc->mtx);
+           sc->xfer, uep_config, UEP_N_TRANSFER, sc, &sc->lock);
 
        if (error) {
                DPRINTF("usbd_transfer_setup error=%s\n", usbd_errstr(error));
                goto detach;
        }
 
 
        if (error) {
                DPRINTF("usbd_transfer_setup error=%s\n", usbd_errstr(error));
                goto detach;
        }
 
-       error = usb_fifo_attach(uaa->device, sc, &sc->mtx, &uep_fifo_methods,
+       error = usb_fifo_attach(uaa->device, sc, &sc->lock, &uep_fifo_methods,
            &sc->fifo, device_get_unit(dev), 0 - 1, uaa->info.bIfaceIndex,
            UID_ROOT, GID_OPERATOR, 0644);
 
            &sc->fifo, device_get_unit(dev), 0 - 1, uaa->info.bIfaceIndex,
            UID_ROOT, GID_OPERATOR, 0644);
 
@@ -356,7 +356,7 @@ uep_detach(device_t dev)
 
        usbd_transfer_unsetup(sc->xfer, UEP_N_TRANSFER);
 
 
        usbd_transfer_unsetup(sc->xfer, UEP_N_TRANSFER);
 
-       mtx_destroy(&sc->mtx);
+       lockuninit(&sc->lock);
 
        return (0);
 }
 
        return (0);
 }
diff --git a/sys/bus/u4b/input/uep/Makefile b/sys/bus/u4b/input/uep/Makefile
new file mode 100644 (file)
index 0000000..16328e3
--- /dev/null
@@ -0,0 +1,8 @@
+.PATH: ${.CURDIR}/..
+
+KMOD=  uep
+
+SRCS=  opt_bus.h opt_usb.h device_if.h bus_if.h usb_if.h \
+       uep.c
+
+.include <bsd.kmod.mk>
index 929227b..e2d9459 100644 (file)
@@ -4,9 +4,6 @@
  *     $NetBSD: uhid.c,v 1.54 2002/09/23 05:51:21 simonb Exp $
  */
 
  *     $NetBSD: uhid.c,v 1.54 2002/09/23 05:51:21 simonb Exp $
  */
 
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
  * All rights reserved.
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -42,7 +39,6 @@ __FBSDID("$FreeBSD$");
  */
 
 #include <sys/stdint.h>
  */
 
 #include <sys/stdint.h>
-#include <sys/stddef.h>
 #include <sys/param.h>
 #include <sys/queue.h>
 #include <sys/types.h>
 #include <sys/param.h>
 #include <sys/queue.h>
 #include <sys/types.h>
@@ -51,10 +47,8 @@ __FBSDID("$FreeBSD$");
 #include <sys/bus.h>
 #include <sys/module.h>
 #include <sys/lock.h>
 #include <sys/bus.h>
 #include <sys/module.h>
 #include <sys/lock.h>
-#include <sys/mutex.h>
 #include <sys/condvar.h>
 #include <sys/sysctl.h>
 #include <sys/condvar.h>
 #include <sys/sysctl.h>
-#include <sys/sx.h>
 #include <sys/unistd.h>
 #include <sys/callout.h>
 #include <sys/malloc.h>
 #include <sys/unistd.h>
 #include <sys/callout.h>
 #include <sys/malloc.h>
@@ -62,18 +56,18 @@ __FBSDID("$FreeBSD$");
 #include <sys/conf.h>
 #include <sys/fcntl.h>
 
 #include <sys/conf.h>
 #include <sys/fcntl.h>
 
-#include "usbdevs.h"
-#include <dev/usb/usb.h>
-#include <dev/usb/usbdi.h>
-#include <dev/usb/usbdi_util.h>
-#include <dev/usb/usbhid.h>
-#include <dev/usb/usb_ioctl.h>
+#include <bus/u4b/usbdevs.h>
+#include <bus/u4b/usb.h>
+#include <bus/u4b/usbdi.h>
+#include <bus/u4b/usbdi_util.h>
+#include <bus/u4b/usbhid.h>
+#include <bus/u4b/usb_ioctl.h>
 
 #define        USB_DEBUG_VAR uhid_debug
 
 #define        USB_DEBUG_VAR uhid_debug
-#include <dev/usb/usb_debug.h>
+#include <bus/u4b/usb_debug.h>
 
 
-#include <dev/usb/input/usb_rdesc.h>
-#include <dev/usb/quirk/usb_quirk.h>
+#include <bus/u4b/input/usb_rdesc.h>
+#include <bus/u4b/quirk/usb_quirk.h>
 
 #ifdef USB_DEBUG
 static int uhid_debug = 0;
 
 #ifdef USB_DEBUG
 static int uhid_debug = 0;
@@ -95,7 +89,7 @@ enum {
 
 struct uhid_softc {
        struct usb_fifo_sc sc_fifo;
 
 struct uhid_softc {
        struct usb_fifo_sc sc_fifo;
-       struct mtx sc_mtx;
+       struct lock sc_lock;
 
        struct usb_xfer *sc_xfer[UHID_N_TRANSFER];
        struct usb_device *sc_udev;
 
        struct usb_xfer *sc_xfer[UHID_N_TRANSFER];
        struct usb_device *sc_udev;
@@ -401,7 +395,7 @@ uhid_get_report(struct uhid_softc *sc, uint8_t type,
        uint8_t free_data = 0;
 
        if (kern_data == NULL) {
        uint8_t free_data = 0;
 
        if (kern_data == NULL) {
-               kern_data = malloc(len, M_USBDEV, M_WAITOK);
+               kern_data = kmalloc(len, M_USBDEV, M_WAITOK);
                if (kern_data == NULL) {
                        err = ENOMEM;
                        goto done;
                if (kern_data == NULL) {
                        err = ENOMEM;
                        goto done;
@@ -423,7 +417,7 @@ uhid_get_report(struct uhid_softc *sc, uint8_t type,
        }
 done:
        if (free_data) {
        }
 done:
        if (free_data) {
-               free(kern_data, M_USBDEV);
+               kfree(kern_data, M_USBDEV);
        }
        return (err);
 }
        }
        return (err);
 }
@@ -437,7 +431,7 @@ uhid_set_report(struct uhid_softc *sc, uint8_t type,
        uint8_t free_data = 0;
 
        if (kern_data == NULL) {
        uint8_t free_data = 0;
 
        if (kern_data == NULL) {
-               kern_data = malloc(len, M_USBDEV, M_WAITOK);
+               kern_data = kmalloc(len, M_USBDEV, M_WAITOK);
                if (kern_data == NULL) {
                        err = ENOMEM;
                        goto done;
                if (kern_data == NULL) {
                        err = ENOMEM;
                        goto done;
@@ -456,7 +450,7 @@ uhid_set_report(struct uhid_softc *sc, uint8_t type,
        }
 done:
        if (free_data) {
        }
 done:
        if (free_data) {
-               free(kern_data, M_USBDEV);
+               kfree(kern_data, M_USBDEV);
        }
        return (err);
 }
        }
        return (err);
 }
@@ -534,13 +528,13 @@ uhid_ioctl(struct usb_fifo *fifo, u_long cmd, void *addr,
                        if (error) {
                                break;
                        }
                        if (error) {
                                break;
                        }
-                       mtx_lock(&sc->sc_mtx);
+                       lockmgr(&sc->sc_lock, LK_EXCLUSIVE);
                        sc->sc_flags |= UHID_FLAG_IMMED;
                        sc->sc_flags |= UHID_FLAG_IMMED;
-                       mtx_unlock(&sc->sc_mtx);
+                       lockmgr(&sc->sc_lock, LK_RELEASE);
                } else {
                } else {
-                       mtx_lock(&sc->sc_mtx);
+                       lockmgr(&sc->sc_lock, LK_EXCLUSIVE);
                        sc->sc_flags &= ~UHID_FLAG_IMMED;
                        sc->sc_flags &= ~UHID_FLAG_IMMED;
-                       mtx_unlock(&sc->sc_mtx);
+                       lockmgr(&sc->sc_lock, LK_RELEASE);
                }
                break;
 
                }
                break;
 
@@ -665,7 +659,7 @@ uhid_attach(device_t dev)
 
        device_set_usb_desc(dev);
 
 
        device_set_usb_desc(dev);
 
-       mtx_init(&sc->sc_mtx, "uhid lock", NULL, MTX_DEF | MTX_RECURSE);
+       lockinit(&sc->sc_lock, "uhid lock", 0, LK_CANRECURSE);
 
        sc->sc_udev = uaa->device;
 
 
        sc->sc_udev = uaa->device;
 
@@ -674,7 +668,7 @@ uhid_attach(device_t dev)
 
        error = usbd_transfer_setup(uaa->device,
            &uaa->info.bIfaceIndex, sc->sc_xfer, uhid_config,
 
        error = usbd_transfer_setup(uaa->device,
            &uaa->info.bIfaceIndex, sc->sc_xfer, uhid_config,
-           UHID_N_TRANSFER, sc, &sc->sc_mtx);
+           UHID_N_TRANSFER, sc, &sc->sc_lock);
 
        if (error) {
                DPRINTF("error=%s\n", usbd_errstr(error));
 
        if (error) {
                DPRINTF("error=%s\n", usbd_errstr(error));
@@ -766,7 +760,7 @@ uhid_attach(device_t dev)
                sc->sc_fsize = UHID_BSIZE;
        }
 
                sc->sc_fsize = UHID_BSIZE;
        }
 
-       error = usb_fifo_attach(uaa->device, sc, &sc->sc_mtx,
+       error = usb_fifo_attach(uaa->device, sc, &sc->sc_lock,
            &uhid_fifo_methods, &sc->sc_fifo,
            unit, 0 - 1, uaa->info.bIfaceIndex,
            UID_ROOT, GID_OPERATOR, 0644);
            &uhid_fifo_methods, &sc->sc_fifo,
            unit, 0 - 1, uaa->info.bIfaceIndex,
            UID_ROOT, GID_OPERATOR, 0644);
@@ -791,10 +785,10 @@ uhid_detach(device_t dev)
 
        if (sc->sc_repdesc_ptr) {
                if (!(sc->sc_flags & UHID_FLAG_STATIC_DESC)) {
 
        if (sc->sc_repdesc_ptr) {
                if (!(sc->sc_flags & UHID_FLAG_STATIC_DESC)) {
-                       free(sc->sc_repdesc_ptr, M_USBDEV);
+                       kfree(sc->sc_repdesc_ptr, M_USBDEV);
                }
        }
                }
        }
-       mtx_destroy(&sc->sc_mtx);
+       lockuninit(&sc->sc_lock);
 
        return (0);
 }
 
        return (0);
 }
diff --git a/sys/bus/u4b/input/uhid/Makefile b/sys/bus/u4b/input/uhid/Makefile
new file mode 100644 (file)
index 0000000..a9ce94b
--- /dev/null
@@ -0,0 +1,8 @@
+.PATH: ${.CURDIR}/..
+
+KMOD=  uhid
+
+SRCS=  opt_bus.h opt_usb.h device_if.h bus_if.h usb_if.h \
+       uhid.c
+
+.include <bsd.kmod.mk>
index eb7e1d9..cd47acb 100644 (file)
@@ -1,7 +1,3 @@
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
  * All rights reserved.
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -42,7 +38,6 @@ __FBSDID("$FreeBSD$");
 #include "opt_ukbd.h"
 
 #include <sys/stdint.h>
 #include "opt_ukbd.h"
 
 #include <sys/stdint.h>
-#include <sys/stddef.h>
 #include <sys/param.h>
 #include <sys/queue.h>
 #include <sys/types.h>
 #include <sys/param.h>
 #include <sys/queue.h>
 #include <sys/types.h>
@@ -51,34 +46,32 @@ __FBSDID("$FreeBSD$");
 #include <sys/bus.h>
 #include <sys/module.h>
 #include <sys/lock.h>
 #include <sys/bus.h>
 #include <sys/module.h>
 #include <sys/lock.h>
-#include <sys/mutex.h>
 #include <sys/condvar.h>
 #include <sys/sysctl.h>
 #include <sys/condvar.h>
 #include <sys/sysctl.h>
-#include <sys/sx.h>
 #include <sys/unistd.h>
 #include <sys/callout.h>
 #include <sys/malloc.h>
 #include <sys/priv.h>
 #include <sys/proc.h>
 #include <sys/sched.h>
 #include <sys/unistd.h>
 #include <sys/callout.h>
 #include <sys/malloc.h>
 #include <sys/priv.h>
 #include <sys/proc.h>
 #include <sys/sched.h>
-#include <sys/kdb.h>
+#include <sys/thread2.h>
 
 
-#include <dev/usb/usb.h>
-#include <dev/usb/usbdi.h>
-#include <dev/usb/usbdi_util.h>
-#include <dev/usb/usbhid.h>
+#include <bus/u4b/usb.h>
+#include <bus/u4b/usbdi.h>
+#include <bus/u4b/usbdi_util.h>
+#include <bus/u4b/usbhid.h>
 
 #define        USB_DEBUG_VAR ukbd_debug
 
 #define        USB_DEBUG_VAR ukbd_debug
-#include <dev/usb/usb_debug.h>
+#include <bus/u4b/usb_debug.h>
 
 
-#include <dev/usb/quirk/usb_quirk.h>
+#include <bus/u4b/quirk/usb_quirk.h>
 
 #include <sys/ioccom.h>
 #include <sys/filio.h>
 #include <sys/tty.h>
 #include <sys/kbio.h>
 
 
 #include <sys/ioccom.h>
 #include <sys/filio.h>
 #include <sys/tty.h>
 #include <sys/kbio.h>
 
-#include <dev/kbd/kbdreg.h>
+#include <dev/misc/kbd/kbdreg.h>
 
 /* the initial key map, accent map and fkey strings */
 #if defined(UKBD_DFLT_KEYMAP) && !defined(KLD_MODULE)
 
 /* the initial key map, accent map and fkey strings */
 #if defined(UKBD_DFLT_KEYMAP) && !defined(KLD_MODULE)
@@ -87,7 +80,7 @@ __FBSDID("$FreeBSD$");
 #endif
 
 /* the following file must be included after "ukbdmap.h" */
 #endif
 
 /* the following file must be included after "ukbdmap.h" */
-#include <dev/kbd/kbdtables.h>
+#include <dev/misc/kbd/kbdtables.h>
 
 #ifdef USB_DEBUG
 static int ukbd_debug = 0;
 
 #ifdef USB_DEBUG
 static int ukbd_debug = 0;
@@ -135,9 +128,12 @@ enum {
 };
 
 struct ukbd_softc {
 };
 
 struct ukbd_softc {
+    device_t sc_dev;
+    struct lock sc_lock;
        keyboard_t sc_kbd;
        keymap_t sc_keymap;
        accentmap_t sc_accmap;
        keyboard_t sc_kbd;
        keymap_t sc_keymap;
        accentmap_t sc_accmap;
+
        fkeytab_t sc_fkeymap[UKBD_NFKEY];
        struct hid_location sc_loc_apple_eject;
        struct hid_location sc_loc_apple_fn;
        fkeytab_t sc_fkeymap[UKBD_NFKEY];
        struct hid_location sc_loc_apple_eject;
        struct hid_location sc_loc_apple_fn;
@@ -245,8 +241,8 @@ struct ukbd_softc {
                         SCAN_PREFIX_CTL | SCAN_PREFIX_SHIFT)
 #define        SCAN_CHAR(c)    ((c) & 0x7f)
 
                         SCAN_PREFIX_CTL | SCAN_PREFIX_SHIFT)
 #define        SCAN_CHAR(c)    ((c) & 0x7f)
 
-#define        UKBD_LOCK()     mtx_lock(&Giant)
-#define        UKBD_UNLOCK()   mtx_unlock(&Giant)
+#define        UKBD_LOCK(sc)   lockmgr(&(sc)->sc_lock, LK_EXCLUSIVE)   
+#define        UKBD_UNLOCK(sc) lockmgr(&(sc)->sc_lock, LK_RELEASE)
 
 #ifdef INVARIANTS
 
 
 #ifdef INVARIANTS
 
@@ -254,17 +250,13 @@ struct ukbd_softc {
  * Assert that the lock is held in all contexts
  * where the code can be executed.
  */
  * Assert that the lock is held in all contexts
  * where the code can be executed.
  */
-#define        UKBD_LOCK_ASSERT()      mtx_assert(&Giant, MA_OWNED)
+#define        UKBD_LOCK_ASSERT()
 
 /*
  * Assert that the lock is held in the contexts
  * where it really has to be so.
  */
 
 /*
  * Assert that the lock is held in the contexts
  * where it really has to be so.
  */
-#define        UKBD_CTX_LOCK_ASSERT()                          \
-       do {                                            \
-               if (!kdb_active && panicstr == NULL)    \
-                       mtx_assert(&Giant, MA_OWNED);   \
-       } while (0)
+#define        UKBD_CTX_LOCK_ASSERT()
 #else
 
 #define UKBD_LOCK_ASSERT()     (void)0
 #else
 
 #define UKBD_LOCK_ASSERT()     (void)0
@@ -419,8 +411,9 @@ ukbd_do_poll(struct ukbd_softc *sc, uint8_t wait)
        KASSERT((sc->sc_flags & UKBD_FLAG_POLLING) != 0,
            ("ukbd_do_poll called when not polling\n"));
        DPRINTFN(2, "polling\n");
        KASSERT((sc->sc_flags & UKBD_FLAG_POLLING) != 0,
            ("ukbd_do_poll called when not polling\n"));
        DPRINTFN(2, "polling\n");
-
+#if 0 /* XXX */
        if (!kdb_active && !SCHEDULER_STOPPED()) {
        if (!kdb_active && !SCHEDULER_STOPPED()) {
+#endif
                /*
                 * In this context the kernel is polling for input,
                 * but the USB subsystem works in normal interrupt-driven
                /*
                 * In this context the kernel is polling for input,
                 * but the USB subsystem works in normal interrupt-driven
@@ -433,12 +426,14 @@ ukbd_do_poll(struct ukbd_softc *sc, uint8_t wait)
                         * Give USB threads a chance to run.  Note that
                         * kern_yield performs DROP_GIANT + PICKUP_GIANT.
                         */
                         * Give USB threads a chance to run.  Note that
                         * kern_yield performs DROP_GIANT + PICKUP_GIANT.
                         */
-                       kern_yield(PRI_UNCHANGED);
+                       lwkt_yield();
                        if (!wait)
                                break;
                }
                return;
                        if (!wait)
                                break;
                }
                return;
+#if 0
        }
        }
+#endif
 
        while (sc->sc_inputs == 0) {
 
 
        while (sc->sc_inputs == 0) {
 
@@ -466,9 +461,11 @@ ukbd_get_key(struct ukbd_softc *sc, uint8_t wait)
        int32_t c;
 
        UKBD_CTX_LOCK_ASSERT();
        int32_t c;
 
        UKBD_CTX_LOCK_ASSERT();
+#if 0
        KASSERT((!kdb_active && !SCHEDULER_STOPPED())
            || (sc->sc_flags & UKBD_FLAG_POLLING) != 0,
            ("not polling in kdb or panic\n"));
        KASSERT((!kdb_active && !SCHEDULER_STOPPED())
            || (sc->sc_flags & UKBD_FLAG_POLLING) != 0,
            ("not polling in kdb or panic\n"));
+#endif
 
        if (sc->sc_inputs == 0) {
                /* start transfer, if not already started */
 
        if (sc->sc_inputs == 0) {
                /* start transfer, if not already started */
@@ -983,7 +980,6 @@ ukbd_probe(device_t dev)
        int error;
        uint16_t d_len;
 
        int error;
        uint16_t d_len;
 
-       UKBD_LOCK_ASSERT();
        DPRINTFN(11, "\n");
 
        if (sw == NULL) {
        DPRINTFN(11, "\n");
 
        if (sw == NULL) {
@@ -1027,7 +1023,7 @@ ukbd_probe(device_t dev)
        } else
                error = ENXIO;
 
        } else
                error = ENXIO;
 
-       free(d_ptr, M_TEMP);
+       kfree(d_ptr, M_TEMP);
        return (error);
 }
 
        return (error);
 }
 
@@ -1177,9 +1173,9 @@ ukbd_attach(device_t dev)
        uint16_t n;
        uint16_t hid_len;
 
        uint16_t n;
        uint16_t hid_len;
 
-       UKBD_LOCK_ASSERT();
-
-       kbd_init_struct(kbd, UKBD_DRIVER_NAME, KB_OTHER, unit, 0, 0, 0);
+       lockinit(&sc->sc_lock, "ukbd", 0, 0);
+       kbd_init_struct(kbd, UKBD_DRIVER_NAME, KB_OTHER,
+            unit, 0, KB_PRI_USB, 0, 0);
 
        kbd->kb_data = (void *)sc;
 
 
        kbd->kb_data = (void *)sc;
 
@@ -1191,11 +1187,11 @@ ukbd_attach(device_t dev)
        sc->sc_iface_no = uaa->info.bIfaceNum;
        sc->sc_mode = K_XLATE;
 
        sc->sc_iface_no = uaa->info.bIfaceNum;
        sc->sc_mode = K_XLATE;
 
-       usb_callout_init_mtx(&sc->sc_callout, &Giant, 0);
+       usb_callout_init_mtx(&sc->sc_callout, &sc->sc_lock, 0);
 
        err = usbd_transfer_setup(uaa->device,
            &uaa->info.bIfaceIndex, sc->sc_xfer, ukbd_config,
 
        err = usbd_transfer_setup(uaa->device,
            &uaa->info.bIfaceIndex, sc->sc_xfer, ukbd_config,
-           UKBD_N_TRANSFER, sc, &Giant);
+           UKBD_N_TRANSFER, sc, &sc->sc_lock);
 
        if (err) {
                DPRINTF("error=%s\n", usbd_errstr(err));
 
        if (err) {
                DPRINTF("error=%s\n", usbd_errstr(err));
@@ -1232,7 +1228,7 @@ ukbd_attach(device_t dev)
 
                ukbd_parse_hid(sc, hid_ptr, hid_len);
 
 
                ukbd_parse_hid(sc, hid_ptr, hid_len);
 
-               free(hid_ptr, M_TEMP);
+               kfree(hid_ptr, M_TEMP);
        }
 
        /* check if we should use the boot protocol */
        }
 
        /* check if we should use the boot protocol */
@@ -1278,7 +1274,9 @@ ukbd_attach(device_t dev)
        }
 
        /* start the keyboard */
        }
 
        /* start the keyboard */
+       UKBD_LOCK(sc);
        usbd_transfer_start(sc->sc_xfer[UKBD_INTR_DT]);
        usbd_transfer_start(sc->sc_xfer[UKBD_INTR_DT]);
+       UKBD_UNLOCK(sc);
 
        return (0);                     /* success */
 
 
        return (0);                     /* success */
 
@@ -1293,8 +1291,6 @@ ukbd_detach(device_t dev)
        struct ukbd_softc *sc = device_get_softc(dev);
        int error;
 
        struct ukbd_softc *sc = device_get_softc(dev);
        int error;
 
-       UKBD_LOCK_ASSERT();
-
        DPRINTF("\n");
 
        sc->sc_flags |= UKBD_FLAG_GONE;
        DPRINTF("\n");
 
        sc->sc_flags |= UKBD_FLAG_GONE;
@@ -1338,8 +1334,6 @@ ukbd_resume(device_t dev)
 {
        struct ukbd_softc *sc = device_get_softc(dev);
 
 {
        struct ukbd_softc *sc = device_get_softc(dev);
 
-       UKBD_LOCK_ASSERT();
-
        ukbd_clear_state(&sc->sc_kbd);
 
        return (0);
        ukbd_clear_state(&sc->sc_kbd);
 
        return (0);
@@ -1401,10 +1395,11 @@ ukbd_lock(keyboard_t *kbd, int lock)
 static int
 ukbd_enable(keyboard_t *kbd)
 {
 static int
 ukbd_enable(keyboard_t *kbd)
 {
+       struct ukbd_softc *sc = kbd->kb_data;
 
 
-       UKBD_LOCK();
+       UKBD_LOCK(sc);
        KBD_ACTIVATE(kbd);
        KBD_ACTIVATE(kbd);
-       UKBD_UNLOCK();
+       UKBD_UNLOCK(sc);
 
        return (0);
 }
 
        return (0);
 }
@@ -1413,10 +1408,11 @@ ukbd_enable(keyboard_t *kbd)
 static int
 ukbd_disable(keyboard_t *kbd)
 {
 static int
 ukbd_disable(keyboard_t *kbd)
 {
+       struct ukbd_softc *sc = kbd->kb_data;
 
 
-       UKBD_LOCK();
+       UKBD_LOCK(sc);
        KBD_DEACTIVATE(kbd);
        KBD_DEACTIVATE(kbd);
-       UKBD_UNLOCK();
+       UKBD_UNLOCK(sc);
 
        return (0);
 }
 
        return (0);
 }
@@ -1428,8 +1424,6 @@ ukbd_check(keyboard_t *kbd)
 {
        struct ukbd_softc *sc = kbd->kb_data;
 
 {
        struct ukbd_softc *sc = kbd->kb_data;
 
-       UKBD_CTX_LOCK_ASSERT();
-
        if (!KBD_IS_ACTIVE(kbd))
                return (0);
 
        if (!KBD_IS_ACTIVE(kbd))
                return (0);
 
@@ -1453,8 +1447,6 @@ ukbd_check_char_locked(keyboard_t *kbd)
 {
        struct ukbd_softc *sc = kbd->kb_data;
 
 {
        struct ukbd_softc *sc = kbd->kb_data;
 
-       UKBD_CTX_LOCK_ASSERT();
-
        if (!KBD_IS_ACTIVE(kbd))
                return (0);
 
        if (!KBD_IS_ACTIVE(kbd))
                return (0);
 
@@ -1469,10 +1461,15 @@ static int
 ukbd_check_char(keyboard_t *kbd)
 {
        int result;
 ukbd_check_char(keyboard_t *kbd)
 {
        int result;
+#if 0
+       struct ukbd_softc *sc = kbd->kb_data;
 
 
-       UKBD_LOCK();
+       UKBD_LOCK(sc);
+#endif
        result = ukbd_check_char_locked(kbd);
        result = ukbd_check_char_locked(kbd);
-       UKBD_UNLOCK();
+#if 0
+       UKBD_UNLOCK(sc);
+#endif
 
        return (result);
 }
 
        return (result);
 }
@@ -1490,8 +1487,6 @@ ukbd_read(keyboard_t *kbd, int wait)
 
 #endif
 
 
 #endif
 
-       UKBD_CTX_LOCK_ASSERT();
-
        if (!KBD_IS_ACTIVE(kbd))
                return (-1);
 
        if (!KBD_IS_ACTIVE(kbd))
                return (-1);
 
@@ -1539,8 +1534,6 @@ ukbd_read_char_locked(keyboard_t *kbd, int wait)
        uint32_t scancode;
 #endif
 
        uint32_t scancode;
 #endif
 
-       UKBD_CTX_LOCK_ASSERT();
-
        if (!KBD_IS_ACTIVE(kbd))
                return (NOKEY);
 
        if (!KBD_IS_ACTIVE(kbd))
                return (NOKEY);
 
@@ -1723,10 +1716,15 @@ static uint32_t
 ukbd_read_char(keyboard_t *kbd, int wait)
 {
        uint32_t keycode;
 ukbd_read_char(keyboard_t *kbd, int wait)
 {
        uint32_t keycode;
+#if 0
+       struct ukbd_softc *sc = kbd->kb_data;
 
 
-       UKBD_LOCK();
+       UKBD_LOCK(sc);
+#endif
        keycode = ukbd_read_char_locked(kbd, wait);
        keycode = ukbd_read_char_locked(kbd, wait);
-       UKBD_UNLOCK();
+#if 0
+       UKBD_UNLOCK(sc);
+#endif
 
        return (keycode);
 }
 
        return (keycode);
 }
@@ -1743,12 +1741,11 @@ ukbd_ioctl_locked(keyboard_t *kbd, u_long cmd, caddr_t arg)
 
 #endif
 
 
 #endif
 
-       UKBD_LOCK_ASSERT();
-
        switch (cmd) {
        case KDGKBMODE:         /* get keyboard mode */
                *(int *)arg = sc->sc_mode;
                break;
        switch (cmd) {
        case KDGKBMODE:         /* get keyboard mode */
                *(int *)arg = sc->sc_mode;
                break;
+#if 0 /* XXX */
 #if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \
     defined(COMPAT_FREEBSD4) || defined(COMPAT_43)
        case _IO('K', 7):
 #if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \
     defined(COMPAT_FREEBSD4) || defined(COMPAT_43)
        case _IO('K', 7):
@@ -1756,6 +1753,7 @@ ukbd_ioctl_locked(keyboard_t *kbd, u_long cmd, caddr_t arg)
                arg = (caddr_t)&ival;
                /* FALLTHROUGH */
 #endif
                arg = (caddr_t)&ival;
                /* FALLTHROUGH */
 #endif
+#endif
        case KDSKBMODE:         /* set keyboard mode */
                switch (*(int *)arg) {
                case K_XLATE:
        case KDSKBMODE:         /* set keyboard mode */
                switch (*(int *)arg) {
                case K_XLATE:
@@ -1781,6 +1779,7 @@ ukbd_ioctl_locked(keyboard_t *kbd, u_long cmd, caddr_t arg)
        case KDGETLED:                  /* get keyboard LED */
                *(int *)arg = KBD_LED_VAL(kbd);
                break;
        case KDGETLED:                  /* get keyboard LED */
                *(int *)arg = KBD_LED_VAL(kbd);
                break;
+#if 0 /* XXX */
 #if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \
     defined(COMPAT_FREEBSD4) || defined(COMPAT_43)
        case _IO('K', 66):
 #if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \
     defined(COMPAT_FREEBSD4) || defined(COMPAT_43)
        case _IO('K', 66):
@@ -1788,6 +1787,7 @@ ukbd_ioctl_locked(keyboard_t *kbd, u_long cmd, caddr_t arg)
                arg = (caddr_t)&ival;
                /* FALLTHROUGH */
 #endif
                arg = (caddr_t)&ival;
                /* FALLTHROUGH */
 #endif
+#endif
        case KDSETLED:                  /* set keyboard LED */
                /* NOTE: lock key state in "sc_state" won't be changed */
                if (*(int *)arg & ~LOCK_MASK)
        case KDSETLED:                  /* set keyboard LED */
                /* NOTE: lock key state in "sc_state" won't be changed */
                if (*(int *)arg & ~LOCK_MASK)
@@ -1811,6 +1811,7 @@ ukbd_ioctl_locked(keyboard_t *kbd, u_long cmd, caddr_t arg)
        case KDGKBSTATE:                /* get lock key state */
                *(int *)arg = sc->sc_state & LOCK_MASK;
                break;
        case KDGKBSTATE:                /* get lock key state */
                *(int *)arg = sc->sc_state & LOCK_MASK;
                break;
+#if 0 /* XXX */
 #if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \
     defined(COMPAT_FREEBSD4) || defined(COMPAT_43)
        case _IO('K', 20):
 #if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \
     defined(COMPAT_FREEBSD4) || defined(COMPAT_43)
        case _IO('K', 20):
@@ -1818,6 +1819,7 @@ ukbd_ioctl_locked(keyboard_t *kbd, u_long cmd, caddr_t arg)
                arg = (caddr_t)&ival;
                /* FALLTHROUGH */
 #endif
                arg = (caddr_t)&ival;
                /* FALLTHROUGH */
 #endif
+#endif
        case KDSKBSTATE:                /* set lock key state */
                if (*(int *)arg & ~LOCK_MASK) {
                        return (EINVAL);
        case KDSKBSTATE:                /* set lock key state */
                if (*(int *)arg & ~LOCK_MASK) {
                        return (EINVAL);
@@ -1846,6 +1848,7 @@ ukbd_ioctl_locked(keyboard_t *kbd, u_long cmd, caddr_t arg)
                kbd->kb_delay2 = ((int *)arg)[1];
                return (0);
 
                kbd->kb_delay2 = ((int *)arg)[1];
                return (0);
 
+#if 0 /* XXX */
 #if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \
     defined(COMPAT_FREEBSD4) || defined(COMPAT_43)
        case _IO('K', 67):
 #if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \
     defined(COMPAT_FREEBSD4) || defined(COMPAT_43)
        case _IO('K', 67):
@@ -1853,13 +1856,12 @@ ukbd_ioctl_locked(keyboard_t *kbd, u_long cmd, caddr_t arg)
                arg = (caddr_t)&ival;
                /* FALLTHROUGH */
 #endif
                arg = (caddr_t)&ival;
                /* FALLTHROUGH */
 #endif
+#endif
        case KDSETRAD:                  /* set keyboard repeat rate (old
                                         * interface) */
                return (ukbd_set_typematic(kbd, *(int *)arg));
 
        case PIO_KEYMAP:                /* set keyboard translation table */
        case KDSETRAD:                  /* set keyboard repeat rate (old
                                         * interface) */
                return (ukbd_set_typematic(kbd, *(int *)arg));
 
        case PIO_KEYMAP:                /* set keyboard translation table */
-       case OPIO_KEYMAP:               /* set keyboard translation table
-                                        * (compat) */
        case PIO_KEYMAPENT:             /* set keyboard translation table
                                         * entry */
        case PIO_DEADKEYMAP:            /* set accent key translation table */
        case PIO_KEYMAPENT:             /* set keyboard translation table
                                         * entry */
        case PIO_DEADKEYMAP:            /* set accent key translation table */
@@ -1876,6 +1878,7 @@ static int
 ukbd_ioctl(keyboard_t *kbd, u_long cmd, caddr_t arg)
 {
        int result;
 ukbd_ioctl(keyboard_t *kbd, u_long cmd, caddr_t arg)
 {
        int result;
+       struct ukbd_softc *sc = kbd->kb_data;
 
        /*
         * XXX KDGKBSTATE, KDSKBSTATE and KDSETLED can be called from any
 
        /*
         * XXX KDGKBSTATE, KDSKBSTATE and KDSETLED can be called from any
@@ -1891,13 +1894,12 @@ ukbd_ioctl(keyboard_t *kbd, u_long cmd, caddr_t arg)
        case KDGKBSTATE:
        case KDSKBSTATE:
        case KDSETLED:
        case KDGKBSTATE:
        case KDSKBSTATE:
        case KDSETLED:
-               if (!mtx_owned(&Giant) && !SCHEDULER_STOPPED())
-                       return (EDEADLK);       /* best I could come up with */
+               return (EDEADLK);       /* best I could come up with */
                /* FALLTHROUGH */
        default:
                /* FALLTHROUGH */
        default:
-               UKBD_LOCK();
+               UKBD_LOCK(sc);
                result = ukbd_ioctl_locked(kbd, cmd, arg);
                result = ukbd_ioctl_locked(kbd, cmd, arg);
-               UKBD_UNLOCK();
+               UKBD_UNLOCK(sc);
                return (result);
        }
 }
                return (result);
        }
 }
@@ -1909,8 +1911,6 @@ ukbd_clear_state(keyboard_t *kbd)
 {
        struct ukbd_softc *sc = kbd->kb_data;
 
 {
        struct ukbd_softc *sc = kbd->kb_data;
 
-       UKBD_CTX_LOCK_ASSERT();
-
        sc->sc_flags &= ~(UKBD_FLAG_COMPOSE | UKBD_FLAG_POLLING);
        sc->sc_state &= LOCK_MASK;      /* preserve locking key state */
        sc->sc_accents = 0;
        sc->sc_flags &= ~(UKBD_FLAG_COMPOSE | UKBD_FLAG_POLLING);
        sc->sc_state &= LOCK_MASK;      /* preserve locking key state */
        sc->sc_accents = 0;
@@ -1944,7 +1944,7 @@ ukbd_poll(keyboard_t *kbd, int on)
 {
        struct ukbd_softc *sc = kbd->kb_data;
 
 {
        struct ukbd_softc *sc = kbd->kb_data;
 
-       UKBD_LOCK();
+       UKBD_LOCK(sc);
        if (on) {
                sc->sc_flags |= UKBD_FLAG_POLLING;
                sc->sc_poll_thread = curthread;
        if (on) {
                sc->sc_flags |= UKBD_FLAG_POLLING;
                sc->sc_poll_thread = curthread;
@@ -1952,7 +1952,7 @@ ukbd_poll(keyboard_t *kbd, int on)
                sc->sc_flags &= ~UKBD_FLAG_POLLING;
                ukbd_start_timer(sc);   /* start timer */
        }
                sc->sc_flags &= ~UKBD_FLAG_POLLING;
                ukbd_start_timer(sc);   /* start timer */
        }
-       UKBD_UNLOCK();
+       UKBD_UNLOCK(sc);
 
        return (0);
 }
 
        return (0);
 }
@@ -1963,7 +1963,6 @@ static void
 ukbd_set_leds(struct ukbd_softc *sc, uint8_t leds)
 {
 
 ukbd_set_leds(struct ukbd_softc *sc, uint8_t leds)
 {
 
-       UKBD_LOCK_ASSERT();
        DPRINTF("leds=0x%02x\n", leds);
 
        sc->sc_leds = leds;
        DPRINTF("leds=0x%02x\n", leds);
 
        sc->sc_leds = leds;
diff --git a/sys/bus/u4b/input/ukbd/Makefile b/sys/bus/u4b/input/ukbd/Makefile
new file mode 100644 (file)
index 0000000..c03ea41
--- /dev/null
@@ -0,0 +1,8 @@
+.PATH: ${.CURDIR}/..
+
+KMOD=  ukbd
+
+SRCS=  opt_bus.h opt_usb.h device_if.h bus_if.h usb_if.h \
+       ukbd.c
+
+.include <bsd.kmod.mk>
index a910df4..1a8a02b 100644 (file)
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
 /*
  * HID spec: http://www.usb.org/developers/devclass_docs/HID1_11.pdf
  */
 
 #include <sys/stdint.h>
 /*
  * HID spec: http://www.usb.org/developers/devclass_docs/HID1_11.pdf
  */
 
 #include <sys/stdint.h>
-#include <sys/stddef.h>
 #include <sys/param.h>
 #include <sys/queue.h>
 #include <sys/types.h>
 #include <sys/param.h>
 #include <sys/queue.h>
 #include <sys/types.h>
@@ -45,10 +41,8 @@ __FBSDID("$FreeBSD$");
 #include <sys/bus.h>
 #include <sys/module.h>
 #include <sys/lock.h>
 #include <sys/bus.h>
 #include <sys/module.h>
 #include <sys/lock.h>
-#include <sys/mutex.h>
 #include <sys/condvar.h>
 #include <sys/sysctl.h>
 #include <sys/condvar.h>
 #include <sys/sysctl.h>
-#include <sys/sx.h>
 #include <sys/unistd.h>
 #include <sys/callout.h>
 #include <sys/malloc.h>
 #include <sys/unistd.h>
 #include <sys/callout.h>
 #include <sys/malloc.h>
@@ -57,16 +51,16 @@ __FBSDID("$FreeBSD$");
 #include <sys/fcntl.h>
 #include <sys/sbuf.h>
 
 #include <sys/fcntl.h>
 #include <sys/sbuf.h>
 
-#include <dev/usb/usb.h>
-#include <dev/usb/usbdi.h>
-#include <dev/usb/usbdi_util.h>
-#include <dev/usb/usbhid.h>
-#include "usbdevs.h"
+#include <bus/u4b/usb.h>
+#include <bus/u4b/usbdi.h>
+#include <bus/u4b/usbdi_util.h>
+#include <bus/u4b/usbhid.h>
+#include <bus/u4b/usbdevs.h>
 
 #define        USB_DEBUG_VAR ums_debug
 
 #define        USB_DEBUG_VAR ums_debug
-#include <dev/usb/usb_debug.h>
+#include <bus/u4b/usb_debug.h>
 
 
-#include <dev/usb/quirk/usb_quirk.h>
+#include <bus/u4b/quirk/usb_quirk.h>
 
 #include <sys/ioccom.h>
 #include <sys/filio.h>
 
 #include <sys/ioccom.h>
 #include <sys/filio.h>
@@ -123,7 +117,7 @@ struct ums_info {
 
 struct ums_softc {
        struct usb_fifo_sc sc_fifo;
 
 struct ums_softc {
        struct usb_fifo_sc sc_fifo;
-       struct mtx sc_mtx;
+       struct lock sc_lock;
        struct usb_callout sc_callout;
        struct ums_info sc_info[UMS_INFO_MAX];
 
        struct usb_callout sc_callout;
        struct ums_info sc_info[UMS_INFO_MAX];
 
@@ -172,7 +166,7 @@ ums_put_queue_timeout(void *__sc)
 {
        struct ums_softc *sc = __sc;
 
 {
        struct ums_softc *sc = __sc;
 
-       mtx_assert(&sc->sc_mtx, MA_OWNED);
+       KKASSERT(lockowned(&sc->sc_lock));
 
        ums_put_queue(sc, 0, 0, 0, 0, 0);
 }
 
        ums_put_queue(sc, 0, 0, 0, 0, 0);
 }
@@ -426,7 +420,7 @@ ums_probe(device_t dev)
                }
        }
        hid_end_parse(hd);
                }
        }
        hid_end_parse(hd);
-       free(d_ptr, M_TEMP);
+       kfree(d_ptr, M_TEMP);
        return (found ? BUS_PROBE_DEFAULT : ENXIO);
 }
 
        return (found ? BUS_PROBE_DEFAULT : ENXIO);
 }
 
@@ -564,9 +558,9 @@ ums_attach(device_t dev)
 
        device_set_usb_desc(dev);
 
 
        device_set_usb_desc(dev);
 
-       mtx_init(&sc->sc_mtx, "ums lock", NULL, MTX_DEF | MTX_RECURSE);
+       lockinit(&sc->sc_lock, "ums lock", 0, LK_CANRECURSE);
 
 
-       usb_callout_init_mtx(&sc->sc_callout, &sc->sc_mtx, 0);
+       usb_callout_init_mtx(&sc->sc_callout, &sc->sc_lock, 0);
 
        /*
          * Force the report (non-boot) protocol.
 
        /*
          * Force the report (non-boot) protocol.
@@ -579,7 +573,7 @@ ums_attach(device_t dev)
 
        err = usbd_transfer_setup(uaa->device,
            &uaa->info.bIfaceIndex, sc->sc_xfer, ums_config,
 
        err = usbd_transfer_setup(uaa->device,
            &uaa->info.bIfaceIndex, sc->sc_xfer, ums_config,
-           UMS_N_TRANSFER, sc, &sc->sc_mtx);
+           UMS_N_TRANSFER, sc, &sc->sc_lock);
 
        if (err) {
                DPRINTF("error=%s\n", usbd_errstr(err));
 
        if (err) {
                DPRINTF("error=%s\n", usbd_errstr(err));
@@ -649,7 +643,7 @@ ums_attach(device_t dev)
                    "than interrupt size, %d bytes!\n", isize,
                    usbd_xfer_max_framelen(sc->sc_xfer[UMS_INTR_DT]));
        }
                    "than interrupt size, %d bytes!\n", isize,
                    usbd_xfer_max_framelen(sc->sc_xfer[UMS_INTR_DT]));
        }
-       free(d_ptr, M_TEMP);
+       kfree(d_ptr, M_TEMP);
        d_ptr = NULL;
 
 #ifdef USB_DEBUG
        d_ptr = NULL;
 
 #ifdef USB_DEBUG
@@ -696,24 +690,26 @@ ums_attach(device_t dev)
        sc->sc_mode.syncmask[0] = MOUSE_MSC_SYNCMASK;
        sc->sc_mode.syncmask[1] = MOUSE_MSC_SYNC;
 
        sc->sc_mode.syncmask[0] = MOUSE_MSC_SYNCMASK;
        sc->sc_mode.syncmask[1] = MOUSE_MSC_SYNC;
 
-       err = usb_fifo_attach(uaa->device, sc, &sc->sc_mtx,
+       err = usb_fifo_attach(uaa->device, sc, &sc->sc_lock,
            &ums_fifo_methods, &sc->sc_fifo,
            device_get_unit(dev), 0 - 1, uaa->info.bIfaceIndex,
            UID_ROOT, GID_OPERATOR, 0644);
        if (err) {
                goto detach;
        }
            &ums_fifo_methods, &sc->sc_fifo,
            device_get_unit(dev), 0 - 1, uaa->info.bIfaceIndex,
            UID_ROOT, GID_OPERATOR, 0644);
        if (err) {
                goto detach;
        }
+#if 0 /* XXXDF */
        SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev),
            SYSCTL_CHILDREN(device_get_sysctl_tree(dev)),
            OID_AUTO, "parseinfo", CTLTYPE_STRING|CTLFLAG_RD,
            sc, 0, ums_sysctl_handler_parseinfo,
            "", "Dump of parsed HID report descriptor");
        SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev),
            SYSCTL_CHILDREN(device_get_sysctl_tree(dev)),
            OID_AUTO, "parseinfo", CTLTYPE_STRING|CTLFLAG_RD,
            sc, 0, ums_sysctl_handler_parseinfo,
            "", "Dump of parsed HID report descriptor");
+#endif
 
        return (0);
 
 detach:
        if (d_ptr) {
 
        return (0);
 
 detach:
        if (d_ptr) {
-               free(d_ptr, M_TEMP);
+               kfree(d_ptr, M_TEMP);
        }
        ums_detach(dev);
        return (ENOMEM);
        }
        ums_detach(dev);
        return (ENOMEM);
@@ -732,7 +728,7 @@ ums_detach(device_t self)
 
        usb_callout_drain(&sc->sc_callout);
 
 
        usb_callout_drain(&sc->sc_callout);
 
-       mtx_destroy(&sc->sc_mtx);
+       lockuninit(&sc->sc_lock);
 
        return (0);
 }
 
        return (0);
 }
@@ -873,7 +869,7 @@ ums_ioctl(struct usb_fifo *fifo, u_long cmd, void *addr, int fflags)
 
        DPRINTFN(2, "\n");
 
 
        DPRINTFN(2, "\n");
 
-       mtx_lock(&sc->sc_mtx);
+       lockmgr(&sc->sc_lock, LK_EXCLUSIVE);
 
        switch (cmd) {
        case MOUSE_GETHWINFO:
 
        switch (cmd) {
        case MOUSE_GETHWINFO:
@@ -978,7 +974,7 @@ ums_ioctl(struct usb_fifo *fifo, u_long cmd, void *addr, int fflags)
        }
 
 done:
        }
 
 done:
-       mtx_unlock(&sc->sc_mtx);
+       lockmgr(&sc->sc_lock, LK_RELEASE);
        return (error);
 }
 
        return (error);
 }
 
diff --git a/sys/bus/u4b/input/ums/Makefile b/sys/bus/u4b/input/ums/Makefile
new file mode 100644 (file)
index 0000000..7efc31c
--- /dev/null
@@ -0,0 +1,8 @@
+.PATH: ${.CURDIR}/..
+
+KMOD=  ums
+
+SRCS=  opt_bus.h opt_usb.h device_if.h bus_if.h usb_if.h \
+       ums.c
+
+.include <bsd.kmod.mk>