summaryrefslogtreecommitdiff
path: root/sys/dev/usb/usbdi.h
diff options
context:
space:
mode:
authorJacob Meuser <jakemsr@cvs.openbsd.org>2011-02-04 08:21:40 +0000
committerJacob Meuser <jakemsr@cvs.openbsd.org>2011-02-04 08:21:40 +0000
commit4515d91db5080342bab395c673d6d8aabc0bb2ef (patch)
tree2cc47e8ff8d6da42f9f828b07e00fe3bf2cbd13a /sys/dev/usb/usbdi.h
parentf0a0961e47c4711ff31e11aa2dceabd58ece1b9e (diff)
* merge 'onqueue' and 'running' members of struct usb_task into
a new member, 'state'. * add new function 'usb_wait_task()', which waits for queued or running usb_tasks to complete. * in the USB_DEVICEINFO ioctl, fill struct usb_device_info in a usb_task, thereby avoiding races against driver attach/detach. ok miod@
Diffstat (limited to 'sys/dev/usb/usbdi.h')
-rw-r--r--sys/dev/usb/usbdi.h18
1 files changed, 12 insertions, 6 deletions
diff --git a/sys/dev/usb/usbdi.h b/sys/dev/usb/usbdi.h
index 5a990d38fa3..a38a953031d 100644
--- a/sys/dev/usb/usbdi.h
+++ b/sys/dev/usb/usbdi.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: usbdi.h,v 1.39 2011/01/25 20:03:36 jakemsr Exp $ */
+/* $OpenBSD: usbdi.h,v 1.40 2011/02/04 08:21:39 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 $ */
@@ -139,6 +139,7 @@ usbd_status usbd_set_interface(usbd_interface_handle, int);
int usbd_get_no_alts(usb_config_descriptor_t *, int);
usbd_status usbd_get_interface(usbd_interface_handle iface, u_int8_t *aiface);
void usbd_fill_deviceinfo(usbd_device_handle, struct usb_device_info *, int);
+void usbd_fill_di_task(void *);
int usbd_get_interface_altindex(usbd_interface_handle iface);
usb_interface_descriptor_t *usbd_find_idesc(usb_config_descriptor_t *cd,
@@ -187,28 +188,33 @@ const usb_descriptor_t *usb_desc_iter_next(usbd_desc_iter_t *);
* has been detected. But it may also be used by drivers that need to
* perform (short) tasks that must have a process context.
*/
+enum usb_task_state {
+ USB_TASK_STATE_NONE,
+ USB_TASK_STATE_ONQ,
+ USB_TASK_STATE_RUN
+};
+
struct usb_task {
TAILQ_ENTRY(usb_task) next;
usbd_device_handle dev;
void (*fun)(void *);
void *arg;
char type;
-#define USB_TASK_TYPE_GENERIC 0
+#define USB_TASK_TYPE_GENERIC 0
#define USB_TASK_TYPE_EXPLORE 1
#define USB_TASK_TYPE_ABORT 2
- char onqueue;
- char running;
+ enum usb_task_state state;
};
void usb_add_task(usbd_device_handle, struct usb_task *);
void usb_rem_task(usbd_device_handle, struct usb_task *);
+void usb_wait_task(usbd_device_handle, struct usb_task *);
void usb_rem_wait_task(usbd_device_handle, struct usb_task *);
#define usb_init_task(t, f, a, y) \
((t)->fun = (f), \
(t)->arg = (a), \
(t)->type = (y), \
- (t)->onqueue = 0, \
- (t)->running = 0)
+ (t)->state = USB_TASK_STATE_NONE)
struct usb_devno {
u_int16_t ud_vendor;