Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/usb Remove (mostly useless) usb_detach_{broadcast, wa...
details: https://anonhg.NetBSD.org/src/rev/f6d2ac3c3a29
branches: trunk
changeset: 448707:f6d2ac3c3a29
user: skrll <skrll%NetBSD.org@localhost>
date: Thu Feb 07 13:20:41 2019 +0000
description:
Remove (mostly useless) usb_detach_{broadcast,wait} and replace with
cv_{broadcast,timedwait}
Really should loop on conditon.
diffstat:
sys/dev/usb/ugen.c | 13 +++++++------
sys/dev/usb/uhid.c | 14 +++++++-------
sys/dev/usb/umass.c | 7 ++++---
sys/dev/usb/umass_scsipi.c | 8 ++++----
sys/dev/usb/umidi.c | 11 ++++++-----
sys/dev/usb/usbdi_util.c | 24 ++----------------------
sys/dev/usb/usbdi_util.h | 9 +--------
7 files changed, 31 insertions(+), 55 deletions(-)
diffs (289 lines):
diff -r bd2a8124c3bb -r f6d2ac3c3a29 sys/dev/usb/ugen.c
--- a/sys/dev/usb/ugen.c Thu Feb 07 12:37:40 2019 +0000
+++ b/sys/dev/usb/ugen.c Thu Feb 07 13:20:41 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ugen.c,v 1.143 2019/01/29 09:28:50 pgoyette Exp $ */
+/* $NetBSD: ugen.c,v 1.144 2019/02/07 13:20:41 skrll Exp $ */
/*
* Copyright (c) 1998, 2004 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ugen.c,v 1.143 2019/01/29 09:28:50 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ugen.c,v 1.144 2019/02/07 13:20:41 skrll Exp $");
#ifdef _KERNEL_OPT
#include "opt_compat_netbsd.h"
@@ -843,7 +843,7 @@
mutex_enter(&sc->sc_lock);
if (--sc->sc_refcnt < 0)
- usb_detach_broadcast(sc->sc_dev, &sc->sc_detach_cv);
+ cv_broadcast(&sc->sc_detach_cv);
mutex_exit(&sc->sc_lock);
return error;
@@ -1033,7 +1033,7 @@
mutex_enter(&sc->sc_lock);
if (--sc->sc_refcnt < 0)
- usb_detach_broadcast(sc->sc_dev, &sc->sc_detach_cv);
+ cv_broadcast(&sc->sc_detach_cv);
mutex_exit(&sc->sc_lock);
return error;
@@ -1080,7 +1080,8 @@
for (i = 0; i < USB_MAX_ENDPOINTS; i++)
cv_signal(&sc->sc_endpoints[i][IN].cv);
/* Wait for processes to go away. */
- usb_detach_wait(sc->sc_dev, &sc->sc_detach_cv, &sc->sc_lock);
+ if (cv_timedwait(&sc->sc_detach_cv, &sc->sc_lock, hz * 60))
+ aprint_error_dev(self, ": didn't detach\n");
}
mutex_exit(&sc->sc_lock);
@@ -1867,7 +1868,7 @@
sc->sc_refcnt++;
error = ugen_do_ioctl(sc, endpt, cmd, addr, flag, l);
if (--sc->sc_refcnt < 0)
- usb_detach_broadcast(sc->sc_dev, &sc->sc_detach_cv);
+ cv_broadcast(&sc->sc_detach_cv);
return error;
}
diff -r bd2a8124c3bb -r f6d2ac3c3a29 sys/dev/usb/uhid.c
--- a/sys/dev/usb/uhid.c Thu Feb 07 12:37:40 2019 +0000
+++ b/sys/dev/usb/uhid.c Thu Feb 07 13:20:41 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uhid.c,v 1.104 2019/01/29 09:28:50 pgoyette Exp $ */
+/* $NetBSD: uhid.c,v 1.105 2019/02/07 13:20:41 skrll Exp $ */
/*
* Copyright (c) 1998, 2004, 2008, 2012 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uhid.c,v 1.104 2019/01/29 09:28:50 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uhid.c,v 1.105 2019/02/07 13:20:41 skrll Exp $");
#ifdef _KERNEL_OPT
#include "opt_compat_netbsd.h"
@@ -230,8 +230,8 @@
/* Wake everyone */
cv_broadcast(&sc->sc_cv);
/* Wait for processes to go away. */
- usb_detach_wait(sc->sc_hdev.sc_dev,
- &sc->sc_detach_cv, &sc->sc_lock);
+ if (cv_timedwait(&sc->sc_detach_cv, &sc->sc_lock, hz * 60))
+ aprint_error_dev(self, ": didn't detach\n");
}
}
mutex_exit(&sc->sc_lock);
@@ -458,7 +458,7 @@
mutex_enter(&sc->sc_lock);
if (--sc->sc_refcnt < 0)
- usb_detach_broadcast(sc->sc_hdev.sc_dev, &sc->sc_detach_cv);
+ cv_broadcast(&sc->sc_detach_cv);
mutex_exit(&sc->sc_lock);
return error;
}
@@ -508,7 +508,7 @@
mutex_enter(&sc->sc_lock);
if (--sc->sc_refcnt < 0)
- usb_detach_broadcast(sc->sc_hdev.sc_dev, &sc->sc_detach_cv);
+ cv_broadcast(&sc->sc_detach_cv);
mutex_exit(&sc->sc_lock);
return error;
}
@@ -702,7 +702,7 @@
mutex_enter(&sc->sc_lock);
if (--sc->sc_refcnt < 0)
- usb_detach_broadcast(sc->sc_hdev.sc_dev, &sc->sc_detach_cv);
+ cv_broadcast(&sc->sc_detach_cv);
mutex_exit(&sc->sc_lock);
return error;
}
diff -r bd2a8124c3bb -r f6d2ac3c3a29 sys/dev/usb/umass.c
--- a/sys/dev/usb/umass.c Thu Feb 07 12:37:40 2019 +0000
+++ b/sys/dev/usb/umass.c Thu Feb 07 13:20:41 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: umass.c,v 1.168 2019/02/03 03:19:28 mrg Exp $ */
+/* $NetBSD: umass.c,v 1.169 2019/02/07 13:20:41 skrll Exp $ */
/*
* Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -124,7 +124,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: umass.c,v 1.168 2019/02/03 03:19:28 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: umass.c,v 1.169 2019/02/07 13:20:41 skrll Exp $");
#ifdef _KERNEL_OPT
#include "opt_usb.h"
@@ -820,7 +820,8 @@
aprint_normal_dev(self, "waiting for refcnt\n");
#endif
/* Wait for processes to go away. */
- usb_detach_wait(sc->sc_dev, &sc->sc_detach_cv, &sc->sc_lock);
+ if (cv_timedwait(&sc->sc_detach_cv, &sc->sc_lock, hz * 60))
+ aprint_error_dev(self, ": didn't detach\n");
}
mutex_exit(&sc->sc_lock);
diff -r bd2a8124c3bb -r f6d2ac3c3a29 sys/dev/usb/umass_scsipi.c
--- a/sys/dev/usb/umass_scsipi.c Thu Feb 07 12:37:40 2019 +0000
+++ b/sys/dev/usb/umass_scsipi.c Thu Feb 07 13:20:41 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: umass_scsipi.c,v 1.57 2019/01/22 06:46:21 skrll Exp $ */
+/* $NetBSD: umass_scsipi.c,v 1.58 2019/02/07 13:20:41 skrll Exp $ */
/*
* Copyright (c) 2001, 2003, 2012 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: umass_scsipi.c,v 1.57 2019/01/22 06:46:21 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: umass_scsipi.c,v 1.58 2019/02/07 13:20:41 skrll Exp $");
#ifdef _KERNEL_OPT
#include "opt_usb.h"
@@ -144,7 +144,7 @@
scsiprint);
mutex_enter(&sc->sc_lock);
if (--sc->sc_refcnt < 0)
- usb_detach_broadcast(sc->sc_dev, &sc->sc_detach_cv);
+ cv_broadcast(&sc->sc_detach_cv);
mutex_exit(&sc->sc_lock);
@@ -177,7 +177,7 @@
atapiprint);
mutex_enter(&sc->sc_lock);
if (--sc->sc_refcnt < 0)
- usb_detach_broadcast(sc->sc_dev, &sc->sc_detach_cv);
+ cv_broadcast(&sc->sc_detach_cv);
mutex_exit(&sc->sc_lock);
return 0;
diff -r bd2a8124c3bb -r f6d2ac3c3a29 sys/dev/usb/umidi.c
--- a/sys/dev/usb/umidi.c Thu Feb 07 12:37:40 2019 +0000
+++ b/sys/dev/usb/umidi.c Thu Feb 07 13:20:41 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: umidi.c,v 1.75 2018/09/03 16:29:34 riastradh Exp $ */
+/* $NetBSD: umidi.c,v 1.76 2019/02/07 13:20:41 skrll Exp $ */
/*
* Copyright (c) 2001, 2012, 2014 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: umidi.c,v 1.75 2018/09/03 16:29:34 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: umidi.c,v 1.76 2019/02/07 13:20:41 skrll Exp $");
#ifdef _KERNEL_OPT
#include "opt_usb.h"
@@ -462,7 +462,8 @@
mutex_enter(&sc->sc_lock);
sc->sc_dying = 1;
if (--sc->sc_refcnt >= 0)
- usb_detach_wait(sc->sc_dev, &sc->sc_detach_cv, &sc->sc_lock);
+ if (cv_timedwait(&sc->sc_detach_cv, &sc->sc_lock, hz * 60))
+ aprint_error_dev(self, ": didn't detach\n");
mutex_exit(&sc->sc_lock);
detach_all_mididevs(sc, flags);
@@ -549,7 +550,7 @@
close_in_jack(mididev->in_jack);
if (--sc->sc_refcnt < 0)
- usb_detach_broadcast(sc->sc_dev, &sc->sc_detach_cv);
+ cv_broadcast(&sc->sc_detach_cv);
mididev->opened = 0;
mididev->closing = 0;
@@ -1786,7 +1787,7 @@
}
if (--sc->sc_refcnt < 0)
- usb_detach_broadcast(sc->sc_dev, &sc->sc_detach_cv);
+ cv_broadcast(&sc->sc_detach_cv);
return 0;
}
diff -r bd2a8124c3bb -r f6d2ac3c3a29 sys/dev/usb/usbdi_util.c
--- a/sys/dev/usb/usbdi_util.c Thu Feb 07 12:37:40 2019 +0000
+++ b/sys/dev/usb/usbdi_util.c Thu Feb 07 13:20:41 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: usbdi_util.c,v 1.72 2018/11/08 02:11:54 manu Exp $ */
+/* $NetBSD: usbdi_util.c,v 1.73 2019/02/07 13:20:41 skrll Exp $ */
/*
* Copyright (c) 1998, 2012 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: usbdi_util.c,v 1.72 2018/11/08 02:11:54 manu Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbdi_util.c,v 1.73 2019/02/07 13:20:41 skrll Exp $");
#ifdef _KERNEL_OPT
#include "opt_usb.h"
@@ -569,26 +569,6 @@
}
void
-usb_detach_wait(device_t dv, kcondvar_t *cv, kmutex_t *lock)
-{
- USBHIST_FUNC(); USBHIST_CALLED(usbdebug);
-
- DPRINTFN(1, "waiting for dv %#jx", (uintptr_t)dv, 0, 0, 0);
- if (cv_timedwait(cv, lock, hz * 60)) // dv, PZERO, "usbdet", hz * 60
- aprint_error_dev(dv, "usb_detach_wait: didn't detach\n");
- DPRINTFN(1, "done", 0, 0, 0, 0);
-}
-
-void
-usb_detach_broadcast(device_t dv, kcondvar_t *cv)
-{
- USBHIST_FUNC(); USBHIST_CALLED(usbdebug);
-
- DPRINTFN(1, "for dv %#jx", (uintptr_t)dv, 0, 0, 0);
- cv_broadcast(cv);
-}
-
-void
usb_detach_waitold(device_t dv)
{
USBHIST_FUNC(); USBHIST_CALLED(usbdebug);
diff -r bd2a8124c3bb -r f6d2ac3c3a29 sys/dev/usb/usbdi_util.h
--- a/sys/dev/usb/usbdi_util.h Thu Feb 07 12:37:40 2019 +0000
+++ b/sys/dev/usb/usbdi_util.h Thu Feb 07 13:20:41 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: usbdi_util.h,v 1.48 2018/11/08 02:11:54 manu Exp $ */
+/* $NetBSD: usbdi_util.h,v 1.49 2019/02/07 13:20:41 skrll Exp $ */
/*
* Copyright (c) 1998, 2004 The NetBSD Foundation, Inc.
@@ -90,13 +90,6 @@
void usb_detach_waitold(device_t);
void usb_detach_wakeupold(device_t);
-/*
- * MPSAFE versions - mutex must be at IPL_USB.
- */
-void usb_detach_wait(device_t dv, kcondvar_t *, kmutex_t *);
-void usb_detach_broadcast(device_t, kcondvar_t *);
-
-
typedef struct {
uByte bLength;
uByte bDescriptorType;
Home |
Main Index |
Thread Index |
Old Index