summaryrefslogtreecommitdiffstats
path: root/sys/dev/usb/usbdi.c
diff options
context:
space:
mode:
authorjakemsr <jakemsr@openbsd.org>2010-09-23 04:58:02 +0000
committerjakemsr <jakemsr@openbsd.org>2010-09-23 04:58:02 +0000
commitaf76094e62e54c7561aa277339559ee225fd46f0 (patch)
tree88f7ccf88bb98f04244bebc46b787f80a6e0adf1 /sys/dev/usb/usbdi.c
parentremove reference to msgs(1) (diff)
downloadwireguard-openbsd-af76094e62e54c7561aa277339559ee225fd46f0.tar.xz
wireguard-openbsd-af76094e62e54c7561aa277339559ee225fd46f0.zip
instead of running usb_explore() from individual kthreads for each
USB bus, make usb_explore() a usb_task. reduces races during normal USB device detach, since now usb_tasks and detach happen in the same process. ok yuo@, matthew@ helped with the task thread loop
Diffstat (limited to 'sys/dev/usb/usbdi.c')
-rw-r--r--sys/dev/usb/usbdi.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/sys/dev/usb/usbdi.c b/sys/dev/usb/usbdi.c
index b33d7f9fe00..043b104981e 100644
--- a/sys/dev/usb/usbdi.c
+++ b/sys/dev/usb/usbdi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: usbdi.c,v 1.38 2010/03/05 17:28:54 mk Exp $ */
+/* $OpenBSD: usbdi.c,v 1.39 2010/09/23 04:58:02 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 $ */
@@ -71,15 +71,18 @@ struct rwlock usbpalock;
void
usbd_init(void)
{
- if (usbd_nbuses == 0)
+ if (usbd_nbuses == 0) {
rw_init(&usbpalock, "usbpalock");
+ usb_begin_tasks();
+ }
usbd_nbuses++;
}
void
usbd_finish(void)
{
- --usbd_nbuses;
+ if (--usbd_nbuses == 0)
+ usb_end_tasks();
}
static __inline int