From c9efdb87e8d3706a61b86095220c70ef8e81a629 Mon Sep 17 00:00:00 2001 From: Nick Hibma Date: Sun, 30 May 1999 12:48:49 +0000 Subject: [PATCH] When the mouse is being disconnected, do the followings: - Call ums_disable() to abort the pipe. - Do not wake up processes which has been waiting or polling for mouse data. It won't be available anymore. Submitted by: Kazutaka YOKOTA --- sys/dev/usb/ums.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/sys/dev/usb/ums.c b/sys/dev/usb/ums.c index 6b4e1b6920d..4f80e6a4624 100644 --- a/sys/dev/usb/ums.c +++ b/sys/dev/usb/ums.c @@ -368,10 +368,8 @@ ums_detach(device_t self) { struct ums_softc *sc = device_get_softc(self); - if (sc->sc_enabled) { - usbd_abort_pipe(sc->sc_intrpipe); - usbd_close_pipe(sc->sc_intrpipe); - } + if (sc->sc_enabled) + ums_disable(sc); sc->sc_disconnected = 1; DPRINTF(("%s: disconnected\n", USBDEVNAME(self))); @@ -379,6 +377,14 @@ ums_detach(device_t self) free(sc->sc_loc_btn, M_USB); free(sc->sc_ibuf, M_USB); + /* + * XXX If we wakeup the process here, the device will be gone by + * the time the process gets a chance to notice. *_close and friends + * should be fixed to handle this case. + * Or we should do a delayed detach for this. + */ + +#if 0 /* someone waiting for data */ if (sc->state & UMS_ASLEEP) { sc->state &= ~UMS_ASLEEP; @@ -388,6 +394,7 @@ ums_detach(device_t self) sc->state &= ~UMS_SELECT; selwakeup(&sc->rsel); } +#endif return 0; } @@ -605,6 +612,9 @@ ums_close(dev_t dev, int flag, int fmt, struct proc *p) { USB_GET_SC(ums, UMSUNIT(dev), sc); + if (sc == NULL) + return 0; + if (sc->sc_enabled) ums_disable(sc);