diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2014-12-31 02:07:37 -0500 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2015-01-07 10:13:46 -0500 |
commit | b33e31d17b42eaaccbf3a3b4a6f6e0ef49152ae2 (patch) | |
tree | 4b3b27a224e7d5ade6c646550a60a512c6b29610 /src/hw/usb-xhci.c | |
parent | eb9f3ae5e652d24ff36f45dda80b013417f81f23 (diff) | |
download | seabios-b33e31d17b42eaaccbf3a3b4a6f6e0ef49152ae2.tar.gz |
xhci: Merge xhci_send_control with xhci_send_bulk
Merge both the control and bulk pipe sending functions into one new
function: xhci_send_pipe(). This makes the xhci interface similar to
the other usb drivers.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'src/hw/usb-xhci.c')
-rw-r--r-- | src/hw/usb-xhci.c | 45 |
1 files changed, 15 insertions, 30 deletions
diff --git a/src/hw/usb-xhci.c b/src/hw/usb-xhci.c index d6caa77b..6c7fc134 100644 --- a/src/hw/usb-xhci.c +++ b/src/hw/usb-xhci.c @@ -1117,50 +1117,35 @@ xhci_realloc_pipe(struct usbdevice_s *usbdev, struct usb_pipe *upipe } int -xhci_send_control(struct usb_pipe *p, int dir, const void *cmd, int cmdsize - , void *data, int datalen) +xhci_send_pipe(struct usb_pipe *p, int dir, const void *cmd, int cmdsize + , void *data, int datalen) { if (!CONFIG_USB_XHCI) return -1; - const struct usb_ctrlrequest *req = cmd; struct xhci_pipe *pipe = container_of(p, struct xhci_pipe, pipe); struct usb_xhci_s *xhci = container_of( pipe->pipe.cntl, struct usb_xhci_s, usb); - if (req->bRequest == USB_REQ_SET_ADDRESS) - // Set address command sent during xhci_alloc_pipe. - return 0; - - xhci_xfer_setup(pipe, req, dir, datalen); - if (datalen) - xhci_xfer_data(pipe, dir, data, datalen); - xhci_xfer_status(pipe, dir, datalen); + if (cmd) { + const struct usb_ctrlrequest *req = cmd; + if (req->bRequest == USB_REQ_SET_ADDRESS) + // Set address command sent during xhci_alloc_pipe. + return 0; - int cc = xhci_event_wait(xhci, &pipe->reqs, usb_xfer_time(p, datalen)); - if (cc != CC_SUCCESS) { - dprintf(1, "%s: control xfer failed (cc %d)\n", __func__, cc); - return -1; + xhci_xfer_setup(pipe, req, dir, datalen); + if (datalen) + xhci_xfer_data(pipe, dir, data, datalen); + xhci_xfer_status(pipe, dir, datalen); + } else { + xhci_xfer_normal(pipe, data, datalen); } - return 0; -} - -int -xhci_send_bulk(struct usb_pipe *p, int dir, void *data, int datalen) -{ - if (!CONFIG_USB_XHCI) - return -1; - - struct xhci_pipe *pipe = container_of(p, struct xhci_pipe, pipe); - struct usb_xhci_s *xhci = container_of( - pipe->pipe.cntl, struct usb_xhci_s, usb); - - xhci_xfer_normal(pipe, data, datalen); int cc = xhci_event_wait(xhci, &pipe->reqs, usb_xfer_time(p, datalen)); if (cc != CC_SUCCESS) { - dprintf(1, "%s: bulk xfer failed (cc %d)\n", __func__, cc); + dprintf(1, "%s: xfer failed (cc %d)\n", __func__, cc); return -1; } + return 0; } |