Skip to content

Commit f17c34f

Browse files
oneukumgregkh
authored andcommitted
USB: hub: check for alternate port before enabling A_ALT_HNP_SUPPORT
The OTG 1.3 spec has the feature A_ALT_HNP_SUPPORT, which tells a device that it is connected to the wrong port. Some devices refuse to operate if you enable that feature, because it indicates to them that they ought to request to be connected to another port. According to the spec this feature may be used based only the following three conditions: 6.5.3 a_alt_hnp_support Setting this feature indicates to the B-device that it is connected to an A-device port that is not capable of HNP, but that the A-device does have an alternate port that is capable of HNP. The A-device is required to set this feature under the following conditions: • the A-device has multiple receptacles • the A-device port that connects to the B-device does not support HNP • the A-device has another port that does support HNP A check for the third and first condition is missing. Add it. Signed-off-by: Oliver Neukum <oneukum@suse.com> Cc: stable <stable@kernel.org> Fixes: 7d2d641 ("usb: otg: don't set a_alt_hnp_support feature for OTG 2.0 device") Link: https://lore.kernel.org/r/20240122153545.12284-1-oneukum@suse.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent cc509b6 commit f17c34f

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

drivers/usb/core/hub.c

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2398,17 +2398,25 @@ static int usb_enumerate_device_otg(struct usb_device *udev)
23982398
}
23992399
} else if (desc->bLength == sizeof
24002400
(struct usb_otg_descriptor)) {
2401-
/* Set a_alt_hnp_support for legacy otg device */
2402-
err = usb_control_msg(udev,
2403-
usb_sndctrlpipe(udev, 0),
2404-
USB_REQ_SET_FEATURE, 0,
2405-
USB_DEVICE_A_ALT_HNP_SUPPORT,
2406-
0, NULL, 0,
2407-
USB_CTRL_SET_TIMEOUT);
2408-
if (err < 0)
2409-
dev_err(&udev->dev,
2410-
"set a_alt_hnp_support failed: %d\n",
2411-
err);
2401+
/*
2402+
* We are operating on a legacy OTP device
2403+
* These should be told that they are operating
2404+
* on the wrong port if we have another port that does
2405+
* support HNP
2406+
*/
2407+
if (bus->otg_port != 0) {
2408+
/* Set a_alt_hnp_support for legacy otg device */
2409+
err = usb_control_msg(udev,
2410+
usb_sndctrlpipe(udev, 0),
2411+
USB_REQ_SET_FEATURE, 0,
2412+
USB_DEVICE_A_ALT_HNP_SUPPORT,
2413+
0, NULL, 0,
2414+
USB_CTRL_SET_TIMEOUT);
2415+
if (err < 0)
2416+
dev_err(&udev->dev,
2417+
"set a_alt_hnp_support failed: %d\n",
2418+
err);
2419+
}
24122420
}
24132421
}
24142422
#endif

0 commit comments

Comments
 (0)