usb: gadget: core: Fix ->udc_set_speed() speed handling
authorRoger Quadros <rogerq@ti.com>
Tue, 31 Oct 2017 13:56:29 +0000 (15:56 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 14 Dec 2017 08:52:44 +0000 (09:52 +0100)
commit28ddc2b45f5f409b905dc78e79d959377789fc12
treed75c16a90c25cdf6c2a2f899d73b117a3598ca2b
parentcb6c13d914e0f5b7badc3ec455114e4b45177c2a
usb: gadget: core: Fix ->udc_set_speed() speed handling

commit a4f0927ef588cf62bb864707261482c874352942 upstream.

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")
Reported-by: Dylan Howey <Dylan.Howey@tennantco.com>
Signed-off-by: Roger Quadros <rogerq@ti.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/gadget/udc/core.c