Module Name: src
Committed By: mrg
Date: Sat Feb 25 20:47:32 UTC 2012
Modified Files:
src/sys/dev/usb [jmcneill-usbmp]: usbdi_util.c usbdi_util.h
Log Message:
implement cv/mutex based usb_detach_wait/wakeup().
To generate a diff of this commit:
cvs rdiff -u -r1.55.12.2 -r1.55.12.3 src/sys/dev/usb/usbdi_util.c
cvs rdiff -u -r1.41 -r1.41.16.1 src/sys/dev/usb/usbdi_util.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/usb/usbdi_util.c
diff -u src/sys/dev/usb/usbdi_util.c:1.55.12.2 src/sys/dev/usb/usbdi_util.c:1.55.12.3
--- src/sys/dev/usb/usbdi_util.c:1.55.12.2 Thu Feb 23 09:25:03 2012
+++ src/sys/dev/usb/usbdi_util.c Sat Feb 25 20:47:32 2012
@@ -1,12 +1,12 @@
-/* $NetBSD: usbdi_util.c,v 1.55.12.2 2012/02/23 09:25:03 mrg Exp $ */
+/* $NetBSD: usbdi_util.c,v 1.55.12.3 2012/02/25 20:47:32 mrg Exp $ */
/*
- * Copyright (c) 1998 The NetBSD Foundation, Inc.
+ * Copyright (c) 1998, 2012 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Lennart Augustsson ([email protected]) at
- * Carlstedt Research & Technology.
+ * Carlstedt Research & Technology and Matthew R. Green ([email protected]).
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: usbdi_util.c,v 1.55.12.2 2012/02/23 09:25:03 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbdi_util.c,v 1.55.12.3 2012/02/25 20:47:32 mrg Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -514,6 +514,23 @@ usbd_intr_transfer(usbd_xfer_handle xfer
}
void
+usb_detach_waitcv(device_t dv, kcondvar_t *cv, kmutex_t *lock)
+{
+ DPRINTF(("usb_detach_waitcv: waiting for %s\n", device_xname(dv)));
+ if (cv_timedwait(cv, lock, hz * 60)) // dv, PZERO, "usbdet", hz * 60
+ printf("usb_detach_waitcv: %s didn't detach\n",
+ device_xname(dv));
+ DPRINTF(("usb_detach_waitcv: %s done\n", device_xname(dv)));
+}
+
+void
+usb_detach_broadcast(device_t dv, kcondvar_t *cv)
+{
+ DPRINTF(("usb_detach_broadcast: for %s\n", device_xname(dv)));
+ cv_broadcast(cv);
+}
+
+void
usb_detach_wait(device_t dv)
{
DPRINTF(("usb_detach_wait: waiting for %s\n", device_xname(dv)));
Index: src/sys/dev/usb/usbdi_util.h
diff -u src/sys/dev/usb/usbdi_util.h:1.41 src/sys/dev/usb/usbdi_util.h:1.41.16.1
--- src/sys/dev/usb/usbdi_util.h:1.41 Thu Nov 12 08:32:57 2009
+++ src/sys/dev/usb/usbdi_util.h Sat Feb 25 20:47:32 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: usbdi_util.h,v 1.41 2009/11/12 08:32:57 uebayasi Exp $ */
+/* $NetBSD: usbdi_util.h,v 1.41.16.1 2012/02/25 20:47:32 mrg Exp $ */
/*
* Copyright (c) 1998, 2004 The NetBSD Foundation, Inc.
@@ -86,6 +86,12 @@ usbd_status usbd_intr_transfer(usbd_xfer
void usb_detach_wait(device_t);
void usb_detach_wakeup(device_t);
+/*
+ * MPSAFE versions - mutex must be at IPL_USB.
+ */
+void usb_detach_waitcv(device_t dv, kcondvar_t *, kmutex_t *);
+void usb_detach_broadcast(device_t, kcondvar_t *);
+
typedef struct {
uByte bLength;