usb: dwc3: ep0: use dwc3_request for ep0 requsts instead of usb_request
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>
Fri, 25 Nov 2011 11:03:46 +0000 (12:03 +0100)
committerFelipe Balbi <balbi@ti.com>
Mon, 12 Dec 2011 09:48:45 +0000 (11:48 +0200)
Instead of special functions and shortcuts for sending our internal
answers to the host we started doing what the gadget does and used the
public API for this. Since we only were using a few fields the
usb_request was enough. Later added the list handling in order to
synchronize the host / gadget events and now we require to have the
dwc3_request struct around our usb_request or else we touch memory that
does not belong to us. So this patch does this.

Reported-by: Partha Basak <p-basak2@ti.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
drivers/usb/dwc3/core.h
drivers/usb/dwc3/ep0.c
drivers/usb/dwc3/gadget.h

index 836cf9942a4f511a7230e7f5391dbcd43ba5214f..da523f5648a5de86c8d9896f14617592c821d8fb 100644 (file)
@@ -548,6 +548,20 @@ struct dwc3_hwparams {
 /* HWPARAMS1 */
 #define DWC3_NUM_INT(n)        (((n) & (0x3f << 15)) >> 15)
 
+struct dwc3_request {
+       struct usb_request      request;
+       struct list_head        list;
+       struct dwc3_ep          *dep;
+
+       u8                      epnum;
+       struct dwc3_trb_hw      *trb;
+       dma_addr_t              trb_dma;
+
+       unsigned                direction:1;
+       unsigned                mapped:1;
+       unsigned                queued:1;
+};
+
 /**
  * struct dwc3 - representation of our controller
  * @ctrl_req: usb control request which is used for ep0
@@ -596,7 +610,7 @@ struct dwc3 {
        dma_addr_t              ep0_trb_addr;
        dma_addr_t              setup_buf_addr;
        dma_addr_t              ep0_bounce_addr;
-       struct usb_request      ep0_usb_req;
+       struct dwc3_request     ep0_usb_req;
        /* device lock */
        spinlock_t              lock;
        struct device           *dev;
index ed44525c8d62aa72e495a7abba64598501a64587..1ba86a114655c193c7b0f7be6317701d6b487245 100644 (file)
@@ -302,10 +302,10 @@ static int dwc3_ep0_handle_status(struct dwc3 *dwc,
 
        response_pkt = (__le16 *) dwc->setup_buf;
        *response_pkt = cpu_to_le16(usb_status);
-       dwc->ep0_usb_req.length = sizeof(*response_pkt);
-       dwc->ep0_usb_req.dma = dwc->setup_buf_addr;
-       dwc->ep0_usb_req.complete = dwc3_ep0_status_cmpl;
-       return usb_ep_queue(&dwc->eps[0]->endpoint, &dwc->ep0_usb_req,
+       dwc->ep0_usb_req.request.length = sizeof(*response_pkt);
+       dwc->ep0_usb_req.request.dma = dwc->setup_buf_addr;
+       dwc->ep0_usb_req.request.complete = dwc3_ep0_status_cmpl;
+       return usb_ep_queue(&dwc->eps[0]->endpoint, &dwc->ep0_usb_req.request,
                        GFP_ATOMIC);
 }
 
index 4cdaf02ead5d0f9c6469045c817f15ddd1a0f392..d97f467d41cc43a2d536a93248530de33f55c521 100644 (file)
@@ -79,19 +79,6 @@ struct dwc3_gadget_ep_cmd_params {
 
 /* -------------------------------------------------------------------------- */
 
-struct dwc3_request {
-       struct usb_request      request;
-       struct list_head        list;
-       struct dwc3_ep          *dep;
-
-       u8                      epnum;
-       struct dwc3_trb_hw      *trb;
-       dma_addr_t              trb_dma;
-
-       unsigned                direction:1;
-       unsigned                mapped:1;
-       unsigned                queued:1;
-};
 #define to_dwc3_request(r)     (container_of(r, struct dwc3_request, request))
 
 static inline struct dwc3_request *next_request(struct list_head *list)