]> xenbits.xensource.com Git - seabios.git/commitdiff
usb: Control transfers always have an 8 byte command size
authorKevin O'Connor <kevin@koconnor.net>
Wed, 31 Dec 2014 22:41:14 +0000 (17:41 -0500)
committerKevin O'Connor <kevin@koconnor.net>
Wed, 7 Jan 2015 15:13:46 +0000 (10:13 -0500)
There is no need to pass 'cmdsize' to the usb drivers as the cmdsize
is always 8 bytes.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
src/hw/usb-ehci.c
src/hw/usb-ehci.h
src/hw/usb-ohci.c
src/hw/usb-ohci.h
src/hw/usb-uhci.c
src/hw/usb-uhci.h
src/hw/usb-xhci.c
src/hw/usb-xhci.h
src/hw/usb.c
src/hw/usb.h

index a7383166dfdf0fdf65d05edf19fc8b77cef67e99..41f8579ce922a164395460b70fe36ac4885d10ac 100644 (file)
@@ -542,7 +542,7 @@ ehci_fill_tdbuf(struct ehci_qtd *td, u32 dest, int transfer)
 #define STACKQTDS 6
 
 int
-ehci_send_pipe(struct usb_pipe *p, int dir, const void *cmd, int cmdsize
+ehci_send_pipe(struct usb_pipe *p, int dir, const void *cmd
                , void *data, int datasize)
 {
     if (! CONFIG_USB_EHCI)
@@ -563,9 +563,9 @@ ehci_send_pipe(struct usb_pipe *p, int dir, const void *cmd, int cmdsize
         // Send setup pid on control transfers
         td->qtd_next = (u32)MAKE_FLATPTR(GET_SEG(SS), td+1);
         td->alt_next = EHCI_PTR_TERM;
-        td->token = (ehci_explen(cmdsize) | QTD_STS_ACTIVE
+        td->token = (ehci_explen(USB_CONTROL_SETUP_SIZE) | QTD_STS_ACTIVE
                      | QTD_PID_SETUP | ehci_maxerr(3));
-        ehci_fill_tdbuf(td, (u32)cmd, cmdsize);
+        ehci_fill_tdbuf(td, (u32)cmd, USB_CONTROL_SETUP_SIZE);
         td++;
         toggle = QTD_TOGGLE;
     }
index 08ae0462f69a0f9f822301ace2349670fe811f5e..88f7b6a1e95cd77b4c82521b9be7521bbf257f48 100644 (file)
@@ -9,7 +9,7 @@ struct usb_pipe;
 struct usb_pipe *ehci_realloc_pipe(struct usbdevice_s *usbdev
                                    , struct usb_pipe *upipe
                                    , struct usb_endpoint_descriptor *epdesc);
-int ehci_send_pipe(struct usb_pipe *p, int dir, const void *cmd, int cmdsize
+int ehci_send_pipe(struct usb_pipe *p, int dir, const void *cmd
                    , void *data, int datasize);
 int ehci_poll_intr(struct usb_pipe *p, void *data);
 
index 11fe9fadbe3d88cf41e8b5ed5b4038808f089624..42f8a0681c77673f959ae500133f18b41277be5d 100644 (file)
@@ -459,7 +459,7 @@ wait_ed(struct ohci_ed *ed, int timeout)
 #define OHCI_TD_ALIGN 16
 
 int
-ohci_send_pipe(struct usb_pipe *p, int dir, const void *cmd, int cmdsize
+ohci_send_pipe(struct usb_pipe *p, int dir, const void *cmd
                , void *data, int datasize)
 {
     ASSERT32FLAT();
@@ -481,7 +481,7 @@ ohci_send_pipe(struct usb_pipe *p, int dir, const void *cmd, int cmdsize
         td->hwINFO = TD_DP_SETUP | TD_T_DATA0 | TD_CC;
         td->hwCBP = (u32)cmd;
         td->hwNextTD = (u32)&td[1];
-        td->hwBE = (u32)cmd + cmdsize - 1;
+        td->hwBE = (u32)cmd + USB_CONTROL_SETUP_SIZE - 1;
         td++;
         toggle = TD_T_DATA1;
         statuscmd = OHCI_CLF;
index 3dbc0e098fea6e1cc62941d22e93c71b342428ef..5a275a3348d076091834381be8b5dbe2de2e2c40 100644 (file)
@@ -9,7 +9,7 @@ struct usb_pipe;
 struct usb_pipe *ohci_realloc_pipe(struct usbdevice_s *usbdev
                                    , struct usb_pipe *upipe
                                    , struct usb_endpoint_descriptor *epdesc);
-int ohci_send_pipe(struct usb_pipe *p, int dir, const void *cmd, int cmdsize
+int ohci_send_pipe(struct usb_pipe *p, int dir, const void *cmd
                    , void *data, int datasize);
 int ohci_poll_intr(struct usb_pipe *p, void *data);
 
index 890b7d6e049239b1690979a677262f6dbd2604ed..69c33ee3bda87ec342f2e832adb8b6dbf28a2e16 100644 (file)
@@ -447,7 +447,7 @@ wait_td(struct uhci_td *td, u32 end)
 #define TDALIGN 16
 
 int
-uhci_send_pipe(struct usb_pipe *p, int dir, const void *cmd, int cmdsize
+uhci_send_pipe(struct usb_pipe *p, int dir, const void *cmd
                , void *data, int datasize)
 {
     if (! CONFIG_USB_UHCI)
@@ -478,8 +478,8 @@ uhci_send_pipe(struct usb_pipe *p, int dir, const void *cmd, int cmdsize
         struct uhci_td *td = &tds[tdpos++ % STACKTDS];
         u32 nexttd = (u32)MAKE_FLATPTR(GET_SEG(SS), &tds[tdpos % STACKTDS]);
         td->link = nexttd | UHCI_PTR_DEPTH;
-        td->token = (uhci_explen(cmdsize) | (devaddr << TD_TOKEN_DEVADDR_SHIFT)
-                     | USB_PID_SETUP);
+        td->token = (uhci_explen(USB_CONTROL_SETUP_SIZE)
+                     | (devaddr << TD_TOKEN_DEVADDR_SHIFT) | USB_PID_SETUP);
         td->buffer = (void*)cmd;
         barrier();
         td->status = (uhci_maxerr(3) | (lowspeed ? TD_CTRL_LS : 0)
index c5ba43db215cd2fe4979d89b1f50d60054b3c157..bff70c667775cf92406d41c3cea7341177eb8d36 100644 (file)
@@ -9,7 +9,7 @@ struct usb_pipe;
 struct usb_pipe *uhci_realloc_pipe(struct usbdevice_s *usbdev
                                    , struct usb_pipe *upipe
                                    , struct usb_endpoint_descriptor *epdesc);
-int uhci_send_pipe(struct usb_pipe *p, int dir, const void *cmd, int cmdsize
+int uhci_send_pipe(struct usb_pipe *p, int dir, const void *cmd
                    , void *data, int datasize);
 int uhci_poll_intr(struct usb_pipe *p, void *data);
 
index bacae11d5bf2855519e3303aa779b7f398b9bc95..fd58334dc94b050e0aa23471beee2137a0d70af9 100644 (file)
@@ -1069,7 +1069,7 @@ static void xhci_xfer_normal(struct xhci_pipe *pipe,
 }
 
 int
-xhci_send_pipe(struct usb_pipe *p, int dir, const void *cmd, int cmdsize
+xhci_send_pipe(struct usb_pipe *p, int dir, const void *cmd
                , void *data, int datalen)
 {
     if (!CONFIG_USB_XHCI)
@@ -1084,7 +1084,8 @@ xhci_send_pipe(struct usb_pipe *p, int dir, const void *cmd, int cmdsize
             // Set address command sent during xhci_alloc_pipe.
             return 0;
 
-        xhci_xfer_queue(pipe, (void*)req, 8, (TR_SETUP << 10) | TRB_TR_IDT
+        xhci_xfer_queue(pipe, (void*)req, USB_CONTROL_SETUP_SIZE
+                        , (TR_SETUP << 10) | TRB_TR_IDT
                         | ((datalen ? (dir ? 3 : 2) : 0) << 16));
         if (datalen)
             xhci_xfer_queue(pipe, data, datalen, (TR_DATA << 10)
index fc1bf7f0c057f55701bc5fb60061ea8b16c0d6cf..c768c5b58fbb5083818ede7b18c69b555731fa5c 100644 (file)
@@ -12,7 +12,7 @@ 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_pipe(struct usb_pipe *p, int dir, const void *cmd, int cmdsize
+int xhci_send_pipe(struct usb_pipe *p, int dir, const void *cmd
                    , void *data, int datasize);
 int xhci_poll_intr(struct usb_pipe *p, void *data);
 
index 773057ebe5fe32d547211c6153bb59f89dd9b2e1..46e17df7729896d44669e8eee8dbcd36330a2aa7 100644 (file)
@@ -46,23 +46,23 @@ usb_realloc_pipe(struct usbdevice_s *usbdev, struct usb_pipe *pipe
 
 // Send a message on a control pipe using the default control descriptor.
 static int
-usb_send_pipe(struct usb_pipe *pipe_fl, int dir, const void *cmd, int cmdsize
+usb_send_pipe(struct usb_pipe *pipe_fl, int dir, const void *cmd
               , void *data, int datasize)
 {
     switch (GET_LOWFLAT(pipe_fl->type)) {
     default:
     case USB_TYPE_UHCI:
-        return uhci_send_pipe(pipe_fl, dir, cmd, cmdsize, data, datasize);
+        return uhci_send_pipe(pipe_fl, dir, cmd, data, datasize);
     case USB_TYPE_OHCI:
         if (MODESEGMENT)
             return -1;
-        return ohci_send_pipe(pipe_fl, dir, cmd, cmdsize, data, datasize);
+        return ohci_send_pipe(pipe_fl, dir, cmd, data, datasize);
     case USB_TYPE_EHCI:
-        return ehci_send_pipe(pipe_fl, dir, cmd, cmdsize, data, datasize);
+        return ehci_send_pipe(pipe_fl, dir, cmd, data, datasize);
     case USB_TYPE_XHCI:
         if (MODESEGMENT)
             return -1;
-        return xhci_send_pipe(pipe_fl, dir, cmd, cmdsize, data, datasize);
+        return xhci_send_pipe(pipe_fl, dir, cmd, data, datasize);
     }
 }
 
@@ -118,15 +118,15 @@ int
 usb_send_default_control(struct usb_pipe *pipe, const struct usb_ctrlrequest *req
                          , void *data)
 {
-    return usb_send_pipe(pipe, req->bRequestType & USB_DIR_IN
-                         , req, sizeof(*req), data, req->wLength);
+    return usb_send_pipe(pipe, req->bRequestType & USB_DIR_IN, req
+                         , data, req->wLength);
 }
 
 // Send a message to a bulk endpoint
 int
 usb_send_bulk(struct usb_pipe *pipe_fl, int dir, void *data, int datasize)
 {
-    return usb_send_pipe(pipe_fl, dir, NULL, 0, data, datasize);
+    return usb_send_pipe(pipe_fl, dir, NULL, data, datasize);
 }
 
 // Check if a pipe for a given controller is on the freelist
index 208d08f593292067a07fa92ca37c3c1b383e3b1f..efb5e6f9ccf44c7da9842254b2dff98338f0d4d5 100644 (file)
@@ -211,6 +211,8 @@ struct usb_endpoint_descriptor {
 #define USB_ENDPOINT_XFER_INT           3
 #define USB_ENDPOINT_MAX_ADJUSTABLE     0x80
 
+#define USB_CONTROL_SETUP_SIZE          8
+
 
 /****************************************************************
  * usb mass storage flags