提交 9a0d6f7c 编写于 作者: M Minas Harutyunyan 提交者: Felipe Balbi

usb: dwc2: Fix SET/CLEAR_FEATURE and GET_STATUS flows

SET/CLEAR_FEATURE for Remote Wakeup allowance not handled correctly.
GET_STATUS handling provided not correct data on DATA Stage.
Issue seen when gadget's dr_mode set to "otg" mode and connected
to MacOS.
Both are fixed and tested using USBCV Ch.9 tests.
Signed-off-by: NMinas Harutyunyan <hminas@synopsys.com>
Fixes: fa389a6d ("usb: dwc2: gadget: Add remote_wakeup_allowed flag")
Tested-by: NJack Mitchell <ml@embed.me.uk>
Cc: stable@vger.kernel.org
Signed-off-by: NFelipe Balbi <balbi@kernel.org>
上级 860ef6cd
...@@ -1634,6 +1634,7 @@ static int dwc2_hsotg_process_req_status(struct dwc2_hsotg *hsotg, ...@@ -1634,6 +1634,7 @@ static int dwc2_hsotg_process_req_status(struct dwc2_hsotg *hsotg,
struct dwc2_hsotg_ep *ep0 = hsotg->eps_out[0]; struct dwc2_hsotg_ep *ep0 = hsotg->eps_out[0];
struct dwc2_hsotg_ep *ep; struct dwc2_hsotg_ep *ep;
__le16 reply; __le16 reply;
u16 status;
int ret; int ret;
dev_dbg(hsotg->dev, "%s: USB_REQ_GET_STATUS\n", __func__); dev_dbg(hsotg->dev, "%s: USB_REQ_GET_STATUS\n", __func__);
...@@ -1645,11 +1646,10 @@ static int dwc2_hsotg_process_req_status(struct dwc2_hsotg *hsotg, ...@@ -1645,11 +1646,10 @@ static int dwc2_hsotg_process_req_status(struct dwc2_hsotg *hsotg,
switch (ctrl->bRequestType & USB_RECIP_MASK) { switch (ctrl->bRequestType & USB_RECIP_MASK) {
case USB_RECIP_DEVICE: case USB_RECIP_DEVICE:
/* status = 1 << USB_DEVICE_SELF_POWERED;
* bit 0 => self powered status |= hsotg->remote_wakeup_allowed <<
* bit 1 => remote wakeup USB_DEVICE_REMOTE_WAKEUP;
*/ reply = cpu_to_le16(status);
reply = cpu_to_le16(0);
break; break;
case USB_RECIP_INTERFACE: case USB_RECIP_INTERFACE:
...@@ -1760,7 +1760,10 @@ static int dwc2_hsotg_process_req_feature(struct dwc2_hsotg *hsotg, ...@@ -1760,7 +1760,10 @@ static int dwc2_hsotg_process_req_feature(struct dwc2_hsotg *hsotg,
case USB_RECIP_DEVICE: case USB_RECIP_DEVICE:
switch (wValue) { switch (wValue) {
case USB_DEVICE_REMOTE_WAKEUP: case USB_DEVICE_REMOTE_WAKEUP:
hsotg->remote_wakeup_allowed = 1; if (set)
hsotg->remote_wakeup_allowed = 1;
else
hsotg->remote_wakeup_allowed = 0;
break; break;
case USB_DEVICE_TEST_MODE: case USB_DEVICE_TEST_MODE:
...@@ -1770,16 +1773,17 @@ static int dwc2_hsotg_process_req_feature(struct dwc2_hsotg *hsotg, ...@@ -1770,16 +1773,17 @@ static int dwc2_hsotg_process_req_feature(struct dwc2_hsotg *hsotg,
return -EINVAL; return -EINVAL;
hsotg->test_mode = wIndex >> 8; hsotg->test_mode = wIndex >> 8;
ret = dwc2_hsotg_send_reply(hsotg, ep0, NULL, 0);
if (ret) {
dev_err(hsotg->dev,
"%s: failed to send reply\n", __func__);
return ret;
}
break; break;
default: default:
return -ENOENT; return -ENOENT;
} }
ret = dwc2_hsotg_send_reply(hsotg, ep0, NULL, 0);
if (ret) {
dev_err(hsotg->dev,
"%s: failed to send reply\n", __func__);
return ret;
}
break; break;
case USB_RECIP_ENDPOINT: case USB_RECIP_ENDPOINT:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册