diff options
author | Felipe Balbi <balbi@ti.com> | 2011-12-19 13:01:52 +0200 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2013-03-18 11:17:12 +0200 |
commit | 14cd592f72ea1ce1a25d7a576a5ed6aa761456bc (patch) | |
tree | 7557811ad7c557a2944c23a24da4c387a0881737 /drivers/usb/dwc3/ep0.c | |
parent | 49401f4169c0e5a1b38f1a676d6f12eecaf77485 (diff) |
usb: dwc3: gadget: implement gadget state tracking
make use of the previously introduced gadget->state
field.
Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/dwc3/ep0.c')
-rw-r--r-- | drivers/usb/dwc3/ep0.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/drivers/usb/dwc3/ep0.c b/drivers/usb/dwc3/ep0.c index 1d139ca05ef..2a82b714505 100644 --- a/drivers/usb/dwc3/ep0.c +++ b/drivers/usb/dwc3/ep0.c @@ -512,10 +512,13 @@ static int dwc3_ep0_set_address(struct dwc3 *dwc, struct usb_ctrlrequest *ctrl) reg |= DWC3_DCFG_DEVADDR(addr); dwc3_writel(dwc->regs, DWC3_DCFG, reg); - if (addr) + if (addr) { dwc->dev_state = DWC3_ADDRESS_STATE; - else + usb_gadget_set_state(&dwc->gadget, USB_STATE_ADDRESS); + } else { dwc->dev_state = DWC3_DEFAULT_STATE; + usb_gadget_set_state(&dwc->gadget, USB_STATE_DEFAULT); + } return 0; } @@ -549,6 +552,9 @@ static int dwc3_ep0_set_config(struct dwc3 *dwc, struct usb_ctrlrequest *ctrl) /* if the cfg matches and the cfg is non zero */ if (cfg && (!ret || (ret == USB_GADGET_DELAYED_STATUS))) { dwc->dev_state = DWC3_CONFIGURED_STATE; + usb_gadget_set_state(&dwc->gadget, + USB_STATE_CONFIGURED); + /* * Enable transition to U1/U2 state when * nothing is pending from application. @@ -564,8 +570,11 @@ static int dwc3_ep0_set_config(struct dwc3 *dwc, struct usb_ctrlrequest *ctrl) case DWC3_CONFIGURED_STATE: ret = dwc3_ep0_delegate_req(dwc, ctrl); - if (!cfg) + if (!cfg) { dwc->dev_state = DWC3_ADDRESS_STATE; + usb_gadget_set_state(&dwc->gadget, + USB_STATE_ADDRESS); + } break; default: ret = -EINVAL; |