]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
usb: chipidea: udc: return immediately if re-enable non-empty endpoint
authorPeter Chen <peter.chen@freescale.com>
Wed, 11 Feb 2015 04:44:41 +0000 (12:44 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 18 Mar 2015 15:19:08 +0000 (16:19 +0100)
Some gadget driver (like uac1) will try to enable endpoint again even
the ep is not empty, it will cause the ep reset again and may affect
the dTD list which has already queued.

It returns -EBUSY immediately, and indicate the endpoint is in use.
In this way, the ep's behavior will not be affected, and the gadget
driver is also notified.

Cc: Xuebing Wang <xbing6@gmail.com>
Signed-off-by: Peter Chen <peter.chen@freescale.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/chipidea/udc.c

index ff451048c1aca26d14cd23a40b344810134695cf..52445428f254d8ab83d8d60571ee7b3231474048 100644 (file)
@@ -1151,10 +1151,13 @@ static int ep_enable(struct usb_ep *ep,
 
        /* only internal SW should enable ctrl endpts */
 
-       hwep->ep.desc = desc;
-
-       if (!list_empty(&hwep->qh.queue))
+       if (!list_empty(&hwep->qh.queue)) {
                dev_warn(hwep->ci->dev, "enabling a non-empty endpoint!\n");
+               spin_unlock_irqrestore(hwep->lock, flags);
+               return -EBUSY;
+       }
+
+       hwep->ep.desc = desc;
 
        hwep->dir  = usb_endpoint_dir_in(desc) ? TX : RX;
        hwep->num  = usb_endpoint_num(desc);