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

Configure Feed

Select the types of activity you want to include in your feed.

usb: xhci: clean up 'wValue' handling in xhci_hub_control()

Several hub control requests encode a descriptor type in the upper byte
of 'wValue'. Clean this up by extracting the descriptor type into a local
variable and using it for all relevant requests.

Replace magic value (0x02) with the appropriate macro (HUB_EXT_PORT_STATUS)

This improves readability and makes the handling of 'wValue' consistent.

Signed-off-by: Niklas Neronin <niklas.neronin@linux.intel.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Link: https://patch.msgid.link/20260402131342.2628648-17-mathias.nyman@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Niklas Neronin and committed by
Greg Kroah-Hartman
995e2af1 b7a56f86

+6 -4
+6 -4
drivers/usb/host/xhci-hub.c
··· 1209 1209 u16 wake_mask; 1210 1210 u8 timeout; 1211 1211 u8 test_mode; 1212 + u8 desc_type; 1212 1213 struct xhci_hub *rhub; 1213 1214 struct xhci_port **ports; 1214 1215 struct xhci_port *port; ··· 1227 1226 memset(buf, 0, 4); 1228 1227 break; 1229 1228 case GetHubDescriptor: 1229 + desc_type = (wValue & 0xff00) >> 8; 1230 1230 /* Check to make sure userspace is asking for the USB 3.0 hub 1231 1231 * descriptor for the USB 3.0 roothub. If not, we stall the 1232 1232 * endpoint, like external hubs do. 1233 1233 */ 1234 1234 if (hcd->speed >= HCD_USB3 && 1235 - (wLength < USB_DT_SS_HUB_SIZE || 1236 - wValue != (USB_DT_SS_HUB << 8))) { 1235 + (wLength < USB_DT_SS_HUB_SIZE || desc_type != USB_DT_SS_HUB)) { 1237 1236 xhci_dbg(xhci, "Wrong hub descriptor type for " 1238 1237 "USB 3.0 roothub.\n"); 1239 1238 goto error; ··· 1242 1241 (struct usb_hub_descriptor *) buf); 1243 1242 break; 1244 1243 case DeviceRequest | USB_REQ_GET_DESCRIPTOR: 1245 - if ((wValue & 0xff00) != (USB_DT_BOS << 8)) 1244 + desc_type = (wValue & 0xff00) >> 8; 1245 + if (desc_type != USB_DT_BOS) 1246 1246 goto error; 1247 1247 1248 1248 if (hcd->speed < HCD_USB3) ··· 1274 1272 1275 1273 put_unaligned(cpu_to_le32(status), (__le32 *) buf); 1276 1274 /* if USB 3.1 extended port status return additional 4 bytes */ 1277 - if (wValue == 0x02) { 1275 + if (wValue == HUB_EXT_PORT_STATUS) { 1278 1276 u32 port_li; 1279 1277 1280 1278 if (hcd->speed < HCD_USB31 || wLength != 8) {