summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2014-05-16 19:00:19 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2014-05-16 19:00:19 +0000
commit38bcaa05801bcf5d032143fa6f201e1c8b46ba81 (patch)
tree95a349f0b4e0002307ae064282bf44f8ac9ba5f9 /sys/dev
parente3998046fbd731735fe071bac45c3eae2d9af95b (diff)
Reduce the difference between HC drivers by always passing a generic
usbd_xfer pointer to the routines processing finished transfers to make it crystal clear that the timeout and abort logic is the same everywhere.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/usb/ehci.c49
-rw-r--r--sys/dev/usb/uhci.c55
2 files changed, 53 insertions, 51 deletions
diff --git a/sys/dev/usb/ehci.c b/sys/dev/usb/ehci.c
index 423c408144c..a9488695d1b 100644
--- a/sys/dev/usb/ehci.c
+++ b/sys/dev/usb/ehci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ehci.c,v 1.154 2014/05/16 18:17:03 mpi Exp $ */
+/* $OpenBSD: ehci.c,v 1.155 2014/05/16 19:00:18 mpi Exp $ */
/* $NetBSD: ehci.c,v 1.66 2004/06/30 03:11:56 mycroft Exp $ */
/*
@@ -118,10 +118,10 @@ void ehci_poll(struct usbd_bus *);
void ehci_softintr(void *);
int ehci_intr1(struct ehci_softc *);
void ehci_waitintr(struct ehci_softc *, struct usbd_xfer *);
-void ehci_check_intr(struct ehci_softc *, struct ehci_xfer *);
-void ehci_check_qh_intr(struct ehci_softc *, struct ehci_xfer *);
-void ehci_check_itd_intr(struct ehci_softc *, struct ehci_xfer *);
-void ehci_idone(struct ehci_xfer *);
+void ehci_check_intr(struct ehci_softc *, struct usbd_xfer *);
+void ehci_check_qh_intr(struct ehci_softc *, struct usbd_xfer *);
+void ehci_check_itd_intr(struct ehci_softc *, struct usbd_xfer *);
+void ehci_idone(struct usbd_xfer *);
void ehci_timeout(void *);
void ehci_timeout_task(void *);
void ehci_intrlist_timeout(void *);
@@ -645,7 +645,7 @@ ehci_softintr(void *v)
*/
for (ex = TAILQ_FIRST(&sc->sc_intrhead); ex; ex = nextex) {
nextex = TAILQ_NEXT(ex, inext);
- ehci_check_intr(sc, ex);
+ ehci_check_intr(sc, &ex->xfer);
}
/* Schedule a callout to catch any dropped transactions. */
@@ -664,26 +664,27 @@ ehci_softintr(void *v)
/* Check for an interrupt. */
void
-ehci_check_intr(struct ehci_softc *sc, struct ehci_xfer *ex)
+ehci_check_intr(struct ehci_softc *sc, struct usbd_xfer *xfer)
{
int attr;
- DPRINTFN(/*15*/2, ("ehci_check_intr: ex=%p\n", ex));
+ DPRINTFN(2, ("%s: xfer=%p\n", __func__, xfer));
- attr = ex->xfer.pipe->endpoint->edesc->bmAttributes;
+ attr = xfer->pipe->endpoint->edesc->bmAttributes;
if (UE_GET_XFERTYPE(attr) == UE_ISOCHRONOUS)
- ehci_check_itd_intr(sc, ex);
+ ehci_check_itd_intr(sc, xfer);
else
- ehci_check_qh_intr(sc, ex);
+ ehci_check_qh_intr(sc, xfer);
return;
}
void
-ehci_check_qh_intr(struct ehci_softc *sc, struct ehci_xfer *ex)
+ehci_check_qh_intr(struct ehci_softc *sc, struct usbd_xfer *xfer)
{
+ struct ehci_xfer *ex = (struct ehci_xfer *)xfer;
struct ehci_soft_qtd *sqtd, *lsqtd;
- __uint32_t status;
+ uint32_t status;
if (ex->sqtdstart == NULL) {
printf("ehci_check_qh_intr: not valid sqtd\n");
@@ -736,17 +737,19 @@ ehci_check_qh_intr(struct ehci_softc *sc, struct ehci_xfer *ex)
}
done:
DPRINTFN(12, ("ehci_check_intr: ex=%p done\n", ex));
- timeout_del(&ex->xfer.timeout_handle);
- usb_rem_task(ex->xfer.pipe->device, &ex->xfer.abort_task);
- ehci_idone(ex);
+ timeout_del(&xfer->timeout_handle);
+ usb_rem_task(xfer->pipe->device, &xfer->abort_task);
+ ehci_idone(xfer);
}
void
-ehci_check_itd_intr(struct ehci_softc *sc, struct ehci_xfer *ex) {
+ehci_check_itd_intr(struct ehci_softc *sc, struct usbd_xfer *xfer)
+{
+ struct ehci_xfer *ex = (struct ehci_xfer *)xfer;
struct ehci_soft_itd *itd;
int i;
- if (&ex->xfer != SIMPLEQ_FIRST(&ex->xfer.pipe->queue))
+ if (xfer != SIMPLEQ_FIRST(&xfer->pipe->queue))
return;
if (ex->itdstart == NULL) {
@@ -784,15 +787,15 @@ ehci_check_itd_intr(struct ehci_softc *sc, struct ehci_xfer *ex) {
return;
done:
DPRINTFN(12, ("ehci_check_itd_intr: ex=%p done\n", ex));
- timeout_del(&ex->xfer.timeout_handle);
- usb_rem_task(ex->xfer.pipe->device, &ex->xfer.abort_task);
- ehci_idone(ex);
+ timeout_del(&xfer->timeout_handle);
+ usb_rem_task(xfer->pipe->device, &xfer->abort_task);
+ ehci_idone(xfer);
}
void
-ehci_idone(struct ehci_xfer *ex)
+ehci_idone(struct usbd_xfer *xfer)
{
- struct usbd_xfer *xfer = &ex->xfer;
+ struct ehci_xfer *ex = (struct ehci_xfer *)xfer;
#ifdef EHCI_DEBUG
struct ehci_pipe *epipe = (struct ehci_pipe *)xfer->pipe;
#endif
diff --git a/sys/dev/usb/uhci.c b/sys/dev/usb/uhci.c
index d119400592c..e3bd38aadea 100644
--- a/sys/dev/usb/uhci.c
+++ b/sys/dev/usb/uhci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uhci.c,v 1.117 2014/05/16 18:17:03 mpi Exp $ */
+/* $OpenBSD: uhci.c,v 1.118 2014/05/16 19:00:18 mpi Exp $ */
/* $NetBSD: uhci.c,v 1.172 2003/02/23 04:19:26 simonb Exp $ */
/* $FreeBSD: src/sys/dev/usb/uhci.c,v 1.33 1999/11/17 22:33:41 n_hibma Exp $ */
@@ -125,8 +125,8 @@ usbd_status uhci_alloc_std_chain(struct uhci_softc *, u_int,
struct uhci_soft_td **);
void uhci_poll_hub(void *);
void uhci_waitintr(struct uhci_softc *, struct usbd_xfer *);
-void uhci_check_intr(struct uhci_softc *, struct uhci_xfer *);
-void uhci_idone(struct uhci_xfer *);
+void uhci_check_intr(struct uhci_softc *, struct usbd_xfer *);
+void uhci_idone(struct usbd_xfer *);
void uhci_abort_xfer(struct usbd_xfer *, usbd_status status);
@@ -1117,7 +1117,7 @@ void
uhci_softintr(void *v)
{
struct uhci_softc *sc = v;
- struct uhci_xfer *ex, *nextex;
+ struct uhci_xfer *ux, *nextex;
DPRINTFN(10,("%s: uhci_softintr (%d)\n", sc->sc_bus.bdev.dv_xname,
sc->sc_bus.intr_context));
@@ -1138,9 +1138,9 @@ uhci_softintr(void *v)
* We scan all interrupt descriptors to see if any have
* completed.
*/
- for (ex = LIST_FIRST(&sc->sc_intrhead); ex; ex = nextex) {
- nextex = LIST_NEXT(ex, inext);
- uhci_check_intr(sc, ex);
+ for (ux = LIST_FIRST(&sc->sc_intrhead); ux; ux = nextex) {
+ nextex = LIST_NEXT(ux, inext);
+ uhci_check_intr(sc, &ux->xfer);
}
if (sc->sc_softwake) {
@@ -1151,32 +1151,31 @@ uhci_softintr(void *v)
sc->sc_bus.intr_context--;
}
-/* Check for an interrupt. */
void
-uhci_check_intr(struct uhci_softc *sc, struct uhci_xfer *ex)
+uhci_check_intr(struct uhci_softc *sc, struct usbd_xfer *xfer)
{
+ struct uhci_xfer *ux = (struct uhci_xfer *)xfer;
struct uhci_soft_td *std, *lstd;
u_int32_t status;
- DPRINTFN(15, ("uhci_check_intr: ex=%p\n", ex));
+ DPRINTFN(15, ("%s: ux=%p\n", __func__, ux));
#ifdef DIAGNOSTIC
- if (ex == NULL) {
- printf("uhci_check_intr: no ex? %p\n", ex);
+ if (ux == NULL) {
+ printf("%s: no ux? %p\n", __func__, ux);
return;
}
#endif
- if (ex->xfer.status == USBD_CANCELLED ||
- ex->xfer.status == USBD_TIMEOUT) {
- DPRINTF(("uhci_check_intr: aborted xfer=%p\n", ex->xfer));
+ if (xfer->status == USBD_CANCELLED || xfer->status == USBD_TIMEOUT) {
+ DPRINTF(("%s: aborted xfer=%p\n", __func__, xfer));
return;
}
- if (ex->stdstart == NULL)
+ if (ux->stdstart == NULL)
return;
- lstd = ex->stdend;
+ lstd = ux->stdend;
#ifdef DIAGNOSTIC
if (lstd == NULL) {
- printf("uhci_check_intr: std==0\n");
+ printf("%s: std==0\n", __func__);
return;
}
#endif
@@ -1186,8 +1185,8 @@ uhci_check_intr(struct uhci_softc *sc, struct uhci_xfer *ex)
* short packet (SPD and not ACTIVE).
*/
if (letoh32(lstd->td.td_status) & UHCI_TD_ACTIVE) {
- DPRINTFN(12, ("uhci_check_intr: active ex=%p\n", ex));
- for (std = ex->stdstart; std != lstd; std = std->link.std) {
+ DPRINTFN(12, ("%s: active ux=%p\n", __func__, ux));
+ for (std = ux->stdstart; std != lstd; std = std->link.std) {
status = letoh32(std->td.td_status);
/* If there's an active TD the xfer isn't done. */
if (status & UHCI_TD_ACTIVE)
@@ -1201,22 +1200,22 @@ uhci_check_intr(struct uhci_softc *sc, struct uhci_xfer *ex)
UHCI_TD_GET_MAXLEN(letoh32(std->td.td_token)))
goto done;
}
- DPRINTFN(12, ("uhci_check_intr: ex=%p std=%p still active\n",
- ex, ex->stdstart));
+ DPRINTFN(12, ("%s: ux=%p std=%p still active\n", __func__,
+ ux, ux->stdstart));
return;
}
done:
- DPRINTFN(12, ("uhci_check_intr: ex=%p done\n", ex));
- timeout_del(&ex->xfer.timeout_handle);
- usb_rem_task(ex->xfer.pipe->device, &ex->xfer.abort_task);
- uhci_idone(ex);
+ DPRINTFN(12, ("uhci_check_intr: ux=%p done\n", ux));
+ timeout_del(&xfer->timeout_handle);
+ usb_rem_task(xfer->pipe->device, &xfer->abort_task);
+ uhci_idone(xfer);
}
/* Called at splusb() */
void
-uhci_idone(struct uhci_xfer *ux)
+uhci_idone(struct usbd_xfer *xfer)
{
- struct usbd_xfer *xfer = &ux->xfer;
+ struct uhci_xfer *ux = (struct uhci_xfer *)xfer;
struct uhci_pipe *upipe = (struct uhci_pipe *)xfer->pipe;
struct uhci_soft_td *std;
u_int32_t status = 0, nstatus;