Module Name: src
Committed By: skrll
Date: Thu Oct 3 07:35:37 UTC 2013
Modified Files:
src/sys/dev/usb: usb_subr.c usbdi.c usbdivar.h
Log Message:
Simply the code now that all (real) HCDs provide a get_lock method.
To generate a diff of this commit:
cvs rdiff -u -r1.194 -r1.195 src/sys/dev/usb/usb_subr.c
cvs rdiff -u -r1.157 -r1.158 src/sys/dev/usb/usbdi.c
cvs rdiff -u -r1.105 -r1.106 src/sys/dev/usb/usbdivar.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/usb_subr.c
diff -u src/sys/dev/usb/usb_subr.c:1.194 src/sys/dev/usb/usb_subr.c:1.195
--- src/sys/dev/usb/usb_subr.c:1.194 Thu Sep 26 07:25:31 2013
+++ src/sys/dev/usb/usb_subr.c Thu Oct 3 07:35:37 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: usb_subr.c,v 1.194 2013/09/26 07:25:31 skrll Exp $ */
+/* $NetBSD: usb_subr.c,v 1.195 2013/10/03 07:35:37 skrll Exp $ */
/* $FreeBSD: src/sys/dev/usb/usb_subr.c,v 1.18 1999/11/17 22:33:47 n_hibma Exp $ */
/*
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: usb_subr.c,v 1.194 2013/09/26 07:25:31 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usb_subr.c,v 1.195 2013/10/03 07:35:37 skrll Exp $");
#ifdef _KERNEL_OPT
#include "opt_compat_netbsd.h"
@@ -780,8 +780,6 @@ usbd_setup_pipe_flags(usbd_device_handle
void
usbd_kill_pipe(usbd_pipe_handle pipe)
{
- int s;
-
usbd_abort_pipe(pipe);
usbd_lock_pipe(pipe);
pipe->methods->close(pipe);
Index: src/sys/dev/usb/usbdi.c
diff -u src/sys/dev/usb/usbdi.c:1.157 src/sys/dev/usb/usbdi.c:1.158
--- src/sys/dev/usb/usbdi.c:1.157 Thu Sep 26 10:31:02 2013
+++ src/sys/dev/usb/usbdi.c Thu Oct 3 07:35:37 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: usbdi.c,v 1.157 2013/09/26 10:31:02 skrll Exp $ */
+/* $NetBSD: usbdi.c,v 1.158 2013/10/03 07:35:37 skrll Exp $ */
/*
* Copyright (c) 1998, 2012 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.157 2013/09/26 10:31:02 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.158 2013/10/03 07:35:37 skrll Exp $");
#ifdef _KERNEL_OPT
#include "opt_compat_netbsd.h"
@@ -228,7 +228,6 @@ usbd_open_pipe_intr(usbd_interface_handl
usbd_status
usbd_close_pipe(usbd_pipe_handle pipe)
{
- int s;
#ifdef DIAGNOSTIC
if (pipe == NULL) {
@@ -263,7 +262,6 @@ usbd_transfer(usbd_xfer_handle xfer)
usb_dma_t *dmap = &xfer->dmabuf;
usbd_status err;
unsigned int size, flags;
- int s;
DPRINTFN(5,("usbd_transfer: xfer=%p, flags=%#x, pipe=%p, running=%d\n",
xfer, xfer->flags, pipe, pipe->running));
@@ -324,15 +322,9 @@ usbd_transfer(usbd_xfer_handle xfer)
err = 0;
if ((flags & USBD_SYNCHRONOUS_SIG) != 0) {
- if (pipe->device->bus->lock)
- err = cv_wait_sig(&xfer->cv, pipe->device->bus->lock);
- else
- err = tsleep(xfer, PZERO|PCATCH, "usbsyn", 0);
+ err = cv_wait_sig(&xfer->cv, pipe->device->bus->lock);
} else {
- if (pipe->device->bus->lock)
- cv_wait(&xfer->cv, pipe->device->bus->lock);
- else
- err = tsleep(xfer, PRIBIO, "usbsyn", 0);
+ cv_wait(&xfer->cv, pipe->device->bus->lock);
}
if (err) {
if (!xfer->done)
@@ -557,7 +549,6 @@ usbd_status
usbd_abort_pipe(usbd_pipe_handle pipe)
{
usbd_status err;
- int s;
usbd_xfer_handle intrxfer = pipe->intrxfer;
#ifdef DIAGNOSTIC
@@ -762,7 +753,7 @@ usbd_ar_pipe(usbd_pipe_handle pipe)
{
usbd_xfer_handle xfer;
- KASSERT(pipe->device->bus->lock == NULL || mutex_owned(pipe->device->bus->lock));
+ KASSERT(mutex_owned(pipe->device->bus->lock));
DPRINTFN(2,("usbd_ar_pipe: pipe=%p\n", pipe));
#ifdef USB_DEBUG
@@ -797,8 +788,7 @@ usb_transfer_complete(usbd_xfer_handle x
DPRINTFN(5, ("usb_transfer_complete: pipe=%p xfer=%p status=%d "
"actlen=%d\n", pipe, xfer, xfer->status, xfer->actlen));
- KASSERT(polling || pipe->device->bus->lock == NULL ||
- mutex_owned(pipe->device->bus->lock));
+ KASSERT(polling || mutex_owned(pipe->device->bus->lock));
#ifdef DIAGNOSTIC
if (xfer->busy_free != XFER_ONQU) {
@@ -870,7 +860,7 @@ usb_transfer_complete(usbd_xfer_handle x
if (repeat) {
if (xfer->callback) {
- if (pipe->device->bus->lock && !polling)
+ if (!polling)
mutex_exit(pipe->device->bus->lock);
if (!(pipe->flags & USBD_MPSAFE))
@@ -879,14 +869,14 @@ usb_transfer_complete(usbd_xfer_handle x
if (!(pipe->flags & USBD_MPSAFE))
KERNEL_UNLOCK_ONE(curlwp);
- if (pipe->device->bus->lock && !polling)
+ if (!polling)
mutex_enter(pipe->device->bus->lock);
}
pipe->methods->done(xfer);
} else {
pipe->methods->done(xfer);
if (xfer->callback) {
- if (pipe->device->bus->lock && !polling)
+ if (!polling)
mutex_exit(pipe->device->bus->lock);
if (!(pipe->flags & USBD_MPSAFE))
@@ -895,16 +885,13 @@ usb_transfer_complete(usbd_xfer_handle x
if (!(pipe->flags & USBD_MPSAFE))
KERNEL_UNLOCK_ONE(curlwp);
- if (pipe->device->bus->lock && !polling)
+ if (!polling)
mutex_enter(pipe->device->bus->lock);
}
}
if (sync && !polling) {
- if (pipe->device->bus->lock)
- cv_broadcast(&xfer->cv);
- else
- wakeup(xfer); /* XXXSMP ok */
+ cv_broadcast(&xfer->cv);
}
if (!repeat) {
@@ -926,7 +913,7 @@ usb_insert_transfer(usbd_xfer_handle xfe
DPRINTFN(5,("usb_insert_transfer: pipe=%p running=%d timeout=%d\n",
pipe, pipe->running, xfer->timeout));
- KASSERT(pipe->device->bus->lock == NULL || mutex_owned(pipe->device->bus->lock));
+ KASSERT(mutex_owned(pipe->device->bus->lock));
#ifdef DIAGNOSTIC
if (xfer->busy_free != XFER_BUSY) {
@@ -964,7 +951,7 @@ usbd_start_next(usbd_pipe_handle pipe)
}
#endif
- KASSERT(pipe->device->bus->lock == NULL || mutex_owned(pipe->device->bus->lock));
+ KASSERT(mutex_owned(pipe->device->bus->lock));
/* Get next request in queue. */
xfer = SIMPLEQ_FIRST(&pipe->queue);
@@ -972,11 +959,10 @@ usbd_start_next(usbd_pipe_handle pipe)
if (xfer == NULL) {
pipe->running = 0;
} else {
- if (pipe->device->bus->lock)
- mutex_exit(pipe->device->bus->lock);
+ mutex_exit(pipe->device->bus->lock);
err = pipe->methods->start(xfer);
- if (pipe->device->bus->lock)
- mutex_enter(pipe->device->bus->lock);
+ mutex_enter(pipe->device->bus->lock);
+
if (err != USBD_IN_PROGRESS) {
printf("usbd_start_next: error=%d\n", err);
pipe->running = 0;
@@ -984,7 +970,7 @@ usbd_start_next(usbd_pipe_handle pipe)
}
}
- KASSERT(pipe->device->bus->lock == NULL || mutex_owned(pipe->device->bus->lock));
+ KASSERT(mutex_owned(pipe->device->bus->lock));
}
usbd_status
@@ -1118,12 +1104,9 @@ usbd_set_polling(usbd_device_handle dev,
dev->bus->use_polling--;
/* Kick the host controller when switching modes */
- if (dev->bus->lock)
- mutex_enter(dev->bus->lock);
+ mutex_enter(dev->bus->lock);
(*dev->bus->methods->soft_intr)(dev->bus);
- if (dev->bus->lock)
- mutex_exit(dev->bus->lock);
-
+ mutex_exit(dev->bus->lock);
}
Index: src/sys/dev/usb/usbdivar.h
diff -u src/sys/dev/usb/usbdivar.h:1.105 src/sys/dev/usb/usbdivar.h:1.106
--- src/sys/dev/usb/usbdivar.h:1.105 Sat Sep 14 00:40:31 2013
+++ src/sys/dev/usb/usbdivar.h Thu Oct 3 07:35:37 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: usbdivar.h,v 1.105 2013/09/14 00:40:31 jakllsch Exp $ */
+/* $NetBSD: usbdivar.h,v 1.106 2013/10/03 07:35:37 skrll Exp $ */
/*
* Copyright (c) 1998, 2012 The NetBSD Foundation, Inc.
@@ -327,21 +327,6 @@ void usb_schedsoftintr(struct usbd_bus
/*
* These macros help while not all host controllers are ported to the MP code.
*/
-#define usbd_mutex_enter(m) do { \
- if (m) { \
- s = -1; \
- mutex_enter(m); \
- } else \
- s = splusb(); \
-} while (0)
-
-#define usbd_mutex_exit(m) do { \
- if (m) { \
- s = -1; \
- mutex_exit(m); \
- } else \
- splx(s); \
-} while (0)
-#define usbd_lock_pipe(p) usbd_mutex_enter((p)->device->bus->lock)
-#define usbd_unlock_pipe(p) usbd_mutex_exit((p)->device->bus->lock)
+#define usbd_lock_pipe(p) mutex_enter((p)->device->bus->lock)
+#define usbd_unlock_pipe(p) mutex_exit((p)->device->bus->lock)