summaryrefslogtreecommitdiffstats
path: root/sys/dev/usb2/controller
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev/usb2/controller')
-rw-r--r--sys/dev/usb2/controller/at91dci.c42
-rw-r--r--sys/dev/usb2/controller/at91dci_atmelarm.c2
-rw-r--r--sys/dev/usb2/controller/ehci2.c68
-rw-r--r--sys/dev/usb2/controller/ehci2_pci.c2
-rw-r--r--sys/dev/usb2/controller/musb2_otg.c42
-rw-r--r--sys/dev/usb2/controller/musb2_otg_atmelarm.c2
-rw-r--r--sys/dev/usb2/controller/ohci2.c70
-rw-r--r--sys/dev/usb2/controller/ohci2_atmelarm.c2
-rw-r--r--sys/dev/usb2/controller/ohci2_pci.c2
-rw-r--r--sys/dev/usb2/controller/uhci2.c58
-rw-r--r--sys/dev/usb2/controller/uhci2_pci.c6
-rw-r--r--sys/dev/usb2/controller/usb2_bus.h2
-rw-r--r--sys/dev/usb2/controller/usb2_controller.c20
-rw-r--r--sys/dev/usb2/controller/uss820dci.c40
-rw-r--r--sys/dev/usb2/controller/uss820dci_atmelarm.c2
-rw-r--r--sys/dev/usb2/controller/uss820dci_pccard.c2
16 files changed, 181 insertions, 181 deletions
diff --git a/sys/dev/usb2/controller/at91dci.c b/sys/dev/usb2/controller/at91dci.c
index d5c7508..17eca9f 100644
--- a/sys/dev/usb2/controller/at91dci.c
+++ b/sys/dev/usb2/controller/at91dci.c
@@ -291,7 +291,7 @@ at91dci_rem_wakeup_set(struct usb2_device *udev, uint8_t is_on)
DPRINTFN(5, "is_on=%u\n", is_on);
- mtx_assert(&udev->bus->mtx, MA_OWNED);
+ USB_BUS_LOCK_ASSERT(udev->bus, MA_OWNED);
sc = AT9100_DCI_BUS2SC(udev->bus);
@@ -766,7 +766,7 @@ at91dci_vbus_interrupt(struct usb2_bus *bus, uint8_t is_on)
DPRINTFN(5, "vbus = %u\n", is_on);
- mtx_lock(&sc->sc_bus.mtx);
+ USB_BUS_LOCK(&sc->sc_bus);
if (is_on) {
if (!sc->sc_flags.status_vbus) {
sc->sc_flags.status_vbus = 1;
@@ -791,7 +791,7 @@ at91dci_vbus_interrupt(struct usb2_bus *bus, uint8_t is_on)
}
}
- mtx_unlock(&sc->sc_bus.mtx);
+ USB_BUS_UNLOCK(&sc->sc_bus);
return;
}
@@ -801,13 +801,13 @@ at91dci_interrupt(struct at91dci_softc *sc)
{
uint32_t status;
- mtx_lock(&sc->sc_bus.mtx);
+ USB_BUS_LOCK(&sc->sc_bus);
status = AT91_UDP_READ_4(sc, AT91_UDP_ISR);
status &= AT91_UDP_INT_DEFAULT;
if (!status) {
- mtx_unlock(&sc->sc_bus.mtx);
+ USB_BUS_UNLOCK(&sc->sc_bus);
return;
}
/* acknowledge interrupts */
@@ -879,7 +879,7 @@ at91dci_interrupt(struct at91dci_softc *sc)
at91dci_interrupt_poll(sc);
}
- mtx_unlock(&sc->sc_bus.mtx);
+ USB_BUS_UNLOCK(&sc->sc_bus);
return;
}
@@ -1065,12 +1065,12 @@ at91dci_timeout(void *arg)
DPRINTF("xfer=%p\n", xfer);
- mtx_assert(&sc->sc_bus.mtx, MA_OWNED);
+ USB_BUS_LOCK_ASSERT(&sc->sc_bus, MA_OWNED);
/* transfer is transferred */
at91dci_device_done(xfer, USB_ERR_TIMEOUT);
- mtx_unlock(&sc->sc_bus.mtx);
+ USB_BUS_UNLOCK(&sc->sc_bus);
return;
}
@@ -1115,7 +1115,7 @@ at91dci_root_intr_done(struct usb2_xfer *xfer,
DPRINTFN(9, "\n");
- mtx_assert(&sc->sc_bus.mtx, MA_OWNED);
+ USB_BUS_LOCK_ASSERT(&sc->sc_bus, MA_OWNED);
if (std->state != USB_SW_TR_PRE_DATA) {
if (std->state == USB_SW_TR_PRE_CALLBACK) {
@@ -1255,7 +1255,7 @@ at91dci_device_done(struct usb2_xfer *xfer, usb2_error_t error)
struct at91dci_softc *sc = xfer->usb2_sc;
uint8_t ep_no;
- mtx_assert(&sc->sc_bus.mtx, MA_OWNED);
+ USB_BUS_LOCK_ASSERT(&sc->sc_bus, MA_OWNED);
DPRINTFN(2, "xfer=%p, pipe=%p, error=%d\n",
xfer, xfer->pipe, error);
@@ -1281,7 +1281,7 @@ at91dci_set_stall(struct usb2_device *udev, struct usb2_xfer *xfer,
uint32_t csr_val;
uint8_t csr_reg;
- mtx_assert(&udev->bus->mtx, MA_OWNED);
+ USB_BUS_LOCK_ASSERT(udev->bus, MA_OWNED);
DPRINTFN(5, "pipe=%p\n", pipe);
@@ -1405,7 +1405,7 @@ at91dci_clear_stall(struct usb2_device *udev, struct usb2_pipe *pipe)
DPRINTFN(5, "pipe=%p\n", pipe);
- mtx_assert(&udev->bus->mtx, MA_OWNED);
+ USB_BUS_LOCK_ASSERT(udev->bus, MA_OWNED);
/* check mode */
if (udev->flags.usb2_mode != USB_MODE_DEVICE) {
@@ -1438,7 +1438,7 @@ at91dci_init(struct at91dci_softc *sc)
sc->sc_bus.usbrev = USB_REV_1_1;
sc->sc_bus.methods = &at91dci_bus_methods;
- mtx_lock(&sc->sc_bus.mtx);
+ USB_BUS_LOCK(&sc->sc_bus);
/* turn on clocks */
@@ -1446,7 +1446,7 @@ at91dci_init(struct at91dci_softc *sc)
(sc->sc_clocks_on) (sc->sc_clocks_arg);
}
/* wait a little for things to stabilise */
- usb2_pause_mtx(&sc->sc_bus.mtx, 1);
+ usb2_pause_mtx(&sc->sc_bus.bus_mtx, 1);
/* disable and clear all interrupts */
@@ -1483,7 +1483,7 @@ at91dci_init(struct at91dci_softc *sc)
at91dci_clocks_off(sc);
- mtx_unlock(&sc->sc_bus.mtx);
+ USB_BUS_UNLOCK(&sc->sc_bus);
/* catch any lost interrupts */
@@ -1495,7 +1495,7 @@ at91dci_init(struct at91dci_softc *sc)
void
at91dci_uninit(struct at91dci_softc *sc)
{
- mtx_lock(&sc->sc_bus.mtx);
+ USB_BUS_LOCK(&sc->sc_bus);
/* disable and clear all interrupts */
AT91_UDP_WRITE_4(sc, AT91_UDP_IDR, 0xFFFFFFFF);
@@ -1510,7 +1510,7 @@ at91dci_uninit(struct at91dci_softc *sc)
at91dci_pull_down(sc);
at91dci_clocks_off(sc);
- mtx_unlock(&sc->sc_bus.mtx);
+ USB_BUS_UNLOCK(&sc->sc_bus);
return;
}
@@ -1532,10 +1532,10 @@ at91dci_do_poll(struct usb2_bus *bus)
{
struct at91dci_softc *sc = AT9100_DCI_BUS2SC(bus);
- mtx_lock(&sc->sc_bus.mtx);
+ USB_BUS_LOCK(&sc->sc_bus);
at91dci_interrupt_poll(sc);
at91dci_root_ctrl_poll(sc);
- mtx_unlock(&sc->sc_bus.mtx);
+ USB_BUS_UNLOCK(&sc->sc_bus);
return;
}
@@ -1897,7 +1897,7 @@ at91dci_root_ctrl_done(struct usb2_xfer *xfer,
uint16_t index;
uint8_t use_polling;
- mtx_assert(&sc->sc_bus.mtx, MA_OWNED);
+ USB_BUS_LOCK_ASSERT(&sc->sc_bus, MA_OWNED);
if (std->state != USB_SW_TR_SETUP) {
if (std->state == USB_SW_TR_PRE_CALLBACK) {
@@ -1913,7 +1913,7 @@ at91dci_root_ctrl_done(struct usb2_xfer *xfer,
value = UGETW(std->req.wValue);
index = UGETW(std->req.wIndex);
- use_polling = mtx_owned(xfer->priv_mtx) ? 1 : 0;
+ use_polling = mtx_owned(xfer->xfer_mtx) ? 1 : 0;
/* demultiplex the control request */
diff --git a/sys/dev/usb2/controller/at91dci_atmelarm.c b/sys/dev/usb2/controller/at91dci_atmelarm.c
index 0a6f961..dd01773 100644
--- a/sys/dev/usb2/controller/at91dci_atmelarm.c
+++ b/sys/dev/usb2/controller/at91dci_atmelarm.c
@@ -210,7 +210,7 @@ at91_udp_attach(device_t dev)
device_set_ivars(sc->sc_dci.sc_bus.bdev, &sc->sc_dci.sc_bus);
err = usb2_config_td_setup(&sc->sc_dci.sc_config_td, sc,
- &sc->sc_dci.sc_bus.mtx, NULL, 0, 4);
+ &sc->sc_dci.sc_bus.bus_mtx, NULL, 0, 4);
if (err) {
device_printf(dev, "could not setup config thread!\n");
goto error;
diff --git a/sys/dev/usb2/controller/ehci2.c b/sys/dev/usb2/controller/ehci2.c
index 218a362..5797500 100644
--- a/sys/dev/usb2/controller/ehci2.c
+++ b/sys/dev/usb2/controller/ehci2.c
@@ -164,7 +164,7 @@ ehci_hc_reset(ehci_softc_t *sc)
EOWRITE4(sc, EHCI_USBCMD, 0); /* Halt controller */
for (n = 0; n != 100; n++) {
- usb2_pause_mtx(&sc->sc_bus.mtx, 1);
+ usb2_pause_mtx(&sc->sc_bus.bus_mtx, 1);
hcr = EOREAD4(sc, EHCI_USBSTS);
if (hcr & EHCI_STS_HCH) {
hcr = 0;
@@ -180,7 +180,7 @@ ehci_hc_reset(ehci_softc_t *sc)
EOWRITE4(sc, EHCI_USBCMD, EHCI_CMD_HCRESET);
for (n = 0; n != 100; n++) {
- usb2_pause_mtx(&sc->sc_bus.mtx, 1);
+ usb2_pause_mtx(&sc->sc_bus.bus_mtx, 1);
hcr = EOREAD4(sc, EHCI_USBCMD);
if (!(hcr & EHCI_CMD_HCRESET)) {
hcr = 0;
@@ -208,11 +208,11 @@ ehci_init(ehci_softc_t *sc)
uint16_t bit;
usb2_error_t err = 0;
- mtx_lock(&sc->sc_bus.mtx);
+ USB_BUS_LOCK(&sc->sc_bus);
DPRINTF("start\n");
- usb2_callout_init_mtx(&sc->sc_tmo_pcd, &sc->sc_bus.mtx,
+ usb2_callout_init_mtx(&sc->sc_tmo_pcd, &sc->sc_bus.bus_mtx,
CALLOUT_RETURNUNLOCKED);
#if USB_DEBUG
@@ -465,7 +465,7 @@ ehci_init(ehci_softc_t *sc)
EOWRITE4(sc, EHCI_CONFIGFLAG, EHCI_CONF_CF);
for (i = 0; i < 100; i++) {
- usb2_pause_mtx(&sc->sc_bus.mtx, 1);
+ usb2_pause_mtx(&sc->sc_bus.bus_mtx, 1);
hcr = EOREAD4(sc, EHCI_USBSTS) & EHCI_STS_HCH;
if (!hcr) {
break;
@@ -477,7 +477,7 @@ ehci_init(ehci_softc_t *sc)
goto done;
}
done:
- mtx_unlock(&sc->sc_bus.mtx);
+ USB_BUS_UNLOCK(&sc->sc_bus);
if (!err) {
/* catch any lost interrupts */
@@ -492,7 +492,7 @@ done:
void
ehci_detach(struct ehci_softc *sc)
{
- mtx_lock(&sc->sc_bus.mtx);
+ USB_BUS_LOCK(&sc->sc_bus);
usb2_callout_stop(&sc->sc_tmo_pcd);
@@ -502,9 +502,9 @@ ehci_detach(struct ehci_softc *sc)
DPRINTF("reset failed!\n");
}
/* XXX let stray task complete */
- usb2_pause_mtx(&sc->sc_bus.mtx, 50);
+ usb2_pause_mtx(&sc->sc_bus.bus_mtx, 50);
- mtx_unlock(&sc->sc_bus.mtx);
+ USB_BUS_UNLOCK(&sc->sc_bus);
usb2_callout_drain(&sc->sc_tmo_pcd);
@@ -518,7 +518,7 @@ ehci_suspend(struct ehci_softc *sc)
uint32_t hcr;
uint8_t i;
- mtx_lock(&sc->sc_bus.mtx);
+ USB_BUS_LOCK(&sc->sc_bus);
for (i = 1; i <= sc->sc_noport; i++) {
cmd = EOREAD4(sc, EHCI_PORTSC(i));
@@ -541,7 +541,7 @@ ehci_suspend(struct ehci_softc *sc)
if (hcr == 0) {
break;
}
- usb2_pause_mtx(&sc->sc_bus.mtx, 1);
+ usb2_pause_mtx(&sc->sc_bus.bus_mtx, 1);
}
if (hcr != 0) {
@@ -555,14 +555,14 @@ ehci_suspend(struct ehci_softc *sc)
if (hcr == EHCI_STS_HCH) {
break;
}
- usb2_pause_mtx(&sc->sc_bus.mtx, 1);
+ usb2_pause_mtx(&sc->sc_bus.bus_mtx, 1);
}
if (hcr != EHCI_STS_HCH) {
device_printf(sc->sc_bus.bdev,
"config timeout\n");
}
- mtx_unlock(&sc->sc_bus.mtx);
+ USB_BUS_UNLOCK(&sc->sc_bus);
return;
}
@@ -574,7 +574,7 @@ ehci_resume(struct ehci_softc *sc)
uint32_t hcr;
uint8_t i;
- mtx_lock(&sc->sc_bus.mtx);
+ USB_BUS_LOCK(&sc->sc_bus);
/* restore things in case the bios doesn't */
EOWRITE4(sc, EHCI_CTRLDSSEGMENT, 0);
@@ -599,7 +599,7 @@ ehci_resume(struct ehci_softc *sc)
}
if (hcr) {
- usb2_pause_mtx(&sc->sc_bus.mtx,
+ usb2_pause_mtx(&sc->sc_bus.bus_mtx,
USB_RESUME_WAIT);
for (i = 1; i <= sc->sc_noport; i++) {
@@ -618,15 +618,15 @@ ehci_resume(struct ehci_softc *sc)
if (hcr != EHCI_STS_HCH) {
break;
}
- usb2_pause_mtx(&sc->sc_bus.mtx, 1);
+ usb2_pause_mtx(&sc->sc_bus.bus_mtx, 1);
}
if (hcr == EHCI_STS_HCH) {
device_printf(sc->sc_bus.bdev, "config timeout\n");
}
- usb2_pause_mtx(&sc->sc_bus.mtx,
+ usb2_pause_mtx(&sc->sc_bus.bus_mtx,
USB_RESUME_WAIT);
- mtx_unlock(&sc->sc_bus.mtx);
+ USB_BUS_UNLOCK(&sc->sc_bus);
/* catch any lost interrupts */
ehci_do_poll(&sc->sc_bus);
@@ -639,12 +639,12 @@ ehci_shutdown(ehci_softc_t *sc)
{
DPRINTF("stopping the HC\n");
- mtx_lock(&sc->sc_bus.mtx);
+ USB_BUS_LOCK(&sc->sc_bus);
if (ehci_hc_reset(sc)) {
DPRINTF("reset failed!\n");
}
- mtx_unlock(&sc->sc_bus.mtx);
+ USB_BUS_UNLOCK(&sc->sc_bus);
}
#if USB_DEBUG
@@ -1415,7 +1415,7 @@ transferred:
static void
ehci_pcd_enable(ehci_softc_t *sc)
{
- mtx_assert(&sc->sc_bus.mtx, MA_OWNED);
+ USB_BUS_LOCK_ASSERT(&sc->sc_bus, MA_OWNED);
sc->sc_eintrs |= EHCI_STS_PCD;
EOWRITE4(sc, EHCI_USBINTR, sc->sc_eintrs);
@@ -1426,7 +1426,7 @@ ehci_pcd_enable(ehci_softc_t *sc)
usb2_sw_transfer(&sc->sc_root_intr,
&ehci_root_intr_done);
- mtx_unlock(&sc->sc_bus.mtx);
+ USB_BUS_UNLOCK(&sc->sc_bus);
return;
}
@@ -1460,7 +1460,7 @@ ehci_interrupt(ehci_softc_t *sc)
{
uint32_t status;
- mtx_lock(&sc->sc_bus.mtx);
+ USB_BUS_LOCK(&sc->sc_bus);
DPRINTFN(16, "real interrupt\n");
@@ -1517,7 +1517,7 @@ ehci_interrupt(ehci_softc_t *sc)
ehci_interrupt_poll(sc);
done:
- mtx_unlock(&sc->sc_bus.mtx);
+ USB_BUS_UNLOCK(&sc->sc_bus);
return;
}
@@ -1532,12 +1532,12 @@ ehci_timeout(void *arg)
DPRINTF("xfer=%p\n", xfer);
- mtx_assert(&sc->sc_bus.mtx, MA_OWNED);
+ USB_BUS_LOCK_ASSERT(&sc->sc_bus, MA_OWNED);
/* transfer is transferred */
ehci_device_done(xfer, USB_ERR_TIMEOUT);
- mtx_unlock(&sc->sc_bus.mtx);
+ USB_BUS_UNLOCK(&sc->sc_bus);
return;
}
@@ -1547,10 +1547,10 @@ ehci_do_poll(struct usb2_bus *bus)
{
struct ehci_softc *sc = EHCI_BUS2SC(bus);
- mtx_lock(&sc->sc_bus.mtx);
+ USB_BUS_LOCK(&sc->sc_bus);
ehci_interrupt_poll(sc);
ehci_root_ctrl_poll(sc);
- mtx_unlock(&sc->sc_bus.mtx);
+ USB_BUS_UNLOCK(&sc->sc_bus);
return;
}
@@ -1965,7 +1965,7 @@ ehci_root_intr_done(struct usb2_xfer *xfer,
uint16_t i;
uint16_t m;
- mtx_assert(&sc->sc_bus.mtx, MA_OWNED);
+ USB_BUS_LOCK_ASSERT(&sc->sc_bus, MA_OWNED);
if (std->state != USB_SW_TR_PRE_DATA) {
if (std->state == USB_SW_TR_PRE_CALLBACK) {
@@ -2124,7 +2124,7 @@ ehci_device_done(struct usb2_xfer *xfer, usb2_error_t error)
struct usb2_pipe_methods *methods = xfer->pipe->methods;
ehci_softc_t *sc = xfer->usb2_sc;
- mtx_assert(&sc->sc_bus.mtx, MA_OWNED);
+ USB_BUS_LOCK_ASSERT(&sc->sc_bus, MA_OWNED);
DPRINTFN(2, "xfer=%p, pipe=%p, error=%d\n",
xfer, xfer->pipe, error);
@@ -3076,7 +3076,7 @@ ehci_root_ctrl_done(struct usb2_xfer *xfer,
uint8_t l;
uint8_t use_polling;
- mtx_assert(&sc->sc_bus.mtx, MA_OWNED);
+ USB_BUS_LOCK_ASSERT(&sc->sc_bus, MA_OWNED);
if (std->state != USB_SW_TR_SETUP) {
if (std->state == USB_SW_TR_PRE_CALLBACK) {
@@ -3092,7 +3092,7 @@ ehci_root_ctrl_done(struct usb2_xfer *xfer,
value = UGETW(std->req.wValue);
index = UGETW(std->req.wIndex);
- use_polling = mtx_owned(xfer->priv_mtx) ? 1 : 0;
+ use_polling = mtx_owned(xfer->xfer_mtx) ? 1 : 0;
DPRINTFN(3, "type=0x%02x request=0x%02x wLen=0x%04x "
"wValue=0x%04x wIndex=0x%04x\n",
@@ -3373,7 +3373,7 @@ ehci_root_ctrl_done(struct usb2_xfer *xfer,
DELAY(USB_PORT_ROOT_RESET_DELAY * 1000);
} else {
/* Wait for reset to complete. */
- usb2_pause_mtx(&sc->sc_bus.mtx,
+ usb2_pause_mtx(&sc->sc_bus.bus_mtx,
USB_PORT_ROOT_RESET_DELAY);
}
@@ -3385,7 +3385,7 @@ ehci_root_ctrl_done(struct usb2_xfer *xfer,
DELAY(EHCI_PORT_RESET_COMPLETE * 1000);
} else {
/* Wait for HC to complete reset. */
- usb2_pause_mtx(&sc->sc_bus.mtx,
+ usb2_pause_mtx(&sc->sc_bus.bus_mtx,
EHCI_PORT_RESET_COMPLETE);
}
diff --git a/sys/dev/usb2/controller/ehci2_pci.c b/sys/dev/usb2/controller/ehci2_pci.c
index 1fb7dc2..2d33cb0 100644
--- a/sys/dev/usb2/controller/ehci2_pci.c
+++ b/sys/dev/usb2/controller/ehci2_pci.c
@@ -337,7 +337,7 @@ ehci_pci_attach(device_t self)
sprintf(sc->sc_vendor, "(0x%04x)", pci_get_vendor(self));
}
- err = usb2_config_td_setup(&sc->sc_config_td, sc, &sc->sc_bus.mtx,
+ err = usb2_config_td_setup(&sc->sc_config_td, sc, &sc->sc_bus.bus_mtx,
NULL, 0, 4);
if (err) {
device_printf(self, "could not setup config thread!\n");
diff --git a/sys/dev/usb2/controller/musb2_otg.c b/sys/dev/usb2/controller/musb2_otg.c
index b036d5c..f7832dc 100644
--- a/sys/dev/usb2/controller/musb2_otg.c
+++ b/sys/dev/usb2/controller/musb2_otg.c
@@ -221,7 +221,7 @@ musbotg_wakeup_peer(struct usb2_xfer *xfer)
if (!(sc->sc_flags.status_suspend)) {
return;
}
- use_polling = mtx_owned(xfer->priv_mtx) ? 1 : 0;
+ use_polling = mtx_owned(xfer->xfer_mtx) ? 1 : 0;
temp = MUSB2_READ_1(sc, MUSB2_REG_POWER);
temp |= MUSB2_MASK_RESUME;
@@ -233,7 +233,7 @@ musbotg_wakeup_peer(struct usb2_xfer *xfer)
DELAY(8000);
} else {
/* Wait for reset to complete. */
- usb2_pause_mtx(&sc->sc_bus.mtx, 8);
+ usb2_pause_mtx(&sc->sc_bus.bus_mtx, 8);
}
temp = MUSB2_READ_1(sc, MUSB2_REG_POWER);
@@ -982,7 +982,7 @@ musbotg_vbus_interrupt(struct usb2_bus *bus, uint8_t is_on)
DPRINTFN(4, "vbus = %u\n", is_on);
- mtx_lock(&sc->sc_bus.mtx);
+ USB_BUS_LOCK(&sc->sc_bus);
if (is_on) {
if (!sc->sc_flags.status_vbus) {
sc->sc_flags.status_vbus = 1;
@@ -1007,7 +1007,7 @@ musbotg_vbus_interrupt(struct usb2_bus *bus, uint8_t is_on)
}
}
- mtx_unlock(&sc->sc_bus.mtx);
+ USB_BUS_UNLOCK(&sc->sc_bus);
return;
}
@@ -1021,7 +1021,7 @@ musbotg_interrupt(struct musbotg_softc *sc)
uint8_t temp;
uint8_t to = 2;
- mtx_lock(&sc->sc_bus.mtx);
+ USB_BUS_LOCK(&sc->sc_bus);
repeat:
@@ -1116,7 +1116,7 @@ repeat:
if (--to)
goto repeat;
- mtx_unlock(&sc->sc_bus.mtx);
+ USB_BUS_UNLOCK(&sc->sc_bus);
return;
}
@@ -1273,12 +1273,12 @@ musbotg_timeout(void *arg)
DPRINTFN(1, "xfer=%p\n", xfer);
- mtx_assert(&sc->sc_bus.mtx, MA_OWNED);
+ USB_BUS_LOCK_ASSERT(&sc->sc_bus, MA_OWNED);
/* transfer is transferred */
musbotg_device_done(xfer, USB_ERR_TIMEOUT);
- mtx_unlock(&sc->sc_bus.mtx);
+ USB_BUS_UNLOCK(&sc->sc_bus);
return;
}
@@ -1356,7 +1356,7 @@ musbotg_root_intr_done(struct usb2_xfer *xfer,
DPRINTFN(8, "\n");
- mtx_assert(&sc->sc_bus.mtx, MA_OWNED);
+ USB_BUS_LOCK_ASSERT(&sc->sc_bus, MA_OWNED);
if (std->state != USB_SW_TR_PRE_DATA) {
if (std->state == USB_SW_TR_PRE_CALLBACK) {
@@ -1516,7 +1516,7 @@ musbotg_set_stall(struct usb2_device *udev, struct usb2_xfer *xfer,
struct musbotg_softc *sc;
uint8_t ep_no;
- mtx_assert(&udev->bus->mtx, MA_OWNED);
+ USB_BUS_LOCK_ASSERT(udev->bus, MA_OWNED);
DPRINTFN(4, "pipe=%p\n", pipe);
@@ -1702,7 +1702,7 @@ musbotg_clear_stall(struct usb2_device *udev, struct usb2_pipe *pipe)
DPRINTFN(4, "pipe=%p\n", pipe);
- mtx_assert(&udev->bus->mtx, MA_OWNED);
+ USB_BUS_LOCK_ASSERT(udev->bus, MA_OWNED);
/* check mode */
if (udev->flags.usb2_mode != USB_MODE_DEVICE) {
@@ -1741,7 +1741,7 @@ musbotg_init(struct musbotg_softc *sc)
sc->sc_bus.usbrev = USB_REV_2_0;
sc->sc_bus.methods = &musbotg_bus_methods;
- mtx_lock(&sc->sc_bus.mtx);
+ USB_BUS_LOCK(&sc->sc_bus);
/* turn on clocks */
@@ -1749,7 +1749,7 @@ musbotg_init(struct musbotg_softc *sc)
(sc->sc_clocks_on) (sc->sc_clocks_arg);
}
/* wait a little for things to stabilise */
- usb2_pause_mtx(&sc->sc_bus.mtx, 1);
+ usb2_pause_mtx(&sc->sc_bus.bus_mtx, 1);
/* disable all interrupts */
@@ -1762,7 +1762,7 @@ musbotg_init(struct musbotg_softc *sc)
musbotg_pull_common(sc, 0);
/* wait a little bit (10ms) */
- usb2_pause_mtx(&sc->sc_bus.mtx, 10);
+ usb2_pause_mtx(&sc->sc_bus.bus_mtx, 10);
/* disable double packet buffering */
MUSB2_WRITE_2(sc, MUSB2_REG_RXDBDIS, 0xFFFF);
@@ -1871,7 +1871,7 @@ musbotg_init(struct musbotg_softc *sc)
musbotg_clocks_off(sc);
- mtx_unlock(&sc->sc_bus.mtx);
+ USB_BUS_UNLOCK(&sc->sc_bus);
/* catch any lost interrupts */
@@ -1883,7 +1883,7 @@ musbotg_init(struct musbotg_softc *sc)
void
musbotg_uninit(struct musbotg_softc *sc)
{
- mtx_lock(&sc->sc_bus.mtx);
+ USB_BUS_LOCK(&sc->sc_bus);
/* disable all interrupts */
MUSB2_WRITE_1(sc, MUSB2_REG_INTUSBE, 0);
@@ -1899,7 +1899,7 @@ musbotg_uninit(struct musbotg_softc *sc)
musbotg_pull_down(sc);
musbotg_clocks_off(sc);
- mtx_unlock(&sc->sc_bus.mtx);
+ USB_BUS_UNLOCK(&sc->sc_bus);
return;
}
@@ -1921,10 +1921,10 @@ musbotg_do_poll(struct usb2_bus *bus)
{
struct musbotg_softc *sc = MUSBOTG_BUS2SC(bus);
- mtx_lock(&sc->sc_bus.mtx);
+ USB_BUS_LOCK(&sc->sc_bus);
musbotg_interrupt_poll(sc);
musbotg_root_ctrl_poll(sc);
- mtx_unlock(&sc->sc_bus.mtx);
+ USB_BUS_UNLOCK(&sc->sc_bus);
return;
}
@@ -2293,7 +2293,7 @@ musbotg_root_ctrl_done(struct usb2_xfer *xfer,
uint16_t index;
uint8_t use_polling;
- mtx_assert(&sc->sc_bus.mtx, MA_OWNED);
+ USB_BUS_LOCK_ASSERT(&sc->sc_bus, MA_OWNED);
if (std->state != USB_SW_TR_SETUP) {
if (std->state == USB_SW_TR_PRE_CALLBACK) {
@@ -2309,7 +2309,7 @@ musbotg_root_ctrl_done(struct usb2_xfer *xfer,
value = UGETW(std->req.wValue);
index = UGETW(std->req.wIndex);
- use_polling = mtx_owned(xfer->priv_mtx) ? 1 : 0;
+ use_polling = mtx_owned(xfer->xfer_mtx) ? 1 : 0;
/* demultiplex the control request */
diff --git a/sys/dev/usb2/controller/musb2_otg_atmelarm.c b/sys/dev/usb2/controller/musb2_otg_atmelarm.c
index 58ee134..49b653ff 100644
--- a/sys/dev/usb2/controller/musb2_otg_atmelarm.c
+++ b/sys/dev/usb2/controller/musb2_otg_atmelarm.c
@@ -138,7 +138,7 @@ musbotg_attach(device_t dev)
device_set_ivars(sc->sc_otg.sc_bus.bdev, &sc->sc_otg.sc_bus);
err = usb2_config_td_setup(&sc->sc_otg.sc_config_td, sc,
- &sc->sc_otg.sc_bus.mtx, NULL, 0, 4);
+ &sc->sc_otg.sc_bus.bus_mtx, NULL, 0, 4);
if (err) {
device_printf(dev, "could not setup config thread!\n");
goto error;
diff --git a/sys/dev/usb2/controller/ohci2.c b/sys/dev/usb2/controller/ohci2.c
index 54133ba..8ed49d3 100644
--- a/sys/dev/usb2/controller/ohci2.c
+++ b/sys/dev/usb2/controller/ohci2.c
@@ -173,7 +173,7 @@ ohci_controller_init(ohci_softc_t *sc)
DPRINTF("SMM active, request owner change\n");
OWRITE4(sc, OHCI_COMMAND_STATUS, OHCI_OCR);
for (i = 0; (i < 100) && (ctl & OHCI_IR); i++) {
- usb2_pause_mtx(&sc->sc_bus.mtx, 1);
+ usb2_pause_mtx(&sc->sc_bus.bus_mtx, 1);
ctl = OREAD4(sc, OHCI_CONTROL);
}
if (ctl & OHCI_IR) {
@@ -186,7 +186,7 @@ ohci_controller_init(ohci_softc_t *sc)
DPRINTF("cold started\n");
reset:
/* controller was cold started */
- usb2_pause_mtx(&sc->sc_bus.mtx,
+ usb2_pause_mtx(&sc->sc_bus.bus_mtx,
USB_BUS_RESET_DELAY);
}
@@ -197,7 +197,7 @@ reset:
DPRINTF("%s: resetting\n", device_get_nameunit(sc->sc_bus.bdev));
OWRITE4(sc, OHCI_CONTROL, OHCI_HCFS_RESET);
- usb2_pause_mtx(&sc->sc_bus.mtx,
+ usb2_pause_mtx(&sc->sc_bus.bus_mtx,
USB_BUS_RESET_DELAY);
/* we now own the host controller and the bus has been reset */
@@ -260,7 +260,7 @@ reset:
desca = OREAD4(sc, OHCI_RH_DESCRIPTOR_A);
OWRITE4(sc, OHCI_RH_DESCRIPTOR_A, desca | OHCI_NOCP);
OWRITE4(sc, OHCI_RH_STATUS, OHCI_LPSC); /* Enable port power */
- usb2_pause_mtx(&sc->sc_bus.mtx,
+ usb2_pause_mtx(&sc->sc_bus.bus_mtx,
OHCI_ENABLE_POWER_DELAY);
OWRITE4(sc, OHCI_RH_DESCRIPTOR_A, desca);
@@ -270,7 +270,7 @@ reset:
*/
sc->sc_noport = 0;
for (i = 0; (i < 10) && (sc->sc_noport == 0); i++) {
- usb2_pause_mtx(&sc->sc_bus.mtx,
+ usb2_pause_mtx(&sc->sc_bus.bus_mtx,
OHCI_READ_DESC_DELAY);
sc->sc_noport = OHCI_GET_NDP(OREAD4(sc, OHCI_RH_DESCRIPTOR_A));
}
@@ -309,7 +309,7 @@ ohci_init(ohci_softc_t *sc)
uint16_t x;
uint16_t y;
- mtx_lock(&sc->sc_bus.mtx);
+ USB_BUS_LOCK(&sc->sc_bus);
DPRINTF("start\n");
@@ -391,7 +391,7 @@ ohci_init(ohci_softc_t *sc)
/* set up the bus struct */
sc->sc_bus.methods = &ohci_bus_methods;
- usb2_callout_init_mtx(&sc->sc_tmo_rhsc, &sc->sc_bus.mtx,
+ usb2_callout_init_mtx(&sc->sc_tmo_rhsc, &sc->sc_bus.bus_mtx,
CALLOUT_RETURNUNLOCKED);
#if USB_DEBUG
@@ -408,10 +408,10 @@ ohci_init(ohci_softc_t *sc)
sc->sc_bus.usbrev = USB_REV_1_0;
if (ohci_controller_init(sc)) {
- mtx_unlock(&sc->sc_bus.mtx);
+ USB_BUS_UNLOCK(&sc->sc_bus);
return (USB_ERR_INVAL);
} else {
- mtx_unlock(&sc->sc_bus.mtx);
+ USB_BUS_UNLOCK(&sc->sc_bus);
/* catch any lost interrupts */
ohci_do_poll(&sc->sc_bus);
return (USB_ERR_NORMAL_COMPLETION);
@@ -424,7 +424,7 @@ ohci_init(ohci_softc_t *sc)
void
ohci_detach(struct ohci_softc *sc)
{
- mtx_lock(&sc->sc_bus.mtx);
+ USB_BUS_LOCK(&sc->sc_bus);
usb2_callout_stop(&sc->sc_tmo_rhsc);
@@ -432,9 +432,9 @@ ohci_detach(struct ohci_softc *sc)
OWRITE4(sc, OHCI_CONTROL, OHCI_HCFS_RESET);
/* XXX let stray task complete */
- usb2_pause_mtx(&sc->sc_bus.mtx, 50);
+ usb2_pause_mtx(&sc->sc_bus.bus_mtx, 50);
- mtx_unlock(&sc->sc_bus.mtx);
+ USB_BUS_UNLOCK(&sc->sc_bus);
usb2_callout_drain(&sc->sc_tmo_rhsc);
@@ -449,7 +449,7 @@ ohci_suspend(ohci_softc_t *sc)
{
uint32_t ctl;
- mtx_lock(&sc->sc_bus.mtx);
+ USB_BUS_LOCK(&sc->sc_bus);
#if USB_DEBUG
DPRINTF("\n");
@@ -470,10 +470,10 @@ ohci_suspend(ohci_softc_t *sc)
ctl |= OHCI_HCFS_SUSPEND;
OWRITE4(sc, OHCI_CONTROL, ctl);
- usb2_pause_mtx(&sc->sc_bus.mtx,
+ usb2_pause_mtx(&sc->sc_bus.bus_mtx,
USB_RESUME_WAIT);
- mtx_unlock(&sc->sc_bus.mtx);
+ USB_BUS_UNLOCK(&sc->sc_bus);
return;
}
@@ -482,7 +482,7 @@ ohci_resume(ohci_softc_t *sc)
{
uint32_t ctl;
- mtx_lock(&sc->sc_bus.mtx);
+ USB_BUS_LOCK(&sc->sc_bus);
#if USB_DEBUG
DPRINTF("\n");
@@ -503,13 +503,13 @@ ohci_resume(ohci_softc_t *sc)
ctl = OREAD4(sc, OHCI_CONTROL);
ctl |= OHCI_HCFS_RESUME;
OWRITE4(sc, OHCI_CONTROL, ctl);
- usb2_pause_mtx(&sc->sc_bus.mtx, USB_RESUME_DELAY);
+ usb2_pause_mtx(&sc->sc_bus.bus_mtx, USB_RESUME_DELAY);
ctl = (ctl & ~OHCI_HCFS_MASK) | OHCI_HCFS_OPERATIONAL;
OWRITE4(sc, OHCI_CONTROL, ctl);
- usb2_pause_mtx(&sc->sc_bus.mtx, USB_RESUME_RECOVERY);
+ usb2_pause_mtx(&sc->sc_bus.bus_mtx, USB_RESUME_RECOVERY);
sc->sc_control = sc->sc_intre = 0;
- mtx_unlock(&sc->sc_bus.mtx);
+ USB_BUS_UNLOCK(&sc->sc_bus);
/* catch any lost interrupts */
ohci_do_poll(&sc->sc_bus);
@@ -699,7 +699,7 @@ _ohci_append_qh(ohci_ed_t *sed, uint32_t td_self, ohci_ed_t *last)
{
DPRINTFN(11, "%p to %p\n", sed, last);
- /* (sc->sc_bus.mtx) must be locked */
+ /* (sc->sc_bus.bus_mtx) must be locked */
sed->next = last->next;
sed->ed_next = last->ed_next;
@@ -728,7 +728,7 @@ _ohci_remove_qh(ohci_ed_t *sed, ohci_ed_t *last)
{
DPRINTFN(11, "%p from %p\n", sed, last);
- /* (sc->sc_bus.mtx) must be locked */
+ /* (sc->sc_bus.bus_mtx) must be locked */
/* only remove if not removed from a queue */
if (sed->prev) {
@@ -1099,7 +1099,7 @@ ohci_rhsc_enable(ohci_softc_t *sc)
{
DPRINTFN(5, "\n");
- mtx_assert(&sc->sc_bus.mtx, MA_OWNED);
+ USB_BUS_LOCK_ASSERT(&sc->sc_bus, MA_OWNED);
sc->sc_eintrs |= OHCI_RHSC;
OWRITE4(sc, OHCI_INTERRUPT_ENABLE, OHCI_RHSC);
@@ -1110,7 +1110,7 @@ ohci_rhsc_enable(ohci_softc_t *sc)
usb2_sw_transfer(&sc->sc_root_intr,
&ohci_root_intr_done);
- mtx_unlock(&sc->sc_bus.mtx);
+ USB_BUS_UNLOCK(&sc->sc_bus);
return;
}
@@ -1146,7 +1146,7 @@ ohci_interrupt(ohci_softc_t *sc)
uint32_t status;
uint32_t done;
- mtx_lock(&sc->sc_bus.mtx);
+ USB_BUS_LOCK(&sc->sc_bus);
hcca = ohci_get_hcca(sc);
@@ -1246,7 +1246,7 @@ ohci_interrupt(ohci_softc_t *sc)
ohci_interrupt_poll(sc);
done:
- mtx_unlock(&sc->sc_bus.mtx);
+ USB_BUS_UNLOCK(&sc->sc_bus);
return;
}
@@ -1261,12 +1261,12 @@ ohci_timeout(void *arg)
DPRINTF("xfer=%p\n", xfer);
- mtx_assert(&sc->sc_bus.mtx, MA_OWNED);
+ USB_BUS_LOCK_ASSERT(&sc->sc_bus, MA_OWNED);
/* transfer is transferred */
ohci_device_done(xfer, USB_ERR_TIMEOUT);
- mtx_unlock(&sc->sc_bus.mtx);
+ USB_BUS_UNLOCK(&sc->sc_bus);
return;
}
@@ -1276,10 +1276,10 @@ ohci_do_poll(struct usb2_bus *bus)
{
struct ohci_softc *sc = OHCI_BUS2SC(bus);
- mtx_lock(&sc->sc_bus.mtx);
+ USB_BUS_LOCK(&sc->sc_bus);
ohci_interrupt_poll(sc);
ohci_root_ctrl_poll(sc);
- mtx_unlock(&sc->sc_bus.mtx);
+ USB_BUS_UNLOCK(&sc->sc_bus);
return;
}
@@ -1617,7 +1617,7 @@ ohci_root_intr_done(struct usb2_xfer *xfer,
uint16_t i;
uint16_t m;
- mtx_assert(&sc->sc_bus.mtx, MA_OWNED);
+ USB_BUS_LOCK_ASSERT(&sc->sc_bus, MA_OWNED);
if (std->state != USB_SW_TR_PRE_DATA) {
if (std->state == USB_SW_TR_PRE_CALLBACK) {
@@ -1663,7 +1663,7 @@ ohci_device_done(struct usb2_xfer *xfer, usb2_error_t error)
ohci_softc_t *sc = xfer->usb2_sc;
ohci_ed_t *ed;
- mtx_assert(&sc->sc_bus.mtx, MA_OWNED);
+ USB_BUS_LOCK_ASSERT(&sc->sc_bus, MA_OWNED);
DPRINTFN(2, "xfer=%p, pipe=%p, error=%d\n",
@@ -2198,7 +2198,7 @@ ohci_root_ctrl_done(struct usb2_xfer *xfer,
uint8_t l;
uint8_t use_polling;
- mtx_assert(&sc->sc_bus.mtx, MA_OWNED);
+ USB_BUS_LOCK_ASSERT(&sc->sc_bus, MA_OWNED);
if (std->state != USB_SW_TR_SETUP) {
if (std->state == USB_SW_TR_PRE_CALLBACK) {
@@ -2214,7 +2214,7 @@ ohci_root_ctrl_done(struct usb2_xfer *xfer,
value = UGETW(std->req.wValue);
index = UGETW(std->req.wIndex);
- use_polling = mtx_owned(xfer->priv_mtx) ? 1 : 0;
+ use_polling = mtx_owned(xfer->xfer_mtx) ? 1 : 0;
DPRINTFN(3, "type=0x%02x request=0x%02x wLen=0x%04x "
"wValue=0x%04x wIndex=0x%04x\n",
@@ -2375,7 +2375,7 @@ ohci_root_ctrl_done(struct usb2_xfer *xfer,
/* enable RHSC interrupt if condition is cleared. */
if ((OREAD4(sc, port) >> 16) == 0) {
ohci_rhsc_enable(sc);
- mtx_lock(&sc->sc_bus.mtx);
+ USB_BUS_LOCK(&sc->sc_bus);
}
break;
default:
@@ -2456,7 +2456,7 @@ ohci_root_ctrl_done(struct usb2_xfer *xfer,
/* polling */
DELAY(USB_PORT_ROOT_RESET_DELAY * 1000);
} else {
- usb2_pause_mtx(&sc->sc_bus.mtx,
+ usb2_pause_mtx(&sc->sc_bus.bus_mtx,
USB_PORT_ROOT_RESET_DELAY);
}
diff --git a/sys/dev/usb2/controller/ohci2_atmelarm.c b/sys/dev/usb2/controller/ohci2_atmelarm.c
index 83325be..cd0d332 100644
--- a/sys/dev/usb2/controller/ohci2_atmelarm.c
+++ b/sys/dev/usb2/controller/ohci2_atmelarm.c
@@ -111,7 +111,7 @@ ohci_atmelarm_attach(device_t dev)
strlcpy(sc->sc_ohci.sc_vendor, "Atmel", sizeof(sc->sc_ohci.sc_vendor));
err = usb2_config_td_setup(&sc->sc_ohci.sc_config_td, sc,
- &sc->sc_ohci.sc_bus.mtx, NULL, 0, 4);
+ &sc->sc_ohci.sc_bus.bus_mtx, NULL, 0, 4);
if (err) {
device_printf(dev, "could not setup config thread!\n");
goto error;
diff --git a/sys/dev/usb2/controller/ohci2_pci.c b/sys/dev/usb2/controller/ohci2_pci.c
index 60ae0b6..fe84e9c 100644
--- a/sys/dev/usb2/controller/ohci2_pci.c
+++ b/sys/dev/usb2/controller/ohci2_pci.c
@@ -280,7 +280,7 @@ ohci_pci_attach(device_t self)
sprintf(sc->sc_vendor, "(0x%04x)", pci_get_vendor(self));
}
- err = usb2_config_td_setup(&sc->sc_config_td, sc, &sc->sc_bus.mtx,
+ err = usb2_config_td_setup(&sc->sc_config_td, sc, &sc->sc_bus.bus_mtx,
NULL, 0, 4);
if (err) {
device_printf(self, "could not setup config thread!\n");
diff --git a/sys/dev/usb2/controller/uhci2.c b/sys/dev/usb2/controller/uhci2.c
index 9a938d9..5e23cc1 100644
--- a/sys/dev/usb2/controller/uhci2.c
+++ b/sys/dev/usb2/controller/uhci2.c
@@ -265,7 +265,7 @@ uhci_reset(uhci_softc_t *sc)
struct usb2_page_search buf_res;
uint16_t n;
- mtx_assert(&sc->sc_bus.mtx, MA_OWNED);
+ USB_BUS_LOCK_ASSERT(&sc->sc_bus, MA_OWNED);
DPRINTF("resetting the HC\n");
@@ -279,7 +279,7 @@ uhci_reset(uhci_softc_t *sc)
/* wait */
- usb2_pause_mtx(&sc->sc_bus.mtx,
+ usb2_pause_mtx(&sc->sc_bus.bus_mtx,
USB_BUS_RESET_DELAY);
/* terminate all transfers */
@@ -292,7 +292,7 @@ uhci_reset(uhci_softc_t *sc)
while (n--) {
/* wait one millisecond */
- usb2_pause_mtx(&sc->sc_bus.mtx, 1);
+ usb2_pause_mtx(&sc->sc_bus.bus_mtx, 1);
if (!(UREAD2(sc, UHCI_CMD) & UHCI_CMD_HCRESET)) {
goto done_1;
@@ -308,7 +308,7 @@ done_1:
while (n--) {
/* wait one millisecond */
- usb2_pause_mtx(&sc->sc_bus.mtx, 1);
+ usb2_pause_mtx(&sc->sc_bus.bus_mtx, 1);
/* check if HC is stopped */
if (UREAD2(sc, UHCI_STS) & UHCI_STS_HCH) {
@@ -332,7 +332,7 @@ done_2:
static void
uhci_start(uhci_softc_t *sc)
{
- mtx_assert(&sc->sc_bus.mtx, MA_OWNED);
+ USB_BUS_LOCK_ASSERT(&sc->sc_bus, MA_OWNED);
DPRINTFN(2, "enabling\n");
@@ -355,7 +355,7 @@ uhci_start(uhci_softc_t *sc)
while (n--) {
/* wait one millisecond */
- usb2_pause_mtx(&sc->sc_bus.mtx, 1);
+ usb2_pause_mtx(&sc->sc_bus.bus_mtx, 1);
/* check that controller has started */
@@ -416,7 +416,7 @@ uhci_init(uhci_softc_t *sc)
uint16_t x;
uint16_t y;
- mtx_lock(&sc->sc_bus.mtx);
+ USB_BUS_LOCK(&sc->sc_bus);
DPRINTF("start\n");
@@ -613,7 +613,7 @@ uhci_init(uhci_softc_t *sc)
/* start the controller */
uhci_start(sc);
- mtx_unlock(&sc->sc_bus.mtx);
+ USB_BUS_UNLOCK(&sc->sc_bus);
/* catch lost interrupts */
uhci_do_poll(&sc->sc_bus);
@@ -628,7 +628,7 @@ uhci_init(uhci_softc_t *sc)
void
uhci_suspend(uhci_softc_t *sc)
{
- mtx_lock(&sc->sc_bus.mtx);
+ USB_BUS_LOCK(&sc->sc_bus);
#if USB_DEBUG
if (uhcidebug > 2) {
@@ -648,16 +648,16 @@ uhci_suspend(uhci_softc_t *sc)
UHCICMD(sc, UHCI_CMD_EGSM);
- usb2_pause_mtx(&sc->sc_bus.mtx, USB_RESUME_WAIT);
+ usb2_pause_mtx(&sc->sc_bus.bus_mtx, USB_RESUME_WAIT);
- mtx_unlock(&sc->sc_bus.mtx);
+ USB_BUS_UNLOCK(&sc->sc_bus);
return;
}
void
uhci_resume(uhci_softc_t *sc)
{
- mtx_lock(&sc->sc_bus.mtx);
+ USB_BUS_LOCK(&sc->sc_bus);
/* reset the controller */
@@ -667,7 +667,7 @@ uhci_resume(uhci_softc_t *sc)
UHCICMD(sc, UHCI_CMD_FGR);
- usb2_pause_mtx(&sc->sc_bus.mtx,
+ usb2_pause_mtx(&sc->sc_bus.bus_mtx,
USB_RESUME_DELAY);
/* and start traffic again */
@@ -680,7 +680,7 @@ uhci_resume(uhci_softc_t *sc)
}
#endif
- mtx_unlock(&sc->sc_bus.mtx);
+ USB_BUS_UNLOCK(&sc->sc_bus);
/* catch lost interrupts */
uhci_do_poll(&sc->sc_bus);
@@ -1448,7 +1448,7 @@ uhci_interrupt(uhci_softc_t *sc)
{
uint32_t status;
- mtx_lock(&sc->sc_bus.mtx);
+ USB_BUS_LOCK(&sc->sc_bus);
DPRINTFN(16, "real interrupt\n");
@@ -1506,7 +1506,7 @@ uhci_interrupt(uhci_softc_t *sc)
uhci_interrupt_poll(sc);
done:
- mtx_unlock(&sc->sc_bus.mtx);
+ USB_BUS_UNLOCK(&sc->sc_bus);
return;
}
@@ -1521,12 +1521,12 @@ uhci_timeout(void *arg)
DPRINTF("xfer=%p\n", xfer);
- mtx_assert(&sc->sc_bus.mtx, MA_OWNED);
+ USB_BUS_LOCK_ASSERT(&sc->sc_bus, MA_OWNED);
/* transfer is transferred */
uhci_device_done(xfer, USB_ERR_TIMEOUT);
- mtx_unlock(&sc->sc_bus.mtx);
+ USB_BUS_UNLOCK(&sc->sc_bus);
return;
}
@@ -1536,10 +1536,10 @@ uhci_do_poll(struct usb2_bus *bus)
{
struct uhci_softc *sc = UHCI_BUS2SC(bus);
- mtx_lock(&sc->sc_bus.mtx);
+ USB_BUS_LOCK(&sc->sc_bus);
uhci_interrupt_poll(sc);
uhci_root_ctrl_poll(sc);
- mtx_unlock(&sc->sc_bus.mtx);
+ USB_BUS_UNLOCK(&sc->sc_bus);
return;
}
@@ -1857,7 +1857,7 @@ uhci_device_done(struct usb2_xfer *xfer, usb2_error_t error)
uhci_softc_t *sc = xfer->usb2_sc;
uhci_qh_t *qh;
- mtx_assert(&sc->sc_bus.mtx, MA_OWNED);
+ USB_BUS_LOCK_ASSERT(&sc->sc_bus, MA_OWNED);
DPRINTFN(2, "xfer=%p, pipe=%p, error=%d\n",
xfer, xfer->pipe, error);
@@ -2437,7 +2437,7 @@ uhci_portreset(uhci_softc_t *sc, uint16_t index, uint8_t use_polling)
/* polling */
DELAY(USB_PORT_ROOT_RESET_DELAY * 1000);
} else {
- usb2_pause_mtx(&sc->sc_bus.mtx,
+ usb2_pause_mtx(&sc->sc_bus.bus_mtx,
USB_PORT_ROOT_RESET_DELAY);
}
@@ -2451,7 +2451,7 @@ uhci_portreset(uhci_softc_t *sc, uint16_t index, uint8_t use_polling)
/* polling */
DELAY(1000);
} else {
- usb2_pause_mtx(&sc->sc_bus.mtx, 1);
+ usb2_pause_mtx(&sc->sc_bus.bus_mtx, 1);
}
DPRINTFN(4, "uhci port %d reset, status1 = 0x%04x\n",
@@ -2466,7 +2466,7 @@ uhci_portreset(uhci_softc_t *sc, uint16_t index, uint8_t use_polling)
/* polling */
DELAY(USB_PORT_RESET_DELAY * 1000);
} else {
- usb2_pause_mtx(&sc->sc_bus.mtx,
+ usb2_pause_mtx(&sc->sc_bus.bus_mtx,
USB_PORT_RESET_DELAY);
}
@@ -2560,7 +2560,7 @@ uhci_root_ctrl_done(struct usb2_xfer *xfer,
uint16_t change;
uint8_t use_polling;
- mtx_assert(&sc->sc_bus.mtx, MA_OWNED);
+ USB_BUS_LOCK_ASSERT(&sc->sc_bus, MA_OWNED);
if (std->state != USB_SW_TR_SETUP) {
if (std->state == USB_SW_TR_PRE_CALLBACK) {
@@ -2576,7 +2576,7 @@ uhci_root_ctrl_done(struct usb2_xfer *xfer,
value = UGETW(std->req.wValue);
index = UGETW(std->req.wIndex);
- use_polling = mtx_owned(xfer->priv_mtx) ? 1 : 0;
+ use_polling = mtx_owned(xfer->xfer_mtx) ? 1 : 0;
DPRINTFN(3, "type=0x%02x request=0x%02x wLen=0x%04x "
"wValue=0x%04x wIndex=0x%04x\n",
@@ -2913,7 +2913,7 @@ uhci_root_intr_done(struct usb2_xfer *xfer,
{
uhci_softc_t *sc = xfer->usb2_sc;
- mtx_assert(&sc->sc_bus.mtx, MA_OWNED);
+ USB_BUS_LOCK_ASSERT(&sc->sc_bus, MA_OWNED);
if (std->state != USB_SW_TR_PRE_DATA) {
if (std->state == USB_SW_TR_PRE_CALLBACK) {
@@ -2941,7 +2941,7 @@ uhci_root_intr_check(void *arg)
DPRINTFN(21, "\n");
- mtx_assert(&sc->sc_bus.mtx, MA_OWNED);
+ USB_BUS_LOCK_ASSERT(&sc->sc_bus, MA_OWNED);
sc->sc_hub_idata[0] = 0;
@@ -2960,7 +2960,7 @@ uhci_root_intr_check(void *arg)
usb2_sw_transfer(&sc->sc_root_intr,
&uhci_root_intr_done);
}
- mtx_unlock(&sc->sc_bus.mtx);
+ USB_BUS_UNLOCK(&sc->sc_bus);
return;
}
diff --git a/sys/dev/usb2/controller/uhci2_pci.c b/sys/dev/usb2/controller/uhci2_pci.c
index 947f9af..44e0b59 100644
--- a/sys/dev/usb2/controller/uhci2_pci.c
+++ b/sys/dev/usb2/controller/uhci2_pci.c
@@ -321,7 +321,7 @@ uhci_pci_attach(device_t self)
break;
}
- err = usb2_config_td_setup(&sc->sc_config_td, sc, &sc->sc_bus.mtx,
+ err = usb2_config_td_setup(&sc->sc_config_td, sc, &sc->sc_bus.bus_mtx,
NULL, 0, 4);
if (err) {
device_printf(self, "could not setup config thread!\n");
@@ -390,12 +390,12 @@ uhci_pci_detach(device_t self)
* uhci_init.
*/
if (sc->sc_io_res) {
- mtx_lock(&sc->sc_bus.mtx);
+ USB_BUS_LOCK(&sc->sc_bus);
/* stop the controller */
uhci_reset(sc);
- mtx_unlock(&sc->sc_bus.mtx);
+ USB_BUS_UNLOCK(&sc->sc_bus);
}
pci_disable_busmaster(self);
diff --git a/sys/dev/usb2/controller/usb2_bus.h b/sys/dev/usb2/controller/usb2_bus.h
index cfe98f7..c58c986 100644
--- a/sys/dev/usb2/controller/usb2_bus.h
+++ b/sys/dev/usb2/controller/usb2_bus.h
@@ -54,7 +54,7 @@ struct usb2_bus {
struct usb2_process explore_proc;
struct usb2_bus_msg explore_msg[2];
struct usb2_bus_msg detach_msg[2];
- struct mtx mtx; /* This mutex protects the USB
+ struct mtx bus_mtx; /* This mutex protects the USB
* hardware */
struct usb2_perm perm;
struct usb2_xfer_queue intr_q;
diff --git a/sys/dev/usb2/controller/usb2_controller.c b/sys/dev/usb2/controller/usb2_controller.c
index fdfa3a6..028c312 100644
--- a/sys/dev/usb2/controller/usb2_controller.c
+++ b/sys/dev/usb2/controller/usb2_controller.c
@@ -144,7 +144,7 @@ usb2_detach(device_t dev)
}
/* Let the USB explore process detach all devices. */
- mtx_lock(&bus->mtx);
+ USB_BUS_LOCK(bus);
if (usb2_proc_msignal(&bus->explore_proc,
&bus->detach_msg[0], &bus->detach_msg[1])) {
/* ignore */
@@ -154,7 +154,7 @@ usb2_detach(device_t dev)
usb2_proc_mwait(&bus->explore_proc,
&bus->detach_msg[0], &bus->detach_msg[1]);
- mtx_unlock(&bus->mtx);
+ USB_BUS_UNLOCK(bus);
/* Get rid of USB explore process */
@@ -187,7 +187,7 @@ usb2_bus_explore(struct usb2_proc_msg *pm)
/* avoid zero, hence that is memory default */
bus->driver_added_refcount = 1;
}
- mtx_unlock(&bus->mtx);
+ USB_BUS_UNLOCK(bus);
mtx_lock(&Giant);
@@ -199,7 +199,7 @@ usb2_bus_explore(struct usb2_proc_msg *pm)
mtx_unlock(&Giant);
- mtx_lock(&bus->mtx);
+ USB_BUS_LOCK(bus);
}
return;
}
@@ -221,7 +221,7 @@ usb2_bus_detach(struct usb2_proc_msg *pm)
dev = bus->bdev;
/* clear the softc */
device_set_softc(dev, NULL);
- mtx_unlock(&bus->mtx);
+ USB_BUS_UNLOCK(bus);
mtx_lock(&Giant);
@@ -236,7 +236,7 @@ usb2_bus_detach(struct usb2_proc_msg *pm)
usb2_free_device(udev);
mtx_unlock(&Giant);
- mtx_lock(&bus->mtx);
+ USB_BUS_LOCK(bus);
/* clear bdev variable last */
bus->bdev = NULL;
return;
@@ -320,7 +320,7 @@ usb2_attach_sub(device_t dev, struct usb2_bus *bus)
/* Create a new USB process */
if (usb2_proc_setup(&bus->explore_proc,
- &bus->mtx, USB_PRI_MED)) {
+ &bus->bus_mtx, USB_PRI_MED)) {
printf("WARNING: Creation of USB explore process failed.\n");
}
/* set softc - we are ready */
@@ -432,13 +432,13 @@ usb2_bus_mem_alloc_all(struct usb2_bus *bus, bus_dma_tag_t dmat,
bus->devices_max = USB_MAX_DEVICES;
- mtx_init(&bus->mtx, "USB lock",
+ mtx_init(&bus->bus_mtx, "USB bus lock",
NULL, MTX_DEF | MTX_RECURSE);
TAILQ_INIT(&bus->intr_q.head);
usb2_dma_tag_setup(bus->dma_parent_tag, bus->dma_tags,
- dmat, &bus->mtx, NULL, NULL, 32, USB_BUS_DMA_TAG_MAX);
+ dmat, &bus->bus_mtx, NULL, NULL, 32, USB_BUS_DMA_TAG_MAX);
if (cb) {
cb(bus, &usb2_bus_mem_alloc_all_cb);
@@ -471,7 +471,7 @@ usb2_bus_mem_free_all(struct usb2_bus *bus, usb2_bus_mem_cb_t *cb)
}
usb2_dma_tag_unsetup(bus->dma_parent_tag);
- mtx_destroy(&bus->mtx);
+ mtx_destroy(&bus->bus_mtx);
return;
}
diff --git a/sys/dev/usb2/controller/uss820dci.c b/sys/dev/usb2/controller/uss820dci.c
index cc9f219..e6af4d7 100644
--- a/sys/dev/usb2/controller/uss820dci.c
+++ b/sys/dev/usb2/controller/uss820dci.c
@@ -235,7 +235,7 @@ uss820dci_rem_wakeup_set(struct usb2_device *udev, uint8_t is_on)
DPRINTFN(5, "is_on=%u\n", is_on);
- mtx_assert(&udev->bus->mtx, MA_OWNED);
+ USB_BUS_LOCK_ASSERT(udev->bus, MA_OWNED);
sc = USS820_DCI_BUS2SC(udev->bus);
@@ -755,7 +755,7 @@ uss820dci_interrupt(struct uss820dci_softc *sc)
uint8_t ssr;
uint8_t event;
- mtx_lock(&sc->sc_bus.mtx);
+ USB_BUS_LOCK(&sc->sc_bus);
ssr = USS820_READ_1(sc, USS820_SSR);
@@ -826,7 +826,7 @@ uss820dci_interrupt(struct uss820dci_softc *sc)
/* poll all active transfers */
uss820dci_interrupt_poll(sc);
- mtx_unlock(&sc->sc_bus.mtx);
+ USB_BUS_UNLOCK(&sc->sc_bus);
return;
}
@@ -993,12 +993,12 @@ uss820dci_timeout(void *arg)
DPRINTF("xfer=%p\n", xfer);
- mtx_assert(&sc->sc_bus.mtx, MA_OWNED);
+ USB_BUS_LOCK_ASSERT(&sc->sc_bus, MA_OWNED);
/* transfer is transferred */
uss820dci_device_done(xfer, USB_ERR_TIMEOUT);
- mtx_unlock(&sc->sc_bus.mtx);
+ USB_BUS_UNLOCK(&sc->sc_bus);
return;
}
@@ -1078,7 +1078,7 @@ uss820dci_root_intr_done(struct usb2_xfer *xfer,
DPRINTFN(9, "\n");
- mtx_assert(&sc->sc_bus.mtx, MA_OWNED);
+ USB_BUS_LOCK_ASSERT(&sc->sc_bus, MA_OWNED);
if (std->state != USB_SW_TR_PRE_DATA) {
if (std->state == USB_SW_TR_PRE_CALLBACK) {
@@ -1215,7 +1215,7 @@ done:
static void
uss820dci_device_done(struct usb2_xfer *xfer, usb2_error_t error)
{
- mtx_assert(xfer->usb2_mtx, MA_OWNED);
+ USB_BUS_LOCK_ASSERT(xfer->udev->bus, MA_OWNED);
DPRINTFN(2, "xfer=%p, pipe=%p, error=%d\n",
xfer, xfer->pipe, error);
@@ -1238,7 +1238,7 @@ uss820dci_set_stall(struct usb2_device *udev, struct usb2_xfer *xfer,
uint8_t ep_dir;
uint8_t temp;
- mtx_assert(&udev->bus->mtx, MA_OWNED);
+ USB_BUS_LOCK_ASSERT(udev->bus, MA_OWNED);
DPRINTFN(5, "pipe=%p\n", pipe);
@@ -1324,7 +1324,7 @@ uss820dci_clear_stall(struct usb2_device *udev, struct usb2_pipe *pipe)
struct uss820dci_softc *sc;
struct usb2_endpoint_descriptor *ed;
- mtx_assert(&udev->bus->mtx, MA_OWNED);
+ USB_BUS_LOCK_ASSERT(udev->bus, MA_OWNED);
DPRINTFN(5, "pipe=%p\n", pipe);
@@ -1361,7 +1361,7 @@ uss820dci_init(struct uss820dci_softc *sc)
sc->sc_bus.usbrev = USB_REV_1_1;
sc->sc_bus.methods = &uss820dci_bus_methods;
- mtx_lock(&sc->sc_bus.mtx);
+ USB_BUS_LOCK(&sc->sc_bus);
/* we always have VBUS */
sc->sc_flags.status_vbus = 1;
@@ -1380,7 +1380,7 @@ uss820dci_init(struct uss820dci_softc *sc)
break;
}
if (n == 100) {
- mtx_unlock(&sc->sc_bus.mtx);
+ USB_BUS_UNLOCK(&sc->sc_bus);
return (USB_ERR_INVAL);
}
/* wait a little for things to stabilise */
@@ -1391,13 +1391,13 @@ uss820dci_init(struct uss820dci_softc *sc)
uss820dci_pull_down(sc);
/* wait 10ms for pulldown to stabilise */
- usb2_pause_mtx(&sc->sc_bus.mtx, 10);
+ usb2_pause_mtx(&sc->sc_bus.bus_mtx, 10);
/* check hardware revision */
temp = USS820_READ_1(sc, USS820_REV);
if (temp < 0x13) {
- mtx_unlock(&sc->sc_bus.mtx);
+ USB_BUS_UNLOCK(&sc->sc_bus);
return (USB_ERR_INVAL);
}
/* enable interrupts */
@@ -1503,7 +1503,7 @@ uss820dci_init(struct uss820dci_softc *sc)
uss820dci_update_shared_1(sc, USS820_EPCON, 0xFF, temp);
}
- mtx_unlock(&sc->sc_bus.mtx);
+ USB_BUS_UNLOCK(&sc->sc_bus);
/* catch any lost interrupts */
@@ -1517,7 +1517,7 @@ uss820dci_uninit(struct uss820dci_softc *sc)
{
uint8_t temp;
- mtx_lock(&sc->sc_bus.mtx);
+ USB_BUS_LOCK(&sc->sc_bus);
/* disable all interrupts */
temp = USS820_READ_1(sc, USS820_SCR);
@@ -1532,7 +1532,7 @@ uss820dci_uninit(struct uss820dci_softc *sc)
sc->sc_flags.change_connect = 1;
uss820dci_pull_down(sc);
- mtx_unlock(&sc->sc_bus.mtx);
+ USB_BUS_UNLOCK(&sc->sc_bus);
return;
}
@@ -1554,10 +1554,10 @@ uss820dci_do_poll(struct usb2_bus *bus)
{
struct uss820dci_softc *sc = USS820_DCI_BUS2SC(bus);
- mtx_lock(&sc->sc_bus.mtx);
+ USB_BUS_LOCK(&sc->sc_bus);
uss820dci_interrupt_poll(sc);
uss820dci_root_ctrl_poll(sc);
- mtx_unlock(&sc->sc_bus.mtx);
+ USB_BUS_UNLOCK(&sc->sc_bus);
return;
}
@@ -1919,7 +1919,7 @@ uss820dci_root_ctrl_done(struct usb2_xfer *xfer,
uint16_t index;
uint8_t use_polling;
- mtx_assert(&sc->sc_bus.mtx, MA_OWNED);
+ USB_BUS_LOCK_ASSERT(&sc->sc_bus, MA_OWNED);
if (std->state != USB_SW_TR_SETUP) {
if (std->state == USB_SW_TR_PRE_CALLBACK) {
@@ -1935,7 +1935,7 @@ uss820dci_root_ctrl_done(struct usb2_xfer *xfer,
value = UGETW(std->req.wValue);
index = UGETW(std->req.wIndex);
- use_polling = mtx_owned(xfer->priv_mtx) ? 1 : 0;
+ use_polling = mtx_owned(xfer->xfer_mtx) ? 1 : 0;
/* demultiplex the control request */
diff --git a/sys/dev/usb2/controller/uss820dci_atmelarm.c b/sys/dev/usb2/controller/uss820dci_atmelarm.c
index be71fb3..3a1eb16 100644
--- a/sys/dev/usb2/controller/uss820dci_atmelarm.c
+++ b/sys/dev/usb2/controller/uss820dci_atmelarm.c
@@ -171,7 +171,7 @@ uss820_atmelarm_attach(device_t dev)
device_set_ivars(sc->sc_bus.bdev, &sc->sc_bus);
err = usb2_config_td_setup(&sc->sc_config_td, sc,
- &sc->sc_bus.mtx, NULL, 0, 4);
+ &sc->sc_bus.bus_mtx, NULL, 0, 4);
if (err) {
device_printf(dev, "could not setup config thread!\n");
goto error;
diff --git a/sys/dev/usb2/controller/uss820dci_pccard.c b/sys/dev/usb2/controller/uss820dci_pccard.c
index f57935d..dde423d 100644
--- a/sys/dev/usb2/controller/uss820dci_pccard.c
+++ b/sys/dev/usb2/controller/uss820dci_pccard.c
@@ -190,7 +190,7 @@ uss820_pccard_attach(device_t dev)
device_set_ivars(sc->sc_bus.bdev, &sc->sc_bus);
err = usb2_config_td_setup(&sc->sc_config_td, sc,
- &sc->sc_bus.mtx, NULL, 0, 4);
+ &sc->sc_bus.bus_mtx, NULL, 0, 4);
if (err) {
device_printf(dev, "could not setup config thread!\n");
goto error;
OpenPOWER on IntegriCloud