summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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