summaryrefslogtreecommitdiffstats
path: root/sys/dev/usb/controller/ohci.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev/usb/controller/ohci.c')
-rw-r--r--sys/dev/usb/controller/ohci.c98
1 files changed, 52 insertions, 46 deletions
diff --git a/sys/dev/usb/controller/ohci.c b/sys/dev/usb/controller/ohci.c
index fc05ece..eb98ff3 100644
--- a/sys/dev/usb/controller/ohci.c
+++ b/sys/dev/usb/controller/ohci.c
@@ -2106,34 +2106,38 @@ struct usb2_hub_descriptor ohci_hubd =
{0},
};
-static void
-ohci_roothub_exec(struct usb2_bus *bus)
+static usb2_error_t
+ohci_roothub_exec(struct usb2_device *udev,
+ struct usb2_device_request *req, const void **pptr, uint16_t *plength)
{
- ohci_softc_t *sc = OHCI_BUS2SC(bus);
- struct usb2_sw_transfer *std = &sc->sc_bus.roothub_req;
- char *ptr;
+ ohci_softc_t *sc = OHCI_BUS2SC(udev->bus);
+ const void *ptr;
+ const char *str_ptr;
uint32_t port;
uint32_t v;
+ uint16_t len;
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.temp;
+ 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):
@@ -2143,82 +2147,82 @@ ohci_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(ohci_devd);
- sc->sc_hub_desc.devd = ohci_devd;
+ len = sizeof(ohci_devd);
+ ptr = (const void *)&ohci_devd;
break;
case UDESC_CONFIG:
if ((value & 0xff) != 0) {
- std->err = USB_ERR_IOERROR;
+ err = USB_ERR_IOERROR;
goto done;
}
- std->len = sizeof(ohci_confd);
- std->ptr = USB_ADD_BYTES(&ohci_confd, 0);
+ len = sizeof(ohci_confd);
+ ptr = (const void *)&ohci_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 = "OHCI root HUB";
+ str_ptr = "OHCI 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 >= OHCI_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;
@@ -2228,7 +2232,7 @@ ohci_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;
@@ -2243,7 +2247,7 @@ ohci_roothub_exec(struct usb2_bus *bus)
index, value);
if ((index < 1) ||
(index > sc->sc_noport)) {
- std->err = USB_ERR_IOERROR;
+ err = USB_ERR_IOERROR;
goto done;
}
port = OHCI_RH_PORT_STATUS(index);
@@ -2274,7 +2278,7 @@ ohci_roothub_exec(struct usb2_bus *bus)
OWRITE4(sc, port, UPS_C_PORT_RESET << 16);
break;
default:
- std->err = USB_ERR_IOERROR;
+ err = USB_ERR_IOERROR;
goto done;
}
switch (value) {
@@ -2293,7 +2297,7 @@ ohci_roothub_exec(struct usb2_bus *bus)
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 = OREAD4(sc, OHCI_RH_DESCRIPTOR_A);
@@ -2316,11 +2320,11 @@ ohci_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):
@@ -2328,24 +2332,24 @@ ohci_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 = OREAD4(sc, OHCI_RH_PORT_STATUS(index));
DPRINTFN(9, "port status=0x%04x\n", v);
USETW(sc->sc_hub_desc.ps.wPortStatus, v);
USETW(sc->sc_hub_desc.ps.wPortChange, v >> 16);
- 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 = OHCI_RH_PORT_STATUS(index);
@@ -2368,7 +2372,7 @@ ohci_roothub_exec(struct usb2_bus *bus)
break;
}
} else {
- std->err = USB_ERR_TIMEOUT;
+ err = USB_ERR_TIMEOUT;
goto done;
}
}
@@ -2380,16 +2384,18 @@ ohci_roothub_exec(struct usb2_bus *bus)
OWRITE4(sc, port, UPS_PORT_POWER);
break;
default:
- std->err = USB_ERR_IOERROR;
+ err = USB_ERR_IOERROR;
goto done;
}
break;
default:
- std->err = USB_ERR_IOERROR;
+ err = USB_ERR_IOERROR;
goto done;
}
done:
- return;
+ *plength = len;
+ *pptr = ptr;
+ return (err);
}
static void
OpenPOWER on IntegriCloud