Skip to content

Commit 51cdd69

Browse files
Michal Vrastilgregkh
authored andcommitted
Revert "usb: gadget: composite: fix OS descriptors w_value logic"
This reverts commit ec6ce70. Fix installation of WinUSB driver using OS descriptors. Without the fix the drivers are not installed correctly and the property 'DeviceInterfaceGUID' is missing on host side. The original change was based on the assumption that the interface number is in the high byte of wValue but it is in the low byte, instead. Unfortunately, the fix is based on MS documentation which is also wrong. The actual USB request for OS descriptors (using USB analyzer) looks like: Offset 0 1 2 3 4 5 6 7 0x000 C1 A1 02 00 05 00 0A 00 C1: bmRequestType (device to host, vendor, interface) A1: nas magic number 0002: wValue (2: nas interface) 0005: wIndex (5: get extended property i.e. nas interface GUID) 008E: wLength (142) The fix was tested on Windows 10 and Windows 11. Cc: [email protected] Fixes: ec6ce70 ("usb: gadget: composite: fix OS descriptors w_value logic") Signed-off-by: Michal Vrastil <[email protected]> Signed-off-by: Elson Roy Serrao <[email protected]> Acked-by: Peter korsgaard <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 40c9748 commit 51cdd69

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

drivers/usb/gadget/composite.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2111,8 +2111,20 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
21112111
memset(buf, 0, w_length);
21122112
buf[5] = 0x01;
21132113
switch (ctrl->bRequestType & USB_RECIP_MASK) {
2114+
/*
2115+
* The Microsoft CompatID OS Descriptor Spec(w_index = 0x4) and
2116+
* Extended Prop OS Desc Spec(w_index = 0x5) state that the
2117+
* HighByte of wValue is the InterfaceNumber and the LowByte is
2118+
* the PageNumber. This high/low byte ordering is incorrectly
2119+
* documented in the Spec. USB analyzer output on the below
2120+
* request packets show the high/low byte inverted i.e LowByte
2121+
* is the InterfaceNumber and the HighByte is the PageNumber.
2122+
* Since we dont support >64KB CompatID/ExtendedProp descriptors,
2123+
* PageNumber is set to 0. Hence verify that the HighByte is 0
2124+
* for below two cases.
2125+
*/
21142126
case USB_RECIP_DEVICE:
2115-
if (w_index != 0x4 || (w_value & 0xff))
2127+
if (w_index != 0x4 || (w_value >> 8))
21162128
break;
21172129
buf[6] = w_index;
21182130
/* Number of ext compat interfaces */
@@ -2128,9 +2140,9 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
21282140
}
21292141
break;
21302142
case USB_RECIP_INTERFACE:
2131-
if (w_index != 0x5 || (w_value & 0xff))
2143+
if (w_index != 0x5 || (w_value >> 8))
21322144
break;
2133-
interface = w_value >> 8;
2145+
interface = w_value & 0xFF;
21342146
if (interface >= MAX_CONFIG_INTERFACES ||
21352147
!os_desc_cfg->interface[interface])
21362148
break;

0 commit comments

Comments
 (0)