]> xenbits.xensource.com Git - seabios.git/commitdiff
xhci: Merge xhci_send_control with xhci_send_bulk
authorKevin O'Connor <kevin@koconnor.net>
Wed, 31 Dec 2014 07:07:37 +0000 (02:07 -0500)
committerKevin O'Connor <kevin@koconnor.net>
Wed, 7 Jan 2015 15:13:46 +0000 (10:13 -0500)
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>
src/hw/usb-xhci.c
src/hw/usb-xhci.h
src/hw/usb.c

index d6caa77bd987396d55005862731da02a8aa265b6..6c7fc1345e35c4a5ca651f875eeb8d19b8971d50 100644 (file)
@@ -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;
 }
 
index 807d59752ff9f2949db343ccef1d65de8f7d7891..fc1bf7f0c057f55701bc5fb60061ea8b16c0d6cf 100644 (file)
@@ -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);
 
 // --------------------------------------------------------------
index 053440cc238a115c8f96479697837485c9eeb113..a262a98e174a071b9d7a355b6b0b1e496f057a70 100644 (file)
@@ -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);
     }
 }