Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

usb: gadget: composite: handle otg status selector request from OTG host

If gadget with HNP polling support receives GetStatus request of otg
status selector, it feedback to host with host request flag to indicate
if it wants to take host role.

Acked-by: Peter Chen <peter.chen@freescale.com>
Signed-off-by: Li Jun <jun.li@nxp.com>
Signed-off-by: Felipe Balbi <balbi@kernel.org>

authored by

Li Jun and committed by
Felipe Balbi
c5348b62 d6da40af

+17 -8
+17 -8
drivers/usb/gadget/composite.c
··· 1707 1707 *((u8 *)req->buf) = value; 1708 1708 value = min(w_length, (u16) 1); 1709 1709 break; 1710 - 1711 - /* 1712 - * USB 3.0 additions: 1713 - * Function driver should handle get_status request. If such cb 1714 - * wasn't supplied we respond with default value = 0 1715 - * Note: function driver should supply such cb only for the first 1716 - * interface of the function 1717 - */ 1718 1710 case USB_REQ_GET_STATUS: 1711 + if (gadget_is_otg(gadget) && gadget->hnp_polling_support && 1712 + (w_index == OTG_STS_SELECTOR)) { 1713 + if (ctrl->bRequestType != (USB_DIR_IN | 1714 + USB_RECIP_DEVICE)) 1715 + goto unknown; 1716 + *((u8 *)req->buf) = gadget->host_request_flag; 1717 + value = 1; 1718 + break; 1719 + } 1720 + 1721 + /* 1722 + * USB 3.0 additions: 1723 + * Function driver should handle get_status request. If such cb 1724 + * wasn't supplied we respond with default value = 0 1725 + * Note: function driver should supply such cb only for the 1726 + * first interface of the function 1727 + */ 1719 1728 if (!gadget_is_superspeed(gadget)) 1720 1729 goto unknown; 1721 1730 if (ctrl->bRequestType != (USB_DIR_IN | USB_RECIP_INTERFACE))