Skip to content

Commit

Permalink
usb: dwc3: gadget: implement gadget state tracking
Browse files Browse the repository at this point in the history
make use of the previously introduced gadget->state
field.

Signed-off-by: Felipe Balbi <balbi@ti.com>
  • Loading branch information
Felipe Balbi committed Mar 18, 2013
1 parent 49401f4 commit 14cd592
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
15 changes: 12 additions & 3 deletions drivers/usb/dwc3/ep0.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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.
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion drivers/usb/dwc3/gadget.c
Original file line number Diff line number Diff line change
Expand Up @@ -2137,7 +2137,7 @@ static void dwc3_gadget_reset_interrupt(struct dwc3 *dwc)
}

/* after reset -> Default State */
dwc->dev_state = DWC3_DEFAULT_STATE;
usb_gadget_set_state(&dwc->gadget, USB_STATE_DEFAULT);

/* Recent versions support automatic phy suspend and don't need this */
if (dwc->revision < DWC3_REVISION_194A) {
Expand Down

0 comments on commit 14cd592

Please sign in to comment.