usb: gadget: fsl: remove usage of list iterator past the loop body
[linux-2.6-block.git] / drivers / usb / gadget / udc / fsl_qe_udc.c
index 15db7a3868fe4d0f7c18d6ab537a05851c51a0c7..d80a7fe5ff6230788d2234a6b7899b52b0b41777 100644 (file)
@@ -1776,7 +1776,8 @@ static int qe_ep_queue(struct usb_ep *_ep, struct usb_request *_req,
 static int qe_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req)
 {
        struct qe_ep *ep = container_of(_ep, struct qe_ep, ep);
-       struct qe_req *req;
+       struct qe_req *req = NULL;
+       struct qe_req *iter;
        unsigned long flags;
 
        if (!_ep || !_req)
@@ -1785,12 +1786,14 @@ static int qe_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req)
        spin_lock_irqsave(&ep->udc->lock, flags);
 
        /* make sure it's actually queued on this endpoint */
-       list_for_each_entry(req, &ep->queue, queue) {
-               if (&req->req == _req)
-                       break;
+       list_for_each_entry(iter, &ep->queue, queue) {
+               if (&iter->req != _req)
+                       continue
+               req = iter;
+               break;
        }
 
-       if (&req->req != _req) {
+       if (!req) {
                spin_unlock_irqrestore(&ep->udc->lock, flags);
                return -EINVAL;
        }