svn commit: r191402 - in head/sys/dev/usb: . controller template
Andrew Thompson
thompsa at FreeBSD.org
Wed Apr 22 17:08:18 UTC 2009
Author: thompsa
Date: Wed Apr 22 17:08:16 2009
New Revision: 191402
URL: http://svn.freebsd.org/changeset/base/191402
Log:
MFp4 //depot/projects/usb at 160930
Change the roothub exec functions to take the usb request and data pointers
directly rather than placing them on the parent bus struct.
Submitted by: Hans Petter Selasky
Modified:
head/sys/dev/usb/controller/at91dci.c
head/sys/dev/usb/controller/atmegadci.c
head/sys/dev/usb/controller/ehci.c
head/sys/dev/usb/controller/ehci.h
head/sys/dev/usb/controller/musb_otg.c
head/sys/dev/usb/controller/ohci.c
head/sys/dev/usb/controller/ohci.h
head/sys/dev/usb/controller/uhci.c
head/sys/dev/usb/controller/uhci.h
head/sys/dev/usb/controller/uss820dci.c
head/sys/dev/usb/template/usb_template.c
head/sys/dev/usb/usb_bus.h
head/sys/dev/usb/usb_controller.h
head/sys/dev/usb/usb_core.h
head/sys/dev/usb/usb_device.c
head/sys/dev/usb/usb_dynamic.c
head/sys/dev/usb/usb_dynamic.h
head/sys/dev/usb/usb_handle_request.c
head/sys/dev/usb/usb_request.c
head/sys/dev/usb/usb_request.h
Modified: head/sys/dev/usb/controller/at91dci.c
==============================================================================
--- head/sys/dev/usb/controller/at91dci.c Wed Apr 22 17:08:13 2009 (r191401)
+++ head/sys/dev/usb/controller/at91dci.c Wed Apr 22 17:08:16 2009 (r191402)
@@ -1744,28 +1744,32 @@ USB_MAKE_STRING_DESC(STRING_LANG, at91dc
USB_MAKE_STRING_DESC(STRING_VENDOR, at91dci_vendor);
USB_MAKE_STRING_DESC(STRING_PRODUCT, at91dci_product);
-static void
-at91dci_roothub_exec(struct usb2_bus *bus)
+static usb2_error_t
+at91dci_roothub_exec(struct usb2_device *udev,
+ struct usb2_device_request *req, const void **pptr, uint16_t *plength)
{
- struct at91dci_softc *sc = AT9100_DCI_BUS2SC(bus);
- struct usb2_sw_transfer *std = &sc->sc_bus.roothub_req;
+ struct at91dci_softc *sc = AT9100_DCI_BUS2SC(udev->bus);
+ const void *ptr;
+ uint16_t len;
uint16_t value;
uint16_t index;
+ usb2_error_t err;
USB_BUS_LOCK_ASSERT(&sc->sc_bus, MA_OWNED);
/* buffer reset */
- std->ptr = USB_ADD_BYTES(&sc->sc_hub_temp, 0);
- std->len = 0;
+ ptr = (const void *)&sc->sc_hub_temp;
+ len = 0;
+ err = 0;
- value = UGETW(std->req.wValue);
- index = UGETW(std->req.wIndex);
+ value = UGETW(req->wValue);
+ index = UGETW(req->wIndex);
/* demultiplex the control request */
- switch (std->req.bmRequestType) {
+ switch (req->bmRequestType) {
case UT_READ_DEVICE:
- switch (std->req.bRequest) {
+ switch (req->bRequest) {
case UR_GET_DESCRIPTOR:
goto tr_handle_get_descriptor;
case UR_GET_CONFIG:
@@ -1778,7 +1782,7 @@ at91dci_roothub_exec(struct usb2_bus *bu
break;
case UT_WRITE_DEVICE:
- switch (std->req.bRequest) {
+ switch (req->bRequest) {
case UR_SET_ADDRESS:
goto tr_handle_set_address;
case UR_SET_CONFIG:
@@ -1794,9 +1798,9 @@ at91dci_roothub_exec(struct usb2_bus *bu
break;
case UT_WRITE_ENDPOINT:
- switch (std->req.bRequest) {
+ switch (req->bRequest) {
case UR_CLEAR_FEATURE:
- switch (UGETW(std->req.wValue)) {
+ switch (UGETW(req->wValue)) {
case UF_ENDPOINT_HALT:
goto tr_handle_clear_halt;
case UF_DEVICE_REMOTE_WAKEUP:
@@ -1806,7 +1810,7 @@ at91dci_roothub_exec(struct usb2_bus *bu
}
break;
case UR_SET_FEATURE:
- switch (UGETW(std->req.wValue)) {
+ switch (UGETW(req->wValue)) {
case UF_ENDPOINT_HALT:
goto tr_handle_set_halt;
case UF_DEVICE_REMOTE_WAKEUP:
@@ -1823,7 +1827,7 @@ at91dci_roothub_exec(struct usb2_bus *bu
break;
case UT_READ_ENDPOINT:
- switch (std->req.bRequest) {
+ switch (req->bRequest) {
case UR_GET_STATUS:
goto tr_handle_get_ep_status;
default:
@@ -1832,7 +1836,7 @@ at91dci_roothub_exec(struct usb2_bus *bu
break;
case UT_WRITE_INTERFACE:
- switch (std->req.bRequest) {
+ switch (req->bRequest) {
case UR_SET_INTERFACE:
goto tr_handle_set_interface;
case UR_CLEAR_FEATURE:
@@ -1844,7 +1848,7 @@ at91dci_roothub_exec(struct usb2_bus *bu
break;
case UT_READ_INTERFACE:
- switch (std->req.bRequest) {
+ switch (req->bRequest) {
case UR_GET_INTERFACE:
goto tr_handle_get_interface;
case UR_GET_STATUS:
@@ -1865,7 +1869,7 @@ at91dci_roothub_exec(struct usb2_bus *bu
break;
case UT_WRITE_CLASS_DEVICE:
- switch (std->req.bRequest) {
+ switch (req->bRequest) {
case UR_CLEAR_FEATURE:
goto tr_valid;
case UR_SET_DESCRIPTOR:
@@ -1877,7 +1881,7 @@ at91dci_roothub_exec(struct usb2_bus *bu
break;
case UT_WRITE_CLASS_OTHER:
- switch (std->req.bRequest) {
+ switch (req->bRequest) {
case UR_CLEAR_FEATURE:
goto tr_handle_clear_port_feature;
case UR_SET_FEATURE:
@@ -1893,7 +1897,7 @@ at91dci_roothub_exec(struct usb2_bus *bu
break;
case UT_READ_CLASS_OTHER:
- switch (std->req.bRequest) {
+ switch (req->bRequest) {
case UR_GET_TT_STATE:
goto tr_handle_get_tt_state;
case UR_GET_STATUS:
@@ -1904,7 +1908,7 @@ at91dci_roothub_exec(struct usb2_bus *bu
break;
case UT_READ_CLASS_DEVICE:
- switch (std->req.bRequest) {
+ switch (req->bRequest) {
case UR_GET_DESCRIPTOR:
goto tr_handle_get_class_descriptor;
case UR_GET_STATUS:
@@ -1925,31 +1929,31 @@ tr_handle_get_descriptor:
if (value & 0xff) {
goto tr_stalled;
}
- std->len = sizeof(at91dci_devd);
- std->ptr = USB_ADD_BYTES(&at91dci_devd, 0);
+ len = sizeof(at91dci_devd);
+ ptr = (const void *)&at91dci_devd;
goto tr_valid;
case UDESC_CONFIG:
if (value & 0xff) {
goto tr_stalled;
}
- std->len = sizeof(at91dci_confd);
- std->ptr = USB_ADD_BYTES(&at91dci_confd, 0);
+ len = sizeof(at91dci_confd);
+ ptr = (const void *)&at91dci_confd;
goto tr_valid;
case UDESC_STRING:
switch (value & 0xff) {
case 0: /* Language table */
- std->len = sizeof(at91dci_langtab);
- std->ptr = USB_ADD_BYTES(&at91dci_langtab, 0);
+ len = sizeof(at91dci_langtab);
+ ptr = (const void *)&at91dci_langtab;
goto tr_valid;
case 1: /* Vendor */
- std->len = sizeof(at91dci_vendor);
- std->ptr = USB_ADD_BYTES(&at91dci_vendor, 0);
+ len = sizeof(at91dci_vendor);
+ ptr = (const void *)&at91dci_vendor;
goto tr_valid;
case 2: /* Product */
- std->len = sizeof(at91dci_product);
- std->ptr = USB_ADD_BYTES(&at91dci_product, 0);
+ len = sizeof(at91dci_product);
+ ptr = (const void *)&at91dci_product;
goto tr_valid;
default:
break;
@@ -1961,12 +1965,12 @@ tr_handle_get_descriptor:
goto tr_stalled;
tr_handle_get_config:
- std->len = 1;
+ len = 1;
sc->sc_hub_temp.wValue[0] = sc->sc_conf;
goto tr_valid;
tr_handle_get_status:
- std->len = 2;
+ len = 2;
USETW(sc->sc_hub_temp.wValue, UDS_SELF_POWERED);
goto tr_valid;
@@ -1985,7 +1989,7 @@ tr_handle_set_config:
goto tr_valid;
tr_handle_get_interface:
- std->len = 1;
+ len = 1;
sc->sc_hub_temp.wValue[0] = 0;
goto tr_valid;
@@ -1993,7 +1997,7 @@ tr_handle_get_tt_state:
tr_handle_get_class_status:
tr_handle_get_iface_status:
tr_handle_get_ep_status:
- std->len = 2;
+ len = 2;
USETW(sc->sc_hub_temp.wValue, 0);
goto tr_valid;
@@ -2038,7 +2042,7 @@ tr_handle_clear_port_feature:
sc->sc_flags.change_suspend = 0;
break;
default:
- std->err = USB_ERR_IOERROR;
+ err = USB_ERR_IOERROR;
goto done;
}
goto tr_valid;
@@ -2063,7 +2067,7 @@ tr_handle_set_port_feature:
sc->sc_flags.port_powered = 1;
break;
default:
- std->err = USB_ERR_IOERROR;
+ err = USB_ERR_IOERROR;
goto done;
}
goto tr_valid;
@@ -2117,22 +2121,24 @@ tr_handle_get_port_status:
value |= UPS_C_SUSPEND;
}
USETW(sc->sc_hub_temp.ps.wPortChange, value);
- std->len = sizeof(sc->sc_hub_temp.ps);
+ len = sizeof(sc->sc_hub_temp.ps);
goto tr_valid;
tr_handle_get_class_descriptor:
if (value & 0xFF) {
goto tr_stalled;
}
- std->ptr = USB_ADD_BYTES(&at91dci_hubd, 0);
- std->len = sizeof(at91dci_hubd);
+ ptr = (const void *)&at91dci_hubd;
+ len = sizeof(at91dci_hubd);
goto tr_valid;
tr_stalled:
- std->err = USB_ERR_STALLED;
+ err = USB_ERR_STALLED;
tr_valid:
done:
- return;
+ *plength = len;
+ *pptr = ptr;
+ return (err);
}
static void
Modified: head/sys/dev/usb/controller/atmegadci.c
==============================================================================
--- head/sys/dev/usb/controller/atmegadci.c Wed Apr 22 17:08:13 2009 (r191401)
+++ head/sys/dev/usb/controller/atmegadci.c Wed Apr 22 17:08:16 2009 (r191402)
@@ -1551,29 +1551,33 @@ USB_MAKE_STRING_DESC(STRING_LANG, atmega
USB_MAKE_STRING_DESC(STRING_VENDOR, atmegadci_vendor);
USB_MAKE_STRING_DESC(STRING_PRODUCT, atmegadci_product);
-static void
-atmegadci_roothub_exec(struct usb2_bus *bus)
+static usb2_error_t
+atmegadci_roothub_exec(struct usb2_device *udev,
+ struct usb2_device_request *req, const void **pptr, uint16_t *plength)
{
- struct atmegadci_softc *sc = ATMEGA_BUS2SC(bus);
- struct usb2_sw_transfer *std = &sc->sc_bus.roothub_req;
+ struct atmegadci_softc *sc = ATMEGA_BUS2SC(udev->bus);
+ const void *ptr;
+ uint16_t len;
uint16_t value;
uint16_t index;
uint8_t temp;
+ usb2_error_t err;
USB_BUS_LOCK_ASSERT(&sc->sc_bus, MA_OWNED);
/* buffer reset */
- std->ptr = USB_ADD_BYTES(&sc->sc_hub_temp, 0);
- std->len = 0;
+ ptr = (const void *)&sc->sc_hub_temp;
+ len = 0;
+ err = 0;
- value = UGETW(std->req.wValue);
- index = UGETW(std->req.wIndex);
+ value = UGETW(req->wValue);
+ index = UGETW(req->wIndex);
/* demultiplex the control request */
- switch (std->req.bmRequestType) {
+ switch (req->bmRequestType) {
case UT_READ_DEVICE:
- switch (std->req.bRequest) {
+ switch (req->bRequest) {
case UR_GET_DESCRIPTOR:
goto tr_handle_get_descriptor;
case UR_GET_CONFIG:
@@ -1586,7 +1590,7 @@ atmegadci_roothub_exec(struct usb2_bus *
break;
case UT_WRITE_DEVICE:
- switch (std->req.bRequest) {
+ switch (req->bRequest) {
case UR_SET_ADDRESS:
goto tr_handle_set_address;
case UR_SET_CONFIG:
@@ -1602,9 +1606,9 @@ atmegadci_roothub_exec(struct usb2_bus *
break;
case UT_WRITE_ENDPOINT:
- switch (std->req.bRequest) {
+ switch (req->bRequest) {
case UR_CLEAR_FEATURE:
- switch (UGETW(std->req.wValue)) {
+ switch (UGETW(req->wValue)) {
case UF_ENDPOINT_HALT:
goto tr_handle_clear_halt;
case UF_DEVICE_REMOTE_WAKEUP:
@@ -1614,7 +1618,7 @@ atmegadci_roothub_exec(struct usb2_bus *
}
break;
case UR_SET_FEATURE:
- switch (UGETW(std->req.wValue)) {
+ switch (UGETW(req->wValue)) {
case UF_ENDPOINT_HALT:
goto tr_handle_set_halt;
case UF_DEVICE_REMOTE_WAKEUP:
@@ -1631,7 +1635,7 @@ atmegadci_roothub_exec(struct usb2_bus *
break;
case UT_READ_ENDPOINT:
- switch (std->req.bRequest) {
+ switch (req->bRequest) {
case UR_GET_STATUS:
goto tr_handle_get_ep_status;
default:
@@ -1640,7 +1644,7 @@ atmegadci_roothub_exec(struct usb2_bus *
break;
case UT_WRITE_INTERFACE:
- switch (std->req.bRequest) {
+ switch (req->bRequest) {
case UR_SET_INTERFACE:
goto tr_handle_set_interface;
case UR_CLEAR_FEATURE:
@@ -1652,7 +1656,7 @@ atmegadci_roothub_exec(struct usb2_bus *
break;
case UT_READ_INTERFACE:
- switch (std->req.bRequest) {
+ switch (req->bRequest) {
case UR_GET_INTERFACE:
goto tr_handle_get_interface;
case UR_GET_STATUS:
@@ -1673,7 +1677,7 @@ atmegadci_roothub_exec(struct usb2_bus *
break;
case UT_WRITE_CLASS_DEVICE:
- switch (std->req.bRequest) {
+ switch (req->bRequest) {
case UR_CLEAR_FEATURE:
goto tr_valid;
case UR_SET_DESCRIPTOR:
@@ -1685,7 +1689,7 @@ atmegadci_roothub_exec(struct usb2_bus *
break;
case UT_WRITE_CLASS_OTHER:
- switch (std->req.bRequest) {
+ switch (req->bRequest) {
case UR_CLEAR_FEATURE:
goto tr_handle_clear_port_feature;
case UR_SET_FEATURE:
@@ -1701,7 +1705,7 @@ atmegadci_roothub_exec(struct usb2_bus *
break;
case UT_READ_CLASS_OTHER:
- switch (std->req.bRequest) {
+ switch (req->bRequest) {
case UR_GET_TT_STATE:
goto tr_handle_get_tt_state;
case UR_GET_STATUS:
@@ -1712,7 +1716,7 @@ atmegadci_roothub_exec(struct usb2_bus *
break;
case UT_READ_CLASS_DEVICE:
- switch (std->req.bRequest) {
+ switch (req->bRequest) {
case UR_GET_DESCRIPTOR:
goto tr_handle_get_class_descriptor;
case UR_GET_STATUS:
@@ -1733,31 +1737,31 @@ tr_handle_get_descriptor:
if (value & 0xff) {
goto tr_stalled;
}
- std->len = sizeof(atmegadci_devd);
- std->ptr = USB_ADD_BYTES(&atmegadci_devd, 0);
+ len = sizeof(atmegadci_devd);
+ ptr = (const void *)&atmegadci_devd;
goto tr_valid;
case UDESC_CONFIG:
if (value & 0xff) {
goto tr_stalled;
}
- std->len = sizeof(atmegadci_confd);
- std->ptr = USB_ADD_BYTES(&atmegadci_confd, 0);
+ len = sizeof(atmegadci_confd);
+ ptr = (const void *)&atmegadci_confd;
goto tr_valid;
case UDESC_STRING:
switch (value & 0xff) {
case 0: /* Language table */
- std->len = sizeof(atmegadci_langtab);
- std->ptr = USB_ADD_BYTES(&atmegadci_langtab, 0);
+ len = sizeof(atmegadci_langtab);
+ ptr = (const void *)&atmegadci_langtab;
goto tr_valid;
case 1: /* Vendor */
- std->len = sizeof(atmegadci_vendor);
- std->ptr = USB_ADD_BYTES(&atmegadci_vendor, 0);
+ len = sizeof(atmegadci_vendor);
+ ptr = (const void *)&atmegadci_vendor;
goto tr_valid;
case 2: /* Product */
- std->len = sizeof(atmegadci_product);
- std->ptr = USB_ADD_BYTES(&atmegadci_product, 0);
+ len = sizeof(atmegadci_product);
+ ptr = (const void *)&atmegadci_product;
goto tr_valid;
default:
break;
@@ -1769,12 +1773,12 @@ tr_handle_get_descriptor:
goto tr_stalled;
tr_handle_get_config:
- std->len = 1;
+ len = 1;
sc->sc_hub_temp.wValue[0] = sc->sc_conf;
goto tr_valid;
tr_handle_get_status:
- std->len = 2;
+ len = 2;
USETW(sc->sc_hub_temp.wValue, UDS_SELF_POWERED);
goto tr_valid;
@@ -1793,7 +1797,7 @@ tr_handle_set_config:
goto tr_valid;
tr_handle_get_interface:
- std->len = 1;
+ len = 1;
sc->sc_hub_temp.wValue[0] = 0;
goto tr_valid;
@@ -1801,7 +1805,7 @@ tr_handle_get_tt_state:
tr_handle_get_class_status:
tr_handle_get_iface_status:
tr_handle_get_ep_status:
- std->len = 2;
+ len = 2;
USETW(sc->sc_hub_temp.wValue, 0);
goto tr_valid;
@@ -1877,7 +1881,7 @@ tr_handle_clear_port_feature:
sc->sc_flags.change_suspend = 0;
break;
default:
- std->err = USB_ERR_IOERROR;
+ err = USB_ERR_IOERROR;
goto done;
}
goto tr_valid;
@@ -1902,7 +1906,7 @@ tr_handle_set_port_feature:
sc->sc_flags.port_powered = 1;
break;
default:
- std->err = USB_ERR_IOERROR;
+ err = USB_ERR_IOERROR;
goto done;
}
goto tr_valid;
@@ -1950,22 +1954,24 @@ tr_handle_get_port_status:
value |= UPS_C_SUSPEND;
}
USETW(sc->sc_hub_temp.ps.wPortChange, value);
- std->len = sizeof(sc->sc_hub_temp.ps);
+ len = sizeof(sc->sc_hub_temp.ps);
goto tr_valid;
tr_handle_get_class_descriptor:
if (value & 0xFF) {
goto tr_stalled;
}
- std->ptr = USB_ADD_BYTES(&atmegadci_hubd, 0);
- std->len = sizeof(atmegadci_hubd);
+ ptr = (const void *)&atmegadci_hubd;
+ len = sizeof(atmegadci_hubd);
goto tr_valid;
tr_stalled:
- std->err = USB_ERR_STALLED;
+ err = USB_ERR_STALLED;
tr_valid:
done:
- return;
+ *plength = len;
+ *pptr = ptr;
+ return (err);
}
static void
Modified: head/sys/dev/usb/controller/ehci.c
==============================================================================
--- head/sys/dev/usb/controller/ehci.c Wed Apr 22 17:08:13 2009 (r191401)
+++ head/sys/dev/usb/controller/ehci.c Wed Apr 22 17:08:16 2009 (r191402)
@@ -2987,35 +2987,39 @@ ehci_disown(ehci_softc_t *sc, uint16_t i
EOWRITE4(sc, port, v | EHCI_PS_PO);
}
-static void
-ehci_roothub_exec(struct usb2_bus *bus)
+static usb2_error_t
+ehci_roothub_exec(struct usb2_device *udev,
+ struct usb2_device_request *req, const void **pptr, uint16_t *plength)
{
- ehci_softc_t *sc = EHCI_BUS2SC(bus);
- struct usb2_sw_transfer *std = &sc->sc_bus.roothub_req;
- char *ptr;
+ ehci_softc_t *sc = EHCI_BUS2SC(udev->bus);
+ const char *str_ptr;
+ const void *ptr;
uint32_t port;
uint32_t v;
+ uint16_t len;
uint16_t i;
uint16_t value;
uint16_t index;
uint8_t l;
+ usb2_error_t err;
USB_BUS_LOCK_ASSERT(&sc->sc_bus, MA_OWNED);
/* buffer reset */
- std->ptr = sc->sc_hub_desc.temp;
- std->len = 0;
+ ptr = (const void *)&sc->sc_hub_desc;
+ len = 0;
+ err = 0;
- value = UGETW(std->req.wValue);
- index = UGETW(std->req.wIndex);
+ value = UGETW(req->wValue);
+ index = UGETW(req->wIndex);
DPRINTFN(3, "type=0x%02x request=0x%02x wLen=0x%04x "
"wValue=0x%04x wIndex=0x%04x\n",
- std->req.bmRequestType, std->req.bRequest,
- UGETW(std->req.wLength), value, index);
+ req->bmRequestType, req->bRequest,
+ UGETW(req->wLength), value, index);
#define C(x,y) ((x) | ((y) << 8))
- switch (C(std->req.bRequest, std->req.bmRequestType)) {
+ switch (C(req->bRequest, req->bmRequestType)) {
case C(UR_CLEAR_FEATURE, UT_WRITE_DEVICE):
case C(UR_CLEAR_FEATURE, UT_WRITE_INTERFACE):
case C(UR_CLEAR_FEATURE, UT_WRITE_ENDPOINT):
@@ -3025,18 +3029,18 @@ ehci_roothub_exec(struct usb2_bus *bus)
*/
break;
case C(UR_GET_CONFIG, UT_READ_DEVICE):
- std->len = 1;
+ len = 1;
sc->sc_hub_desc.temp[0] = sc->sc_conf;
break;
case C(UR_GET_DESCRIPTOR, UT_READ_DEVICE):
switch (value >> 8) {
case UDESC_DEVICE:
if ((value & 0xff) != 0) {
- std->err = USB_ERR_IOERROR;
+ err = USB_ERR_IOERROR;
goto done;
}
- std->len = sizeof(ehci_devd);
- sc->sc_hub_desc.devd = ehci_devd;
+ len = sizeof(ehci_devd);
+ ptr = (const void *)&ehci_devd;
break;
/*
* We can't really operate at another speed,
@@ -3045,74 +3049,74 @@ ehci_roothub_exec(struct usb2_bus *bus)
*/
case UDESC_DEVICE_QUALIFIER:
if ((value & 0xff) != 0) {
- std->err = USB_ERR_IOERROR;
+ err = USB_ERR_IOERROR;
goto done;
}
- std->len = sizeof(ehci_odevd);
- sc->sc_hub_desc.odevd = ehci_odevd;
+ len = sizeof(ehci_odevd);
+ ptr = (const void *)&ehci_odevd;
break;
case UDESC_CONFIG:
if ((value & 0xff) != 0) {
- std->err = USB_ERR_IOERROR;
+ err = USB_ERR_IOERROR;
goto done;
}
- std->len = sizeof(ehci_confd);
- std->ptr = USB_ADD_BYTES(&ehci_confd, 0);
+ len = sizeof(ehci_confd);
+ ptr = (const void *)&ehci_confd;
break;
case UDESC_STRING:
switch (value & 0xff) {
case 0: /* Language table */
- ptr = "\001";
+ str_ptr = "\001";
break;
case 1: /* Vendor */
- ptr = sc->sc_vendor;
+ str_ptr = sc->sc_vendor;
break;
case 2: /* Product */
- ptr = "EHCI root HUB";
+ str_ptr = "EHCI root HUB";
break;
default:
- ptr = "";
+ str_ptr = "";
break;
}
- std->len = usb2_make_str_desc
- (sc->sc_hub_desc.temp,
+ len = usb2_make_str_desc(
+ sc->sc_hub_desc.temp,
sizeof(sc->sc_hub_desc.temp),
- ptr);
+ str_ptr);
break;
default:
- std->err = USB_ERR_IOERROR;
+ err = USB_ERR_IOERROR;
goto done;
}
break;
case C(UR_GET_INTERFACE, UT_READ_INTERFACE):
- std->len = 1;
+ len = 1;
sc->sc_hub_desc.temp[0] = 0;
break;
case C(UR_GET_STATUS, UT_READ_DEVICE):
- std->len = 2;
+ len = 2;
USETW(sc->sc_hub_desc.stat.wStatus, UDS_SELF_POWERED);
break;
case C(UR_GET_STATUS, UT_READ_INTERFACE):
case C(UR_GET_STATUS, UT_READ_ENDPOINT):
- std->len = 2;
+ len = 2;
USETW(sc->sc_hub_desc.stat.wStatus, 0);
break;
case C(UR_SET_ADDRESS, UT_WRITE_DEVICE):
if (value >= EHCI_MAX_DEVICES) {
- std->err = USB_ERR_IOERROR;
+ err = USB_ERR_IOERROR;
goto done;
}
sc->sc_addr = value;
break;
case C(UR_SET_CONFIG, UT_WRITE_DEVICE):
if ((value != 0) && (value != 1)) {
- std->err = USB_ERR_IOERROR;
+ err = USB_ERR_IOERROR;
goto done;
}
sc->sc_conf = value;
@@ -3122,7 +3126,7 @@ ehci_roothub_exec(struct usb2_bus *bus)
case C(UR_SET_FEATURE, UT_WRITE_DEVICE):
case C(UR_SET_FEATURE, UT_WRITE_INTERFACE):
case C(UR_SET_FEATURE, UT_WRITE_ENDPOINT):
- std->err = USB_ERR_IOERROR;
+ err = USB_ERR_IOERROR;
goto done;
case C(UR_SET_INTERFACE, UT_WRITE_INTERFACE):
break;
@@ -3136,7 +3140,7 @@ ehci_roothub_exec(struct usb2_bus *bus)
if ((index < 1) ||
(index > sc->sc_noport)) {
- std->err = USB_ERR_IOERROR;
+ err = USB_ERR_IOERROR;
goto done;
}
port = EHCI_PORTSC(index);
@@ -3191,13 +3195,13 @@ ehci_roothub_exec(struct usb2_bus *bus)
sc->sc_isreset = 0;
break;
default:
- std->err = USB_ERR_IOERROR;
+ err = USB_ERR_IOERROR;
goto done;
}
break;
case C(UR_GET_DESCRIPTOR, UT_READ_CLASS_DEVICE):
if ((value & 0xff) != 0) {
- std->err = USB_ERR_IOERROR;
+ err = USB_ERR_IOERROR;
goto done;
}
v = EOREAD4(sc, EHCI_HCSPARAMS);
@@ -3216,10 +3220,10 @@ ehci_roothub_exec(struct usb2_bus *bus)
}
sc->sc_hub_desc.hubd.bDescLength =
8 + ((sc->sc_noport + 7) / 8);
- std->len = sc->sc_hub_desc.hubd.bDescLength;
+ len = sc->sc_hub_desc.hubd.bDescLength;
break;
case C(UR_GET_STATUS, UT_READ_CLASS_DEVICE):
- std->len = 16;
+ len = 16;
bzero(sc->sc_hub_desc.temp, 16);
break;
case C(UR_GET_STATUS, UT_READ_CLASS_OTHER):
@@ -3227,7 +3231,7 @@ ehci_roothub_exec(struct usb2_bus *bus)
index);
if ((index < 1) ||
(index > sc->sc_noport)) {
- std->err = USB_ERR_IOERROR;
+ err = USB_ERR_IOERROR;
goto done;
}
v = EOREAD4(sc, EHCI_PORTSC(index));
@@ -3267,17 +3271,17 @@ ehci_roothub_exec(struct usb2_bus *bus)
if (sc->sc_isreset)
i |= UPS_C_PORT_RESET;
USETW(sc->sc_hub_desc.ps.wPortChange, i);
- std->len = sizeof(sc->sc_hub_desc.ps);
+ len = sizeof(sc->sc_hub_desc.ps);
break;
case C(UR_SET_DESCRIPTOR, UT_WRITE_CLASS_DEVICE):
- std->err = USB_ERR_IOERROR;
+ err = USB_ERR_IOERROR;
goto done;
case C(UR_SET_FEATURE, UT_WRITE_CLASS_DEVICE):
break;
case C(UR_SET_FEATURE, UT_WRITE_CLASS_OTHER):
if ((index < 1) ||
(index > sc->sc_noport)) {
- std->err = USB_ERR_IOERROR;
+ err = USB_ERR_IOERROR;
goto done;
}
port = EHCI_PORTSC(index);
@@ -3328,7 +3332,7 @@ ehci_roothub_exec(struct usb2_bus *bus)
if (v & EHCI_PS_PR) {
device_printf(sc->sc_bus.bdev,
"port reset timeout\n");
- std->err = USB_ERR_TIMEOUT;
+ err = USB_ERR_TIMEOUT;
goto done;
}
if (!(v & EHCI_PS_PE) &&
@@ -3357,7 +3361,7 @@ ehci_roothub_exec(struct usb2_bus *bus)
break;
default:
- std->err = USB_ERR_IOERROR;
+ err = USB_ERR_IOERROR;
goto done;
}
break;
@@ -3367,11 +3371,13 @@ ehci_roothub_exec(struct usb2_bus *bus)
case C(UR_STOP_TT, UT_WRITE_CLASS_OTHER):
break;
default:
- std->err = USB_ERR_IOERROR;
+ err = USB_ERR_IOERROR;
goto done;
}
done:
- return;
+ *plength = len;
+ *pptr = ptr;
+ return (err);
}
static void
Modified: head/sys/dev/usb/controller/ehci.h
==============================================================================
--- head/sys/dev/usb/controller/ehci.h Wed Apr 22 17:08:13 2009 (r191401)
+++ head/sys/dev/usb/controller/ehci.h Wed Apr 22 17:08:16 2009 (r191402)
@@ -446,8 +446,6 @@ struct ehci_config_desc {
union ehci_hub_desc {
struct usb2_status stat;
struct usb2_port_status ps;
- struct usb2_device_descriptor devd;
- struct usb2_device_qualifier odevd;
struct usb2_hub_descriptor hubd;
uint8_t temp[128];
};
Modified: head/sys/dev/usb/controller/musb_otg.c
==============================================================================
--- head/sys/dev/usb/controller/musb_otg.c Wed Apr 22 17:08:13 2009 (r191401)
+++ head/sys/dev/usb/controller/musb_otg.c Wed Apr 22 17:08:16 2009 (r191402)
@@ -2152,28 +2152,32 @@ USB_MAKE_STRING_DESC(STRING_LANG, musbot
USB_MAKE_STRING_DESC(STRING_VENDOR, musbotg_vendor);
USB_MAKE_STRING_DESC(STRING_PRODUCT, musbotg_product);
-static void
-musbotg_roothub_exec(struct usb2_bus *bus)
+static usb2_error_t
+musbotg_roothub_exec(struct usb2_device *udev,
+ struct usb2_device_request *req, const void **pptr, uint16_t *plength)
{
- struct musbotg_softc *sc = MUSBOTG_BUS2SC(bus);
- struct usb2_sw_transfer *std = &sc->sc_bus.roothub_req;
+ struct musbotg_softc *sc = MUSBOTG_BUS2SC(udev->bus);
+ const void *ptr;
+ uint16_t len;
uint16_t value;
uint16_t index;
+ usb2_error_t err;
USB_BUS_LOCK_ASSERT(&sc->sc_bus, MA_OWNED);
/* buffer reset */
- std->ptr = USB_ADD_BYTES(&sc->sc_hub_temp, 0);
- std->len = 0;
+ ptr = (const void *)&sc->sc_hub_temp;
+ len = 0;
+ err = 0;
- value = UGETW(std->req.wValue);
- index = UGETW(std->req.wIndex);
+ value = UGETW(req->wValue);
+ index = UGETW(req->wIndex);
/* demultiplex the control request */
- switch (std->req.bmRequestType) {
+ switch (req->bmRequestType) {
case UT_READ_DEVICE:
- switch (std->req.bRequest) {
+ switch (req->bRequest) {
case UR_GET_DESCRIPTOR:
goto tr_handle_get_descriptor;
case UR_GET_CONFIG:
@@ -2186,7 +2190,7 @@ musbotg_roothub_exec(struct usb2_bus *bu
break;
case UT_WRITE_DEVICE:
- switch (std->req.bRequest) {
+ switch (req->bRequest) {
case UR_SET_ADDRESS:
goto tr_handle_set_address;
case UR_SET_CONFIG:
@@ -2202,9 +2206,9 @@ musbotg_roothub_exec(struct usb2_bus *bu
break;
case UT_WRITE_ENDPOINT:
- switch (std->req.bRequest) {
+ switch (req->bRequest) {
case UR_CLEAR_FEATURE:
- switch (UGETW(std->req.wValue)) {
+ switch (UGETW(req->wValue)) {
case UF_ENDPOINT_HALT:
goto tr_handle_clear_halt;
case UF_DEVICE_REMOTE_WAKEUP:
@@ -2214,7 +2218,7 @@ musbotg_roothub_exec(struct usb2_bus *bu
}
break;
case UR_SET_FEATURE:
- switch (UGETW(std->req.wValue)) {
+ switch (UGETW(req->wValue)) {
case UF_ENDPOINT_HALT:
goto tr_handle_set_halt;
case UF_DEVICE_REMOTE_WAKEUP:
@@ -2231,7 +2235,7 @@ musbotg_roothub_exec(struct usb2_bus *bu
break;
case UT_READ_ENDPOINT:
- switch (std->req.bRequest) {
+ switch (req->bRequest) {
case UR_GET_STATUS:
goto tr_handle_get_ep_status;
default:
@@ -2240,7 +2244,7 @@ musbotg_roothub_exec(struct usb2_bus *bu
break;
case UT_WRITE_INTERFACE:
- switch (std->req.bRequest) {
+ switch (req->bRequest) {
case UR_SET_INTERFACE:
goto tr_handle_set_interface;
case UR_CLEAR_FEATURE:
@@ -2252,7 +2256,7 @@ musbotg_roothub_exec(struct usb2_bus *bu
break;
case UT_READ_INTERFACE:
- switch (std->req.bRequest) {
+ switch (req->bRequest) {
case UR_GET_INTERFACE:
goto tr_handle_get_interface;
case UR_GET_STATUS:
@@ -2273,7 +2277,7 @@ musbotg_roothub_exec(struct usb2_bus *bu
break;
case UT_WRITE_CLASS_DEVICE:
- switch (std->req.bRequest) {
+ switch (req->bRequest) {
case UR_CLEAR_FEATURE:
goto tr_valid;
case UR_SET_DESCRIPTOR:
@@ -2285,7 +2289,7 @@ musbotg_roothub_exec(struct usb2_bus *bu
break;
case UT_WRITE_CLASS_OTHER:
- switch (std->req.bRequest) {
+ switch (req->bRequest) {
case UR_CLEAR_FEATURE:
goto tr_handle_clear_port_feature;
case UR_SET_FEATURE:
@@ -2301,7 +2305,7 @@ musbotg_roothub_exec(struct usb2_bus *bu
break;
case UT_READ_CLASS_OTHER:
- switch (std->req.bRequest) {
+ switch (req->bRequest) {
case UR_GET_TT_STATE:
goto tr_handle_get_tt_state;
case UR_GET_STATUS:
@@ -2312,7 +2316,7 @@ musbotg_roothub_exec(struct usb2_bus *bu
break;
case UT_READ_CLASS_DEVICE:
- switch (std->req.bRequest) {
+ switch (req->bRequest) {
case UR_GET_DESCRIPTOR:
goto tr_handle_get_class_descriptor;
case UR_GET_STATUS:
@@ -2333,31 +2337,31 @@ tr_handle_get_descriptor:
if (value & 0xff) {
goto tr_stalled;
}
- std->len = sizeof(musbotg_devd);
- std->ptr = USB_ADD_BYTES(&musbotg_devd, 0);
+ len = sizeof(musbotg_devd);
+ ptr = (const void *)&musbotg_devd;
goto tr_valid;
case UDESC_CONFIG:
if (value & 0xff) {
goto tr_stalled;
}
- std->len = sizeof(musbotg_confd);
- std->ptr = USB_ADD_BYTES(&musbotg_confd, 0);
+ len = sizeof(musbotg_confd);
+ ptr = (const void *)&musbotg_confd;
goto tr_valid;
case UDESC_STRING:
switch (value & 0xff) {
case 0: /* Language table */
- std->len = sizeof(musbotg_langtab);
- std->ptr = USB_ADD_BYTES(&musbotg_langtab, 0);
+ len = sizeof(musbotg_langtab);
+ ptr = (const void *)&musbotg_langtab;
goto tr_valid;
case 1: /* Vendor */
- std->len = sizeof(musbotg_vendor);
- std->ptr = USB_ADD_BYTES(&musbotg_vendor, 0);
+ len = sizeof(musbotg_vendor);
+ ptr = (const void *)&musbotg_vendor;
goto tr_valid;
case 2: /* Product */
- std->len = sizeof(musbotg_product);
- std->ptr = USB_ADD_BYTES(&musbotg_product, 0);
+ len = sizeof(musbotg_product);
+ ptr = (const void *)&musbotg_product;
goto tr_valid;
default:
break;
@@ -2369,12 +2373,12 @@ tr_handle_get_descriptor:
goto tr_stalled;
tr_handle_get_config:
*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
More information about the svn-src-head
mailing list