diff options
author | Jacob Meuser <jakemsr@cvs.openbsd.org> | 2010-12-06 04:25:28 +0000 |
---|---|---|
committer | Jacob Meuser <jakemsr@cvs.openbsd.org> | 2010-12-06 04:25:28 +0000 |
commit | 6f1809065a5ecadb4d890dd7e0d8d387acc5e608 (patch) | |
tree | fa332c907a8e5021b97dbd89a0dcc4c84349d3eb | |
parent | 441fa3ce331bbaf030cb213296348b42f53cb05b (diff) |
* add dying flag to struct usbd_device
* add usbd_deactivate(), which should be use to set the dying flag in
struct usbd_device
* add usbd_is_dying(), which can be used to check if either the device
or the associated bus dying flag has been set
* use usbd_is_dying() to check if the deivce or bus is dying before
issuing transfers or requests
-rw-r--r-- | sys/dev/usb/usbdi.c | 19 | ||||
-rw-r--r-- | sys/dev/usb/usbdi.h | 5 | ||||
-rw-r--r-- | sys/dev/usb/usbdivar.h | 3 |
3 files changed, 23 insertions, 4 deletions
diff --git a/sys/dev/usb/usbdi.c b/sys/dev/usb/usbdi.c index f619fd23460..01e88d93a03 100644 --- a/sys/dev/usb/usbdi.c +++ b/sys/dev/usb/usbdi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: usbdi.c,v 1.40 2010/09/23 05:44:15 jakemsr Exp $ */ +/* $OpenBSD: usbdi.c,v 1.41 2010/12/06 04:25:27 jakemsr Exp $ */ /* $NetBSD: usbdi.c,v 1.103 2002/09/27 15:37:38 provos Exp $ */ /* $FreeBSD: src/sys/dev/usb/usbdi.c,v 1.28 1999/11/17 22:33:49 n_hibma Exp $ */ @@ -85,6 +85,18 @@ usbd_finish(void) usb_end_tasks(); } +int +usbd_is_dying(usbd_device_handle dev) +{ + return (dev->dying || dev->bus->dying); +} + +void +usbd_deactivate(usbd_device_handle dev) +{ + dev->dying = 1; +} + static __inline int usbd_xfer_isread(usbd_xfer_handle xfer) { @@ -269,6 +281,9 @@ usbd_transfer(usbd_xfer_handle xfer) u_int size; int s; + if (usbd_is_dying(pipe->device)) + return (USBD_IOERROR); + DPRINTFN(5,("usbd_transfer: xfer=%p, flags=%d, pipe=%p, running=%d\n", xfer, xfer->flags, pipe, pipe->running)); #ifdef USB_DEBUG @@ -923,7 +938,7 @@ usbd_do_request_flags_pipe(usbd_device_handle dev, usbd_pipe_handle pipe, #endif /* If the bus is gone, don't go any further. */ - if (dev->bus->dying) + if (usbd_is_dying(dev)) return (USBD_IOERROR); xfer = usbd_alloc_xfer(dev); diff --git a/sys/dev/usb/usbdi.h b/sys/dev/usb/usbdi.h index 34f60858d96..5996ad61c65 100644 --- a/sys/dev/usb/usbdi.h +++ b/sys/dev/usb/usbdi.h @@ -1,4 +1,4 @@ -/* $OpenBSD: usbdi.h,v 1.35 2010/10/23 15:42:09 jakemsr Exp $ */ +/* $OpenBSD: usbdi.h,v 1.36 2010/12/06 04:25:27 jakemsr Exp $ */ /* $NetBSD: usbdi.h,v 1.62 2002/07/11 21:14:35 augustss Exp $ */ /* $FreeBSD: src/sys/dev/usb/usbdi.h,v 1.18 1999/11/17 22:33:49 n_hibma Exp $ */ @@ -165,6 +165,9 @@ usbd_status usbd_reload_device_desc(usbd_device_handle); int usbd_ratecheck(struct timeval *last); +int usbd_is_dying(usbd_device_handle); +void usbd_deactivate(usbd_device_handle); + /* An iterator for descriptors. */ typedef struct { const uByte *cur; diff --git a/sys/dev/usb/usbdivar.h b/sys/dev/usb/usbdivar.h index b2a22a27a86..2ebdb9b9d9b 100644 --- a/sys/dev/usb/usbdivar.h +++ b/sys/dev/usb/usbdivar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: usbdivar.h,v 1.39 2010/09/23 05:44:16 jakemsr Exp $ */ +/* $OpenBSD: usbdivar.h,v 1.40 2010/12/06 04:25:27 jakemsr Exp $ */ /* $NetBSD: usbdivar.h,v 1.70 2002/07/11 21:14:36 augustss Exp $ */ /* $FreeBSD: src/sys/dev/usb/usbdivar.h,v 1.11 1999/11/17 22:33:51 n_hibma Exp $ */ @@ -125,6 +125,7 @@ struct usbd_bus { struct usbd_device { struct usbd_bus *bus; /* our controller */ struct usbd_pipe *default_pipe; /* pipe 0 */ + u_int8_t dying; /* removed */ u_int8_t address; /* device address */ u_int8_t config; /* current configuration # */ u_int8_t depth; /* distance from root hub */ |