aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2014-12-31 02:07:37 -0500
committerKevin O'Connor <kevin@koconnor.net>2015-01-07 10:13:46 -0500
commitb33e31d17b42eaaccbf3a3b4a6f6e0ef49152ae2 (patch)
tree4b3b27a224e7d5ade6c646550a60a512c6b29610
parenteb9f3ae5e652d24ff36f45dda80b013417f81f23 (diff)
downloadseabios-b33e31d17b42eaaccbf3a3b4a6f6e0ef49152ae2.zip
seabios-b33e31d17b42eaaccbf3a3b4a6f6e0ef49152ae2.tar.gz
seabios-b33e31d17b42eaaccbf3a3b4a6f6e0ef49152ae2.tar.bz2
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>
-rw-r--r--src/hw/usb-xhci.c45
-rw-r--r--src/hw/usb-xhci.h5
-rw-r--r--src/hw/usb.c4
3 files changed, 19 insertions, 35 deletions
diff --git a/src/hw/usb-xhci.c b/src/hw/usb-xhci.c
index d6caa77..6c7fc13 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;
}
diff --git a/src/hw/usb-xhci.h b/src/hw/usb-xhci.h
index 807d597..fc1bf7f 100644
--- a/src/hw/usb-xhci.h
+++ b/src/hw/usb-xhci.h
@@ -12,9 +12,8 @@ void xhci_setup(void);
struct usb_pipe *xhci_realloc_pipe(struct usbdevice_s *usbdev
, struct usb_pipe *upipe
, struct usb_endpoint_descriptor *epdesc);
-int xhci_send_control(struct usb_pipe *p, int dir, const void *cmd, int cmdsize
- , void *data, int datasize);
-int xhci_send_bulk(struct usb_pipe *p, int dir, void *data, int datasize);
+int xhci_send_pipe(struct usb_pipe *p, int dir, const void *cmd, int cmdsize
+ , void *data, int datasize);
int xhci_poll_intr(struct usb_pipe *p, void *data);
// --------------------------------------------------------------
diff --git a/src/hw/usb.c b/src/hw/usb.c
index 053440c..a262a98 100644
--- a/src/hw/usb.c
+++ b/src/hw/usb.c
@@ -59,7 +59,7 @@ usb_send_control(struct usb_pipe *pipe, int dir, const void *cmd, int cmdsize
case USB_TYPE_EHCI:
return ehci_send_pipe(pipe, dir, cmd, cmdsize, data, datasize);
case USB_TYPE_XHCI:
- return xhci_send_control(pipe, dir, cmd, cmdsize, data, datasize);
+ return xhci_send_pipe(pipe, dir, cmd, cmdsize, data, datasize);
}
}
@@ -79,7 +79,7 @@ usb_send_bulk(struct usb_pipe *pipe_fl, int dir, void *data, int datasize)
case USB_TYPE_XHCI:
if (MODESEGMENT)
return -1;
- return xhci_send_bulk(pipe_fl, dir, data, datasize);
+ return xhci_send_pipe(pipe_fl, dir, NULL, 0, data, datasize);
}
}