usb: msm72k_udc: Fix handling of OUT packets on ep0 with length > 0

The gadget level completion function was getting called for the ACK packet
instead of the data packet, making it impossible to read the data from the host.

Signed-off-by: Mike Lockwood <lockwood@android.com>
This commit is contained in:
tytung 2011-11-16 00:29:34 +08:00
parent 89f23f9c1c
commit aabb2fb32d

View File

@ -64,6 +64,7 @@ static const char driver_name[] = "msm72k_udc";
#define SETUP_BUF_SIZE 4096
typedef void (*completion_func)(struct usb_ep *ep, struct usb_request *req);
static const char *const ep_name[] = {
"ep0out", "ep1out", "ep2out", "ep3out",
@ -108,9 +109,7 @@ struct msm_request {
struct usb_request req;
/* saved copy of req.complete */
void (*gadget_complete)(struct usb_ep *ep,
struct usb_request *req);
completion_func gadget_complete;
struct usb_info *ui;
struct msm_request *next;
@ -654,7 +653,7 @@ static void ep0_complete(struct usb_ep *ep, struct usb_request *req)
struct usb_info *ui = ept->ui;
req->complete = r->gadget_complete;
r->gadget_complete = 0;
r->gadget_complete = NULL;
if (req->complete)
req->complete(&ui->ep0in.ep, req);
}
@ -666,6 +665,12 @@ static void ep0_queue_ack_complete(struct usb_ep *ep,
struct msm_endpoint *ept = to_msm_endpoint(ep);
struct usb_info *ui = ept->ui;
struct usb_request *req = ui->setup_req;
completion_func gadget_complete = r->gadget_complete;
if (gadget_complete) {
r->gadget_complete = NULL;
gadget_complete(ep, req);
}
/* queue up the receive of the ACK response from the host */
if (_req->status == 0 && _req->actual == _req->length) {
@ -675,7 +680,7 @@ static void ep0_queue_ack_complete(struct usb_ep *ep,
else
usb_ept_queue_xfer(&ui->ep0in, req);
_req->complete = r->gadget_complete;
r->gadget_complete = 0;
r->gadget_complete = NULL;
if (_req->complete)
_req->complete(&ui->ep0in.ep, _req);
} else
@ -739,7 +744,7 @@ static void ep0_setup_send(struct usb_info *ui, unsigned length)
req->length = length;
req->complete = ep0_queue_ack_complete;
r->gadget_complete = 0;
r->gadget_complete = NULL;
usb_ept_queue_xfer(ept, req);
}