Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/jmcneill-usbmp]: src/sys/dev/usb implement cv/mutex based usb_detach_wai...



details:   https://anonhg.NetBSD.org/src/rev/9485560fb597
branches:  jmcneill-usbmp
changeset: 771818:9485560fb597
user:      mrg <mrg%NetBSD.org@localhost>
date:      Sat Feb 25 20:47:32 2012 +0000

description:
implement cv/mutex based usb_detach_wait/wakeup().

diffstat:

 sys/dev/usb/usbdi_util.c |  25 +++++++++++++++++++++----
 sys/dev/usb/usbdi_util.h |   8 +++++++-
 2 files changed, 28 insertions(+), 5 deletions(-)

diffs (74 lines):

diff -r c55e67f829fb -r 9485560fb597 sys/dev/usb/usbdi_util.c
--- a/sys/dev/usb/usbdi_util.c  Sat Feb 25 20:46:33 2012 +0000
+++ b/sys/dev/usb/usbdi_util.c  Sat Feb 25 20:47:32 2012 +0000
@@ -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 (lennart%augustsson.net@localhost) at
- * Carlstedt Research & Technology.
+ * Carlstedt Research & Technology and Matthew R. Green (mrg%eterna.com.au@localhost).
  *
  * 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 @@
 }
 
 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)));
diff -r c55e67f829fb -r 9485560fb597 sys/dev/usb/usbdi_util.h
--- a/sys/dev/usb/usbdi_util.h  Sat Feb 25 20:46:33 2012 +0000
+++ b/sys/dev/usb/usbdi_util.h  Sat Feb 25 20:47:32 2012 +0000
@@ -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 @@
 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;



Home | Main Index | Thread Index | Old Index