summaryrefslogtreecommitdiffstats
path: root/sys/dev/usb/controller/uss820dci.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev/usb/controller/uss820dci.c')
-rw-r--r--sys/dev/usb/controller/uss820dci.c90
1 files changed, 48 insertions, 42 deletions
diff --git a/sys/dev/usb/controller/uss820dci.c b/sys/dev/usb/controller/uss820dci.c
index 9582869..e319425 100644
--- a/sys/dev/usb/controller/uss820dci.c
+++ b/sys/dev/usb/controller/uss820dci.c
@@ -1788,28 +1788,32 @@ USB_MAKE_STRING_DESC(STRING_LANG, uss820dci_langtab);
USB_MAKE_STRING_DESC(STRING_VENDOR, uss820dci_vendor);
USB_MAKE_STRING_DESC(STRING_PRODUCT, uss820dci_product);
-static void
-uss820dci_roothub_exec(struct usb2_bus *bus)
+static usb2_error_t
+uss820dci_roothub_exec(struct usb2_device *udev,
+ struct usb2_device_request *req, const void **pptr, uint16_t *plength)
{
- struct uss820dci_softc *sc = USS820_DCI_BUS2SC(bus);
- struct usb2_sw_transfer *std = &sc->sc_bus.roothub_req;
+ struct uss820dci_softc *sc = USS820_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:
@@ -1822,7 +1826,7 @@ uss820dci_roothub_exec(struct usb2_bus *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:
@@ -1838,9 +1842,9 @@ uss820dci_roothub_exec(struct usb2_bus *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:
@@ -1850,7 +1854,7 @@ uss820dci_roothub_exec(struct usb2_bus *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:
@@ -1867,7 +1871,7 @@ uss820dci_roothub_exec(struct usb2_bus *bus)
break;
case UT_READ_ENDPOINT:
- switch (std->req.bRequest) {
+ switch (req->bRequest) {
case UR_GET_STATUS:
goto tr_handle_get_ep_status;
default:
@@ -1876,7 +1880,7 @@ uss820dci_roothub_exec(struct usb2_bus *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:
@@ -1888,7 +1892,7 @@ uss820dci_roothub_exec(struct usb2_bus *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:
@@ -1909,7 +1913,7 @@ uss820dci_roothub_exec(struct usb2_bus *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:
@@ -1921,7 +1925,7 @@ uss820dci_roothub_exec(struct usb2_bus *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:
@@ -1937,7 +1941,7 @@ uss820dci_roothub_exec(struct usb2_bus *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:
@@ -1948,7 +1952,7 @@ uss820dci_roothub_exec(struct usb2_bus *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:
@@ -1969,31 +1973,31 @@ tr_handle_get_descriptor:
if (value & 0xff) {
goto tr_stalled;
}
- std->len = sizeof(uss820dci_devd);
- std->ptr = USB_ADD_BYTES(&uss820dci_devd, 0);
+ len = sizeof(uss820dci_devd);
+ ptr = (const void *)&uss820dci_devd;
goto tr_valid;
case UDESC_CONFIG:
if (value & 0xff) {
goto tr_stalled;
}
- std->len = sizeof(uss820dci_confd);
- std->ptr = USB_ADD_BYTES(&uss820dci_confd, 0);
+ len = sizeof(uss820dci_confd);
+ ptr = (const void *)&uss820dci_confd;
goto tr_valid;
case UDESC_STRING:
switch (value & 0xff) {
case 0: /* Language table */
- std->len = sizeof(uss820dci_langtab);
- std->ptr = USB_ADD_BYTES(&uss820dci_langtab, 0);
+ len = sizeof(uss820dci_langtab);
+ ptr = (const void *)&uss820dci_langtab;
goto tr_valid;
case 1: /* Vendor */
- std->len = sizeof(uss820dci_vendor);
- std->ptr = USB_ADD_BYTES(&uss820dci_vendor, 0);
+ len = sizeof(uss820dci_vendor);
+ ptr = (const void *)&uss820dci_vendor;
goto tr_valid;
case 2: /* Product */
- std->len = sizeof(uss820dci_product);
- std->ptr = USB_ADD_BYTES(&uss820dci_product, 0);
+ len = sizeof(uss820dci_product);
+ ptr = (const void *)&uss820dci_product;
goto tr_valid;
default:
break;
@@ -2005,12 +2009,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;
@@ -2029,7 +2033,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;
@@ -2037,7 +2041,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;
@@ -2081,7 +2085,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;
@@ -2106,7 +2110,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;
@@ -2152,22 +2156,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(&uss820dci_hubd, 0);
- std->len = sizeof(uss820dci_hubd);
+ ptr = (const void *)&uss820dci_hubd;
+ len = sizeof(uss820dci_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
OpenPOWER on IntegriCloud