diff options
author | Jacob Meuser <jakemsr@cvs.openbsd.org> | 2010-12-06 04:28:42 +0000 |
---|---|---|
committer | Jacob Meuser <jakemsr@cvs.openbsd.org> | 2010-12-06 04:28:42 +0000 |
commit | 9f859f597e76071c9526e0c90e6ac400f16a14fc (patch) | |
tree | e1ee4c4a2fcce5c575158b7d591768e23ce139f1 /sys/dev/usb/usb.c | |
parent | 6f1809065a5ecadb4d890dd7e0d8d387acc5e608 (diff) |
* check that the root hub has been configured before trying to
free it's resources
* use usbd_is_dying() instead of directly checking the device's
bus dying flag
Diffstat (limited to 'sys/dev/usb/usb.c')
-rw-r--r-- | sys/dev/usb/usb.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/sys/dev/usb/usb.c b/sys/dev/usb/usb.c index 3787a4eace3..6207c070266 100644 --- a/sys/dev/usb/usb.c +++ b/sys/dev/usb/usb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: usb.c,v 1.69 2010/10/23 15:42:09 jakemsr Exp $ */ +/* $OpenBSD: usb.c,v 1.70 2010/12/06 04:28:41 jakemsr Exp $ */ /* $NetBSD: usb.c,v 1.77 2003/01/01 00:10:26 thorpej Exp $ */ /* @@ -300,7 +300,7 @@ usb_add_task(usbd_device_handle dev, struct usb_task *task) task->onqueue, task->type)); /* Don't add task if the device's root hub is dying. */ - if (dev->bus->dying) + if (usbd_is_dying(dev)) return; s = splusb(); @@ -429,7 +429,7 @@ usb_task_thread(void *arg) } task->onqueue = 0; /* Don't execute the task if the root hub is gone. */ - if (task->dev->bus->dying) + if (usbd_is_dying(task->dev)) continue; task->running = 1; splx(s); @@ -466,7 +466,7 @@ usb_abort_task_thread(void *arg) } task->onqueue = 0; /* Don't execute the task if the root hub is gone. */ - if (task->dev->bus->dying) + if (usbd_is_dying(task->dev)) continue; task->running = 1; splx(s); @@ -945,13 +945,15 @@ usb_detach(struct device *self, int flags) sc->sc_bus->dying = 1; - /* Make all devices disconnect. */ - if (sc->sc_port.device != NULL) - usb_disconnect_port(&sc->sc_port, self); + if (sc->sc_bus->root_hub != NULL) { + /* Make all devices disconnect. */ + if (sc->sc_port.device != NULL) + usb_disconnect_port(&sc->sc_port, self); - usb_rem_wait_task(sc->sc_bus->root_hub, &sc->sc_explore_task); + usb_rem_wait_task(sc->sc_bus->root_hub, &sc->sc_explore_task); - usbd_finish(); + usbd_finish(); + } if (sc->sc_bus->soft != NULL) { softintr_disestablish(sc->sc_bus->soft); |