summaryrefslogtreecommitdiffstats
path: root/sys/dev/usb/ums.c
diff options
context:
space:
mode:
authorn_hibma <n_hibma@FreeBSD.org>1999-05-30 12:48:49 +0000
committern_hibma <n_hibma@FreeBSD.org>1999-05-30 12:48:49 +0000
commit678ee57ac43a401a3aeb2644429792fc440ec926 (patch)
tree799c71f05b3a4d3207a970a91cfa00661712cfc6 /sys/dev/usb/ums.c
parent89255a036adc40f08f6247a7228b35a1bc769cb7 (diff)
downloadFreeBSD-src-678ee57ac43a401a3aeb2644429792fc440ec926.zip
FreeBSD-src-678ee57ac43a401a3aeb2644429792fc440ec926.tar.gz
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 <yokota@zodiac.mech.utsunomiya-u.ac.jp>
Diffstat (limited to 'sys/dev/usb/ums.c')
-rw-r--r--sys/dev/usb/ums.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/sys/dev/usb/ums.c b/sys/dev/usb/ums.c
index 6b4e1b6..4f80e6a 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);
OpenPOWER on IntegriCloud