summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormpi <mpi@openbsd.org>2014-03-07 09:51:50 +0000
committermpi <mpi@openbsd.org>2014-03-07 09:51:50 +0000
commitd31fade789862fbecf2a5cf5062127144670b20e (patch)
tree9731b207f6b2e92c464ab76f39b3161faf009308
parentrename $_ for better style... lots more to be done (diff)
downloadwireguard-openbsd-d31fade789862fbecf2a5cf5062127144670b20e.tar.xz
wireguard-openbsd-d31fade789862fbecf2a5cf5062127144670b20e.zip
Transfer descriptors already have a back pointer to the USB device
descriptor they are linked to, so no need to dereference their pipe pointer. Simplify a lot of affectations, no functional change. ok pirofti@
-rw-r--r--sys/dev/usb/ehci.c27
-rw-r--r--sys/dev/usb/ohci.c37
-rw-r--r--sys/dev/usb/uhci.c26
3 files changed, 40 insertions, 50 deletions
diff --git a/sys/dev/usb/ehci.c b/sys/dev/usb/ehci.c
index 952d860a37f..5644fc9a240 100644
--- a/sys/dev/usb/ehci.c
+++ b/sys/dev/usb/ehci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ehci.c,v 1.142 2014/03/07 09:38:14 mpi Exp $ */
+/* $OpenBSD: ehci.c,v 1.143 2014/03/07 09:51:50 mpi Exp $ */
/* $NetBSD: ehci.c,v 1.66 2004/06/30 03:11:56 mycroft Exp $ */
/*
@@ -928,7 +928,7 @@ ehci_idone(struct ehci_xfer *ex)
DPRINTFN(2,
("ehci_idone: error, addr=%d, endpt=0x%02x, "
"status 0x%s\n",
- xfer->pipe->device->address,
+ xfer->device->address,
xfer->pipe->endpoint->edesc->bEndpointAddress,
sbuf));
if (ehcidebug > 2) {
@@ -1893,7 +1893,7 @@ ehci_root_ctrl_transfer(struct usbd_xfer *xfer)
usbd_status
ehci_root_ctrl_start(struct usbd_xfer *xfer)
{
- struct ehci_softc *sc = (struct ehci_softc *)xfer->pipe->device->bus;
+ struct ehci_softc *sc = (struct ehci_softc *)xfer->device->bus;
usb_device_request_t *req;
void *buf = NULL;
int port, i;
@@ -2990,7 +2990,7 @@ ehci_device_ctrl_transfer(struct usbd_xfer *xfer)
usbd_status
ehci_device_ctrl_start(struct usbd_xfer *xfer)
{
- struct ehci_softc *sc = (struct ehci_softc *)xfer->pipe->device->bus;
+ struct ehci_softc *sc = (struct ehci_softc *)xfer->device->bus;
usbd_status err;
if (sc->sc_bus.dying)
@@ -3018,7 +3018,7 @@ void
ehci_device_ctrl_done(struct usbd_xfer *xfer)
{
struct ehci_xfer *ex = EXFER(xfer);
- struct ehci_softc *sc = (struct ehci_softc *)xfer->pipe->device->bus;
+ struct ehci_softc *sc = (struct ehci_softc *)xfer->device->bus;
/*struct ehci_pipe *epipe = (struct ehci_pipe *)xfer->pipe;*/
DPRINTFN(10,("ehci_ctrl_done: xfer=%p\n", xfer));
@@ -3326,7 +3326,7 @@ void
ehci_device_bulk_done(struct usbd_xfer *xfer)
{
struct ehci_xfer *ex = EXFER(xfer);
- struct ehci_softc *sc = (struct ehci_softc *)xfer->pipe->device->bus;
+ struct ehci_softc *sc = (struct ehci_softc *)xfer->device->bus;
struct ehci_pipe *epipe = (struct ehci_pipe *)xfer->pipe;
int endpt = epipe->pipe.endpoint->edesc->bEndpointAddress;
int rd = UE_GET_DIR(endpt) == UE_DIR_IN;
@@ -3390,7 +3390,7 @@ ehci_device_intr_start(struct usbd_xfer *xfer)
{
#define exfer EXFER(xfer)
struct ehci_pipe *epipe = (struct ehci_pipe *)xfer->pipe;
- struct usbd_device *dev = xfer->pipe->device;
+ struct usbd_device *dev = xfer->device;
struct ehci_softc *sc = (struct ehci_softc *)dev->bus;
struct ehci_soft_qtd *data, *dataend;
struct ehci_soft_qh *sqh;
@@ -3501,7 +3501,7 @@ ehci_device_intr_done(struct usbd_xfer *xfer)
{
#define exfer EXFER(xfer)
struct ehci_xfer *ex = EXFER(xfer);
- struct ehci_softc *sc = (struct ehci_softc *)xfer->pipe->device->bus;
+ struct ehci_softc *sc = (struct ehci_softc *)xfer->device->bus;
struct ehci_pipe *epipe = (struct ehci_pipe *)xfer->pipe;
struct ehci_soft_qtd *data, *dataend;
struct ehci_soft_qh *sqh;
@@ -3594,7 +3594,7 @@ ehci_device_isoc_start(struct usbd_xfer *xfer)
itd = NULL;
trans_count = 0;
exfer = (struct ehci_xfer *) xfer;
- sc = (struct ehci_softc *)xfer->pipe->device->bus;
+ sc = (struct ehci_softc *)xfer->device->bus;
epipe = (struct ehci_pipe *)xfer->pipe;
/*
@@ -3856,14 +3856,11 @@ ehci_device_isoc_close(struct usbd_pipe *pipe)
void
ehci_device_isoc_done(struct usbd_xfer *xfer)
{
- struct ehci_xfer *exfer;
- struct ehci_softc *sc;
- struct ehci_pipe *epipe;
+ struct ehci_xfer *exfer = EXFER(xfer);
+ struct ehci_softc *sc = (struct ehci_softc *)xfer->device->bus;
+ struct ehci_pipe *epipe = (struct ehci_pipe *)xfer->pipe;
int s;
- exfer = EXFER(xfer);
- sc = (struct ehci_softc *)xfer->pipe->device->bus;
- epipe = (struct ehci_pipe *) xfer->pipe;
s = splusb();
epipe->u.isoc.cur_xfers--;
diff --git a/sys/dev/usb/ohci.c b/sys/dev/usb/ohci.c
index f67500996a6..5acd6b7497f 100644
--- a/sys/dev/usb/ohci.c
+++ b/sys/dev/usb/ohci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ohci.c,v 1.120 2014/03/07 09:38:14 mpi Exp $ */
+/* $OpenBSD: ohci.c,v 1.121 2014/03/07 09:51:50 mpi Exp $ */
/* $NetBSD: ohci.c,v 1.139 2003/02/22 05:24:16 tsutsui Exp $ */
/* $FreeBSD: src/sys/dev/usb/ohci.c,v 1.22 1999/11/17 22:33:40 n_hibma Exp $ */
@@ -1304,7 +1304,7 @@ ohci_softintr(void *v)
continue;
}
timeout_del(&xfer->timeout_handle);
- usb_rem_task(xfer->pipe->device, &xfer->abort_task);
+ usb_rem_task(xfer->device, &xfer->abort_task);
len = std->len;
if (std->td.td_cbp != 0)
@@ -1458,7 +1458,7 @@ void
ohci_device_intr_done(struct usbd_xfer *xfer)
{
struct ohci_pipe *opipe = (struct ohci_pipe *)xfer->pipe;
- struct ohci_softc *sc = (struct ohci_softc *)opipe->pipe.device->bus;
+ struct ohci_softc *sc = (struct ohci_softc *)xfer->device->bus;
struct ohci_soft_ed *sed = opipe->sed;
struct ohci_soft_td *data, *tail;
@@ -1603,7 +1603,7 @@ ohci_device_request(struct usbd_xfer *xfer)
{
struct ohci_pipe *opipe = (struct ohci_pipe *)xfer->pipe;
usb_device_request_t *req = &xfer->request;
- struct usbd_device *dev = opipe->pipe.device;
+ struct usbd_device *dev = xfer->device;
struct ohci_softc *sc = (struct ohci_softc *)dev->bus;
struct ohci_soft_td *setup, *stat, *next, *tail;
struct ohci_soft_ed *sed;
@@ -2117,7 +2117,7 @@ void
ohci_abort_xfer(struct usbd_xfer *xfer, usbd_status status)
{
struct ohci_pipe *opipe = (struct ohci_pipe *)xfer->pipe;
- struct ohci_softc *sc = (struct ohci_softc *)opipe->pipe.device->bus;
+ struct ohci_softc *sc = (struct ohci_softc *)xfer->device->bus;
struct ohci_soft_ed *sed = opipe->sed;
struct ohci_soft_td *p, *n;
ohci_physaddr_t headp;
@@ -2131,7 +2131,7 @@ ohci_abort_xfer(struct usbd_xfer *xfer, usbd_status status)
s = splusb();
xfer->status = status; /* make software ignore it */
timeout_del(&xfer->timeout_handle);
- usb_rem_task(xfer->pipe->device, &xfer->abort_task);
+ usb_rem_task(xfer->device, &xfer->abort_task);
usb_transfer_complete(xfer);
splx(s);
return;
@@ -2146,7 +2146,7 @@ ohci_abort_xfer(struct usbd_xfer *xfer, usbd_status status)
s = splusb();
xfer->status = status; /* make software ignore it */
timeout_del(&xfer->timeout_handle);
- usb_rem_task(xfer->pipe->device, &xfer->abort_task);
+ usb_rem_task(xfer->device, &xfer->abort_task);
splx(s);
DPRINTFN(1,("ohci_abort_xfer: stop ed=%p\n", sed));
sed->ed.ed_flags |= htole32(OHCI_ED_SKIP); /* force hardware skip */
@@ -2156,7 +2156,7 @@ ohci_abort_xfer(struct usbd_xfer *xfer, usbd_status status)
* use of the xfer. Also make sure the soft interrupt routine
* has run.
*/
- usb_delay_ms(opipe->pipe.device->bus, 20); /* Hardware finishes in 1ms */
+ usb_delay_ms(xfer->device->bus, 20); /* Hardware finishes in 1ms */
s = splusb();
sc->sc_softwake = 1;
usb_schedsoftintr(&sc->sc_bus);
@@ -2297,7 +2297,7 @@ ohci_root_ctrl_transfer(struct usbd_xfer *xfer)
usbd_status
ohci_root_ctrl_start(struct usbd_xfer *xfer)
{
- struct ohci_softc *sc = (struct ohci_softc *)xfer->pipe->device->bus;
+ struct ohci_softc *sc = (struct ohci_softc *)xfer->device->bus;
usb_device_request_t *req;
void *buf = NULL;
int port, i;
@@ -2696,7 +2696,7 @@ ohci_device_ctrl_transfer(struct usbd_xfer *xfer)
usbd_status
ohci_device_ctrl_start(struct usbd_xfer *xfer)
{
- struct ohci_softc *sc = (struct ohci_softc *)xfer->pipe->device->bus;
+ struct ohci_softc *sc = (struct ohci_softc *)xfer->device->bus;
usbd_status err;
if (sc->sc_bus.dying)
@@ -2772,10 +2772,8 @@ ohci_device_bulk_transfer(struct usbd_xfer *xfer)
usbd_status
ohci_device_bulk_start(struct usbd_xfer *xfer)
{
+ struct ohci_softc *sc = (struct ohci_softc *)xfer->device->bus;
struct ohci_pipe *opipe = (struct ohci_pipe *)xfer->pipe;
- struct usbd_device *dev = opipe->pipe.device;
- struct ohci_softc *sc = (struct ohci_softc *)dev->bus;
- int addr = dev->address;
struct ohci_soft_td *data, *tail, *tdp;
struct ohci_soft_ed *sed;
u_int len;
@@ -2808,7 +2806,7 @@ ohci_device_bulk_start(struct usbd_xfer *xfer)
/* Update device address */
sed->ed.ed_flags = htole32(
(letoh32(sed->ed.ed_flags) & ~OHCI_ED_ADDRMASK) |
- OHCI_ED_SET_FA(addr));
+ OHCI_ED_SET_FA(xfer->device->address));
/* Allocate a chain of new TDs (including a new tail). */
data = opipe->tail.td;
@@ -2913,9 +2911,8 @@ ohci_device_intr_transfer(struct usbd_xfer *xfer)
usbd_status
ohci_device_intr_start(struct usbd_xfer *xfer)
{
+ struct ohci_softc *sc = (struct ohci_softc *)xfer->device->bus;
struct ohci_pipe *opipe = (struct ohci_pipe *)xfer->pipe;
- struct usbd_device *dev = opipe->pipe.device;
- struct ohci_softc *sc = (struct ohci_softc *)dev->bus;
struct ohci_soft_ed *sed = opipe->sed;
struct ohci_soft_td *data, *tail;
int s, len, isread, endpt;
@@ -3134,9 +3131,8 @@ ohci_device_isoc_transfer(struct usbd_xfer *xfer)
void
ohci_device_isoc_enter(struct usbd_xfer *xfer)
{
+ struct ohci_softc *sc = (struct ohci_softc *)xfer->device->bus;
struct ohci_pipe *opipe = (struct ohci_pipe *)xfer->pipe;
- struct usbd_device *dev = opipe->pipe.device;
- struct ohci_softc *sc = (struct ohci_softc *)dev->bus;
struct ohci_soft_ed *sed = opipe->sed;
struct iso *iso = &opipe->u.iso;
struct ohci_soft_itd *sitd, *nsitd;
@@ -3255,8 +3251,7 @@ ohci_device_isoc_enter(struct usbd_xfer *xfer)
usbd_status
ohci_device_isoc_start(struct usbd_xfer *xfer)
{
- struct ohci_pipe *opipe = (struct ohci_pipe *)xfer->pipe;
- struct ohci_softc *sc = (struct ohci_softc *)opipe->pipe.device->bus;
+ struct ohci_softc *sc = (struct ohci_softc *)xfer->device->bus;
DPRINTFN(5,("ohci_device_isoc_start: xfer=%p\n", xfer));
@@ -3281,8 +3276,8 @@ ohci_device_isoc_start(struct usbd_xfer *xfer)
void
ohci_device_isoc_abort(struct usbd_xfer *xfer)
{
+ struct ohci_softc *sc = (struct ohci_softc *)xfer->device->bus;
struct ohci_pipe *opipe = (struct ohci_pipe *)xfer->pipe;
- struct ohci_softc *sc = (struct ohci_softc *)opipe->pipe.device->bus;
struct ohci_soft_ed *sed;
struct ohci_soft_itd *sitd;
int s;
diff --git a/sys/dev/usb/uhci.c b/sys/dev/usb/uhci.c
index 7752db7660a..de47662adea 100644
--- a/sys/dev/usb/uhci.c
+++ b/sys/dev/usb/uhci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uhci.c,v 1.106 2014/03/07 09:38:14 mpi Exp $ */
+/* $OpenBSD: uhci.c,v 1.107 2014/03/07 09:51:50 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 $ */
@@ -852,8 +852,7 @@ void
uhci_poll_hub(void *addr)
{
struct usbd_xfer *xfer = addr;
- struct usbd_pipe *pipe = xfer->pipe;
- struct uhci_softc *sc = (struct uhci_softc *)pipe->device->bus;
+ struct uhci_softc *sc = (struct uhci_softc *)xfer->device->bus;
int s;
u_char *p;
@@ -1352,7 +1351,7 @@ uhci_idone(struct uhci_xfer *ex)
DPRINTFN((status == UHCI_TD_STALLED)*10,
("uhci_idone: error, addr=%d, endpt=0x%02x, "
"status 0x%s\n",
- xfer->pipe->device->address,
+ xfer->device->address,
xfer->pipe->endpoint->edesc->bEndpointAddress,
sbuf));
#endif
@@ -1822,7 +1821,7 @@ uhci_abort_xfer(struct usbd_xfer *xfer, usbd_status status)
s = splusb();
xfer->status = status; /* make software ignore it */
timeout_del(&xfer->timeout_handle);
- usb_rem_task(xfer->pipe->device, &xfer->abort_task);
+ usb_rem_task(xfer->device, &xfer->abort_task);
usb_transfer_complete(xfer);
splx(s);
return;
@@ -1837,7 +1836,7 @@ uhci_abort_xfer(struct usbd_xfer *xfer, usbd_status status)
s = splusb();
xfer->status = status; /* make software ignore it */
timeout_del(&xfer->timeout_handle);
- usb_rem_task(xfer->pipe->device, &xfer->abort_task);
+ usb_rem_task(xfer->device, &xfer->abort_task);
DPRINTFN(1,("uhci_abort_xfer: stop ex=%p\n", ex));
for (std = ex->stdstart; std != NULL; std = std->link.std)
std->td.td_status &= htole32(~(UHCI_TD_ACTIVE | UHCI_TD_IOC));
@@ -1900,7 +1899,7 @@ uhci_device_ctrl_transfer(struct usbd_xfer *xfer)
usbd_status
uhci_device_ctrl_start(struct usbd_xfer *xfer)
{
- struct uhci_softc *sc = (struct uhci_softc *)xfer->pipe->device->bus;
+ struct uhci_softc *sc = (struct uhci_softc *)xfer->device->bus;
usbd_status err;
if (sc->sc_bus.dying)
@@ -2534,7 +2533,7 @@ void
uhci_device_intr_done(struct usbd_xfer *xfer)
{
struct uhci_xfer *ex = UXFER(xfer);
- struct uhci_softc *sc = (struct uhci_softc *)xfer->pipe->device->bus;
+ struct uhci_softc *sc = (struct uhci_softc *)xfer->device->bus;
struct uhci_pipe *upipe = (struct uhci_pipe *)xfer->pipe;
struct uhci_soft_qh *sqh;
int i, npoll;
@@ -2596,7 +2595,7 @@ void
uhci_device_ctrl_done(struct usbd_xfer *xfer)
{
struct uhci_xfer *ex = UXFER(xfer);
- struct uhci_softc *sc = (struct uhci_softc *)xfer->pipe->device->bus;
+ struct uhci_softc *sc = (struct uhci_softc *)xfer->device->bus;
struct uhci_pipe *upipe = (struct uhci_pipe *)xfer->pipe;
#ifdef DIAGNOSTIC
@@ -2625,7 +2624,7 @@ void
uhci_device_bulk_done(struct usbd_xfer *xfer)
{
struct uhci_xfer *ex = UXFER(xfer);
- struct uhci_softc *sc = (struct uhci_softc *)xfer->pipe->device->bus;
+ struct uhci_softc *sc = (struct uhci_softc *)xfer->device->bus;
struct uhci_pipe *upipe = (struct uhci_pipe *)xfer->pipe;
DPRINTFN(5,("uhci_device_bulk_done: xfer=%p ex=%p sc=%p upipe=%p\n",
@@ -3007,7 +3006,7 @@ uhci_root_ctrl_transfer(struct usbd_xfer *xfer)
usbd_status
uhci_root_ctrl_start(struct usbd_xfer *xfer)
{
- struct uhci_softc *sc = (struct uhci_softc *)xfer->pipe->device->bus;
+ struct uhci_softc *sc = (struct uhci_softc *)xfer->device->bus;
usb_device_request_t *req;
void *buf = NULL;
int port, x;
@@ -3352,7 +3351,7 @@ uhci_root_ctrl_close(struct usbd_pipe *pipe)
void
uhci_root_intr_abort(struct usbd_xfer *xfer)
{
- struct uhci_softc *sc = (struct uhci_softc *)xfer->pipe->device->bus;
+ struct uhci_softc *sc = (struct uhci_softc *)xfer->device->bus;
timeout_del(&sc->sc_poll_handle);
sc->sc_intr_xfer = NULL;
@@ -3388,8 +3387,7 @@ uhci_root_intr_transfer(struct usbd_xfer *xfer)
usbd_status
uhci_root_intr_start(struct usbd_xfer *xfer)
{
- struct usbd_pipe *pipe = xfer->pipe;
- struct uhci_softc *sc = (struct uhci_softc *)pipe->device->bus;
+ struct uhci_softc *sc = (struct uhci_softc *)xfer->device->bus;
DPRINTFN(3, ("uhci_root_intr_start: xfer=%p len=%u flags=%d\n",
xfer, xfer->length, xfer->flags));