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)
committerFelipe Balbi <felipe.balbi@linux.intel.com>
Tue, 28 Nov 2017 11:05:31 +0000 (13:05 +0200)
commita4f0927ef588cf62bb864707261482c874352942
tree2bc9d7f51dadd89a053a99223bc5fa74c5b7c200
parent7a9618a22aadffb55027d665491adf466bced61a
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: <stable@vger.kernel.org> # v4.13+
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>
drivers/usb/gadget/udc/core.c