summaryrefslogtreecommitdiffstats
path: root/sys/dev/usb/ugen.c
diff options
context:
space:
mode:
authorn_hibma <n_hibma@FreeBSD.org>1999-11-21 17:25:30 +0000
committern_hibma <n_hibma@FreeBSD.org>1999-11-21 17:25:30 +0000
commit183c85e4b413f7c0d1c90772ccb22075f5e49bed (patch)
treeba5bbef1bb21368ac6db96b23eb0cf7cfa125f88 /sys/dev/usb/ugen.c
parentd1dec864e4e1fe680c428c642401fb3b163f137c (diff)
downloadFreeBSD-src-183c85e4b413f7c0d1c90772ccb22075f5e49bed.zip
FreeBSD-src-183c85e4b413f7c0d1c90772ccb22075f5e49bed.tar.gz
Revoke the vnodes on detach. This avoids the crashes people have seen
when moused was still running when the mouse was detached. Convert uhid to use make_dev while I am there. Ugen still needs to be converted.
Diffstat (limited to 'sys/dev/usb/ugen.c')
-rw-r--r--sys/dev/usb/ugen.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/sys/dev/usb/ugen.c b/sys/dev/usb/ugen.c
index ba3f7e2..cd0e6cc 100644
--- a/sys/dev/usb/ugen.c
+++ b/sys/dev/usb/ugen.c
@@ -149,9 +149,10 @@ static usb_config_descriptor_t *ugen_get_cdesc __P((struct ugen_softc *sc,
static usbd_status ugen_set_interface __P((struct ugen_softc *, int, int));
static int ugen_get_alt_index __P((struct ugen_softc *sc, int ifaceidx));
+#define UGENENDPMAX 16 /* maximum number of endpoints, see usb spec */
#define UGENUNIT(n) ((minor(n) >> 4) & 0xf)
#define UGENENDPOINT(n) (minor(n) & 0xf)
-#define UGENDEV(u, e) (makedev(0, ((u) << 4) | (e)))
+#define UGENDEV(u, e) (makedev(UGEN_CDEV_MAJOR, ((u) << 4) | (e)))
USB_DECLARE_DRIVER(ugen);
@@ -629,7 +630,13 @@ USB_DETACH(ugen)
int s;
#if defined(__NetBSD__) || defined(__OpenBSD__)
int maj, mn;
+#elif defined(__FreeBSD__)
+ struct vnode *vp;
+ dev_t dev;
+ int endpt;
+#endif
+#if defined(__NetBSD__) || defined(__OpenBSD__)
DPRINTF(("ugen_detach: sc=%p flags=%d\n", sc, flags));
#elif defined(__FreeBSD__)
DPRINTF(("ugen_detach: sc=%p\n", sc));
@@ -665,7 +672,12 @@ USB_DETACH(ugen)
mn = self->dv_unit * USB_MAX_ENDPOINTS;
vdevgone(maj, mn, mn + USB_MAX_ENDPOINTS - 1, VCHR);
#elif defined(__FreeBSD__)
- /* XXX not implemented yet */
+ for (endpt = 0; endpt < UGENENDPMAX; endpt++) {
+ dev = UGENDEV(device_get_unit(self), endpt);
+ vp = SLIST_FIRST(&dev->si_hlist);
+ if (vp)
+ VOP_REVOKE(vp, REVOKEALL);
+ }
#endif
return (0);
OpenPOWER on IntegriCloud