diff options
Diffstat (limited to 'drivers/usb/dwc3/ep0.c')
-rw-r--r-- | drivers/usb/dwc3/ep0.c | 49 |
1 files changed, 19 insertions, 30 deletions
diff --git a/drivers/usb/dwc3/ep0.c b/drivers/usb/dwc3/ep0.c index 5acbb948b704..7fa93f4bc507 100644 --- a/drivers/usb/dwc3/ep0.c +++ b/drivers/usb/dwc3/ep0.c | |||
@@ -6,34 +6,14 @@ | |||
6 | * Authors: Felipe Balbi <balbi@ti.com>, | 6 | * Authors: Felipe Balbi <balbi@ti.com>, |
7 | * Sebastian Andrzej Siewior <bigeasy@linutronix.de> | 7 | * Sebastian Andrzej Siewior <bigeasy@linutronix.de> |
8 | * | 8 | * |
9 | * Redistribution and use in source and binary forms, with or without | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * modification, are permitted provided that the following conditions | 10 | * it under the terms of the GNU General Public License version 2 of |
11 | * are met: | 11 | * the License as published by the Free Software Foundation. |
12 | * 1. Redistributions of source code must retain the above copyright | ||
13 | * notice, this list of conditions, and the following disclaimer, | ||
14 | * without modification. | ||
15 | * 2. Redistributions in binary form must reproduce the above copyright | ||
16 | * notice, this list of conditions and the following disclaimer in the | ||
17 | * documentation and/or other materials provided with the distribution. | ||
18 | * 3. The names of the above-listed copyright holders may not be used | ||
19 | * to endorse or promote products derived from this software without | ||
20 | * specific prior written permission. | ||
21 | * | 12 | * |
22 | * ALTERNATIVELY, this software may be distributed under the terms of the | 13 | * This program is distributed in the hope that it will be useful, |
23 | * GNU General Public License ("GPL") version 2, as published by the Free | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
24 | * Software Foundation. | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
25 | * | 16 | * GNU General Public License for more details. |
26 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | ||
27 | * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
28 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
29 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | ||
30 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
31 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
32 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
33 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
34 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
35 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
36 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
37 | */ | 17 | */ |
38 | 18 | ||
39 | #include <linux/kernel.h> | 19 | #include <linux/kernel.h> |
@@ -168,6 +148,7 @@ static int __dwc3_gadget_ep0_queue(struct dwc3_ep *dep, | |||
168 | 148 | ||
169 | direction = !dwc->ep0_expect_in; | 149 | direction = !dwc->ep0_expect_in; |
170 | dwc->delayed_status = false; | 150 | dwc->delayed_status = false; |
151 | usb_gadget_set_state(&dwc->gadget, USB_STATE_CONFIGURED); | ||
171 | 152 | ||
172 | if (dwc->ep0state == EP0_STATUS_PHASE) | 153 | if (dwc->ep0state == EP0_STATUS_PHASE) |
173 | __dwc3_ep0_do_control_status(dwc, dwc->eps[direction]); | 154 | __dwc3_ep0_do_control_status(dwc, dwc->eps[direction]); |
@@ -553,8 +534,16 @@ static int dwc3_ep0_set_config(struct dwc3 *dwc, struct usb_ctrlrequest *ctrl) | |||
553 | ret = dwc3_ep0_delegate_req(dwc, ctrl); | 534 | ret = dwc3_ep0_delegate_req(dwc, ctrl); |
554 | /* if the cfg matches and the cfg is non zero */ | 535 | /* if the cfg matches and the cfg is non zero */ |
555 | if (cfg && (!ret || (ret == USB_GADGET_DELAYED_STATUS))) { | 536 | if (cfg && (!ret || (ret == USB_GADGET_DELAYED_STATUS))) { |
556 | usb_gadget_set_state(&dwc->gadget, | 537 | |
557 | USB_STATE_CONFIGURED); | 538 | /* |
539 | * only change state if set_config has already | ||
540 | * been processed. If gadget driver returns | ||
541 | * USB_GADGET_DELAYED_STATUS, we will wait | ||
542 | * to change the state on the next usb_ep_queue() | ||
543 | */ | ||
544 | if (ret == 0) | ||
545 | usb_gadget_set_state(&dwc->gadget, | ||
546 | USB_STATE_CONFIGURED); | ||
558 | 547 | ||
559 | /* | 548 | /* |
560 | * Enable transition to U1/U2 state when | 549 | * Enable transition to U1/U2 state when |
@@ -571,7 +560,7 @@ static int dwc3_ep0_set_config(struct dwc3 *dwc, struct usb_ctrlrequest *ctrl) | |||
571 | 560 | ||
572 | case USB_STATE_CONFIGURED: | 561 | case USB_STATE_CONFIGURED: |
573 | ret = dwc3_ep0_delegate_req(dwc, ctrl); | 562 | ret = dwc3_ep0_delegate_req(dwc, ctrl); |
574 | if (!cfg) | 563 | if (!cfg && !ret) |
575 | usb_gadget_set_state(&dwc->gadget, | 564 | usb_gadget_set_state(&dwc->gadget, |
576 | USB_STATE_ADDRESS); | 565 | USB_STATE_ADDRESS); |
577 | break; | 566 | break; |