mirror of
https://github.com/torvalds/linux.git
synced 2024-12-11 21:52:04 +00:00
usb: dwc3: gadget: Set speed only up to the max supported
The setting of the device speed should be limited by the device's maximum_speed. Check and prevent the driver from attempting to configure higher than the maximum_speed. Signed-off-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com> Link: https://lore.kernel.org/r/4fae4a9ebb60464d64d8b8f6fdfc2777a2206a69.1611106162.git.Thinh.Nguyen@synopsys.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
f551037c07
commit
450b9e9fab
@ -2064,9 +2064,14 @@ static void __dwc3_gadget_set_ssp_rate(struct dwc3 *dwc)
|
||||
|
||||
static void __dwc3_gadget_set_speed(struct dwc3 *dwc)
|
||||
{
|
||||
enum usb_device_speed speed;
|
||||
u32 reg;
|
||||
|
||||
if (dwc->gadget_max_speed == USB_SPEED_SUPER_PLUS &&
|
||||
speed = dwc->gadget_max_speed;
|
||||
if (speed > dwc->maximum_speed)
|
||||
speed = dwc->maximum_speed;
|
||||
|
||||
if (speed == USB_SPEED_SUPER_PLUS &&
|
||||
DWC3_IP_IS(DWC32)) {
|
||||
__dwc3_gadget_set_ssp_rate(dwc);
|
||||
return;
|
||||
@ -2092,7 +2097,7 @@ static void __dwc3_gadget_set_speed(struct dwc3 *dwc)
|
||||
!dwc->dis_metastability_quirk) {
|
||||
reg |= DWC3_DCFG_SUPERSPEED;
|
||||
} else {
|
||||
switch (dwc->gadget_max_speed) {
|
||||
switch (speed) {
|
||||
case USB_SPEED_LOW:
|
||||
reg |= DWC3_DCFG_LOWSPEED;
|
||||
break;
|
||||
@ -2112,7 +2117,7 @@ static void __dwc3_gadget_set_speed(struct dwc3 *dwc)
|
||||
reg |= DWC3_DCFG_SUPERSPEED_PLUS;
|
||||
break;
|
||||
default:
|
||||
dev_err(dwc->dev, "invalid speed (%d)\n", dwc->gadget_max_speed);
|
||||
dev_err(dwc->dev, "invalid speed (%d)\n", speed);
|
||||
|
||||
if (DWC3_IP_IS(DWC3))
|
||||
reg |= DWC3_DCFG_SUPERSPEED;
|
||||
@ -2122,8 +2127,8 @@ static void __dwc3_gadget_set_speed(struct dwc3 *dwc)
|
||||
}
|
||||
|
||||
if (DWC3_IP_IS(DWC32) &&
|
||||
dwc->gadget_max_speed > USB_SPEED_UNKNOWN &&
|
||||
dwc->gadget_max_speed < USB_SPEED_SUPER_PLUS)
|
||||
speed > USB_SPEED_UNKNOWN &&
|
||||
speed < USB_SPEED_SUPER_PLUS)
|
||||
reg &= ~DWC3_DCFG_NUMLANES(~0);
|
||||
|
||||
dwc3_writel(dwc->regs, DWC3_DCFG, reg);
|
||||
|
Loading…
Reference in New Issue
Block a user