On Tue, 12 Feb 2002, David Taylor wrote: > I have approximately no experience with FreeBSD device drivers, but I'm > currently attempting to see if I can figure out how the other u*.c files > handle detaching... any hints would be appreciated :) >
Well. I managed to create a patch which _works_. I have some serious doubts about its correctness, however. -- David Taylor [EMAIL PROTECTED] "The future just ain't what it used to be"
--- urio.c.old Tue Feb 12 22:31:14 2002 +++ urio.c Tue Feb 12 22:02:03 2002 @@ -160,6 +160,8 @@ int sc_refcnt; #if defined(__NetBSD__) || defined(__OpenBSD__) u_char sc_dying; +#elif defined(__FreeBSD__) + dev_t dev; #endif }; @@ -271,8 +273,7 @@ #if defined(__FreeBSD__) #if (__FreeBSD__ >= 4) - /* XXX no error trapping, no storing of dev_t */ - (void) make_dev(&urio_cdevsw, device_get_unit(self), + sc->dev = make_dev(&urio_cdevsw, device_get_unit(self), UID_ROOT, GID_OPERATOR, 0644, "urio%d", device_get_unit(self)); #endif @@ -633,22 +634,25 @@ } return (0); } +#endif USB_DETACH(urio) { USB_DETACH_START(urio, sc); - struct urio_endpoint *sce; - int i, dir; - int s; + struct vnode *vp; + #if defined(__NetBSD__) || defined(__OpenBSD__) - int maj, mn; + struct urio_endpoit *sce; + int i, dir; + int s; + int maj, mn; DPRINTF(("urio_detach: sc=%p flags=%d\n", sc, flags)); + sc->sc_dying = 1; #elif defined(__FreeBSD__) DPRINTF(("urio_detach: sc=%p\n", sc)); #endif - sc->sc_dying = 1; /* Abort all pipes. Causes processes waiting for transfer to wake. */ #if 0 for (i = 0; i < USB_MAX_ENDPOINTS; i++) { @@ -668,7 +672,7 @@ usb_detach_wait(USBDEV(sc->sc_dev)); } splx(s); -#else +/* #else */ if (sc->sc_pipeh_in) usbd_abort_pipe(sc->sc_pipeh_in); @@ -692,25 +696,20 @@ /* Nuke the vnodes for any open instances (calls close). */ mn = self->dv_unit * USB_MAX_ENDPOINTS; vdevgone(maj, mn, mn + USB_MAX_ENDPOINTS - 1, VCHR); -#elif defined(__FreeBSD__) - /* XXX not implemented yet */ -#endif - usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev, - USBDEV(sc->sc_dev)); + usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev, + USBDEV(sc->sc_dev)); +#elif defined(__FreeBSD__) + device_set_desc(self, NULL); + vp = SLIST_FIRST(&sc->dev->si_hlist); + if (vp) + VOP_REVOKE(vp, REVOKEALL); - return (0); + destroy_dev(sc->dev); +#endif + return (0); } -#endif /* defined(__NetBSD__) || defined(__OpenBSD__) */ - #if defined(__FreeBSD__) -Static int -urio_detach(device_t self) -{ - DPRINTF(("%s: disconnected\n", USBDEVNAME(self))); - device_set_desc(self, NULL); - return 0; -} #if (__FreeBSD__ >= 4) DRIVER_MODULE(urio, uhub, urio_driver, urio_devclass, usbd_driver_load, 0);