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 | 4 ++-- src/hw/usb-ehci.h | 2 +- src/hw/usb-ohci.c | 4 ++-- src/hw/usb-ohci.h | 2 +- src/hw/usb-uhci.c | 6 +++--- src/hw/usb-uhci.h | 2 +- src/hw/usb-xhci.c | 5 +++-- src/hw/usb-xhci.h | 2 +- src/hw/usb.c | 16 ++++++++-------- src/hw/usb.h | 2 ++ 10 files changed, 24 insertions(+), 21 deletions(-)
diff --git a/src/hw/usb-ehci.c b/src/hw/usb-ehci.c index aef3945..291639e 100644 --- a/src/hw/usb-ehci.c +++ b/src/hw/usb-ehci.c @@ -555,7 +555,7 @@ fillTDbuffer(struct ehci_qtd *td, u16 maxpacket, const void *buf, int bytes) #define STACKQTDS 4
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) @@ -574,7 +574,7 @@ ehci_send_pipe(struct usb_pipe *p, int dir, const void *cmd, int cmdsize u32 toggle = 0; if (cmd) { // Send setup pid on control transfers - int transfer = fillTDbuffer(td, maxpacket, cmd, cmdsize); + int transfer = fillTDbuffer(td, maxpacket, cmd, USB_CONTROL_SETUP_SIZE); td->qtd_next = (u32)MAKE_FLATPTR(GET_SEG(SS), td+1); td->alt_next = EHCI_PTR_TERM; td->token = (ehci_explen(transfer) | QTD_STS_ACTIVE diff --git a/src/hw/usb-ehci.h b/src/hw/usb-ehci.h index 08ae046..88f7b6a 100644 --- a/src/hw/usb-ehci.h +++ b/src/hw/usb-ehci.h @@ -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);
diff --git a/src/hw/usb-ohci.c b/src/hw/usb-ohci.c index fed5989..659e454 100644 --- a/src/hw/usb-ohci.c +++ b/src/hw/usb-ohci.c @@ -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; diff --git a/src/hw/usb-ohci.h b/src/hw/usb-ohci.h index 3dbc0e0..5a275a3 100644 --- a/src/hw/usb-ohci.h +++ b/src/hw/usb-ohci.h @@ -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);
diff --git a/src/hw/usb-uhci.c b/src/hw/usb-uhci.c index 890b7d6..69c33ee 100644 --- a/src/hw/usb-uhci.c +++ b/src/hw/usb-uhci.c @@ -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) diff --git a/src/hw/usb-uhci.h b/src/hw/usb-uhci.h index c5ba43d..bff70c6 100644 --- a/src/hw/usb-uhci.h +++ b/src/hw/usb-uhci.h @@ -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);
diff --git a/src/hw/usb-xhci.c b/src/hw/usb-xhci.c index bacae11..fd58334 100644 --- a/src/hw/usb-xhci.c +++ b/src/hw/usb-xhci.c @@ -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) diff --git a/src/hw/usb-xhci.h b/src/hw/usb-xhci.h index fc1bf7f..c768c5b 100644 --- a/src/hw/usb-xhci.h +++ b/src/hw/usb-xhci.h @@ -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);
diff --git a/src/hw/usb.c b/src/hw/usb.c index 773057e..46e17df 100644 --- a/src/hw/usb.c +++ b/src/hw/usb.c @@ -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 diff --git a/src/hw/usb.h b/src/hw/usb.h index 208d08f..efb5e6f 100644 --- a/src/hw/usb.h +++ b/src/hw/usb.h @@ -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