Skip to contentSkip to conversation

patch "usb: gadget: core: Fix ->udc_set_speed() speed handling" added to usb-linus

PATCH [email protected] 1 participant 1 message Nov 30, 2017

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

    usb: gadget: core: Fix ->udc_set_speed() speed handling

to my usb git tree which can be found at
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git
in the usb-linus branch.

The patch will show up in the next release of the linux-next tree (usually sometime within the next 24 hours during the week.)

The patch will hopefully also be merged in Linus's tree for the next -rc kernel release.

If you have any questions about this process, please let me know.

Quoted 1 line

From a4f0927ef588cf62bb864707261482c874352942 Mon Sep 17 00:00:00 2001

From: Roger Quadros <[email protected]>
Date: Tue, 31 Oct 2017 15:56:29 +0200
Subject: usb: gadget: core: Fix ->udc_set_speed() speed handling

Currently UDC core calls ->udc_set_speed() with the speed parameter containing the maximum speed supported by the gadget function driver. This might very well be more than that supported by the UDC controller driver.

Select the lesser of the 2 speeds so both UDC and gadget function driver are operating within limits.

This fixes PHY Erratic errors and 2 second enumeration delay on TI's AM437x platforms.

Fixes 6099eca796ae ("usb: gadget: core: introduce ->udc_set_speed() method")
Cc <[email protected]> # v4.13+
---
 drivers/usb/gadget/udc/core.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/usb/gadget/udc/core.c +6 -2
index 61422d624ad0..93eff7dec2f5 100644
@@ -1069,8 +1069,12 @@ static inline void usb_gadget_udc_stop(struct usb_udc *udc)
 static inline void usb_gadget_udc_set_speed(struct usb_udc *udc,
 					    enum usb_device_speed speed)
 {
-	if (udc->gadget->ops->udc_set_speed)
-		udc->gadget->ops->udc_set_speed(udc->gadget, speed);
+	if (udc->gadget->ops->udc_set_speed) {
+		enum usb_device_speed s;
+
+		s = min(speed, udc->gadget->max_speed);
+		udc->gadget->ops->udc_set_speed(udc->gadget, s);
+	}
 }
 
 /**
Signature · 1 line
2.15.1