Commit bfe0658b authored by Michal Nazarewicz's avatar Michal Nazarewicz Committed by Greg Kroah-Hartman

usb: udc: Fix gadget driver's speed check in various UDC drivers

Several UDC drivers had a gadget driver's speed sanity check of the
form of:

	driver->speed != USB_SPEED_HIGH

or:

	driver->speed != USB_SPEED_HIGH && driver->speed != USB_SPEED_FULL

As more and more gadget drivers support USB SuperSpeed, driver->speed
may be set to USB_SPEED_SUPER and UDC driver should handle such gadget
correctly.  The above checks however fail to recognise USB_SPEED_SUPER
as a valid speed.

This commit changes the two checks to:

	driver->speed < USB_SPEED_HIGH

or:

	driver->speed < USB_SPEED_FULL

respectively.
Signed-off-by: default avatarMichal Nazarewicz <mina86@mina86.com>
Reported-by: default avatarAlan Stern <stern@rowland.harvard.edu>
Tested-by: default avatarHeiko Stuebner <heiko@sntech.de>
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent fef69644
...@@ -1959,7 +1959,7 @@ static int amd5536_start(struct usb_gadget_driver *driver, ...@@ -1959,7 +1959,7 @@ static int amd5536_start(struct usb_gadget_driver *driver,
u32 tmp; u32 tmp;
if (!driver || !bind || !driver->setup if (!driver || !bind || !driver->setup
|| driver->speed != USB_SPEED_HIGH) || driver->speed < USB_SPEED_HIGH)
return -EINVAL; return -EINVAL;
if (!dev) if (!dev)
return -ENODEV; return -ENODEV;
......
...@@ -2336,8 +2336,7 @@ static int fsl_qe_start(struct usb_gadget_driver *driver, ...@@ -2336,8 +2336,7 @@ static int fsl_qe_start(struct usb_gadget_driver *driver,
if (!udc_controller) if (!udc_controller)
return -ENODEV; return -ENODEV;
if (!driver || (driver->speed != USB_SPEED_FULL if (!driver || driver->speed < USB_SPEED_FULL
&& driver->speed != USB_SPEED_HIGH)
|| !bind || !driver->disconnect || !driver->setup) || !bind || !driver->disconnect || !driver->setup)
return -EINVAL; return -EINVAL;
......
...@@ -1938,8 +1938,7 @@ static int fsl_start(struct usb_gadget_driver *driver, ...@@ -1938,8 +1938,7 @@ static int fsl_start(struct usb_gadget_driver *driver,
if (!udc_controller) if (!udc_controller)
return -ENODEV; return -ENODEV;
if (!driver || (driver->speed != USB_SPEED_FULL if (!driver || driver->speed < USB_SPEED_FULL
&& driver->speed != USB_SPEED_HIGH)
|| !bind || !driver->disconnect || !driver->setup) || !bind || !driver->disconnect || !driver->setup)
return -EINVAL; return -EINVAL;
......
...@@ -1472,7 +1472,7 @@ static int m66592_start(struct usb_gadget_driver *driver, ...@@ -1472,7 +1472,7 @@ static int m66592_start(struct usb_gadget_driver *driver,
int retval; int retval;
if (!driver if (!driver
|| driver->speed != USB_SPEED_HIGH || driver->speed < USB_SPEED_HIGH
|| !bind || !bind
|| !driver->setup) || !driver->setup)
return -EINVAL; return -EINVAL;
......
...@@ -1881,7 +1881,7 @@ static int net2280_start(struct usb_gadget *_gadget, ...@@ -1881,7 +1881,7 @@ static int net2280_start(struct usb_gadget *_gadget,
* (dev->usb->xcvrdiag & FORCE_FULL_SPEED_MODE) * (dev->usb->xcvrdiag & FORCE_FULL_SPEED_MODE)
* "must not be used in normal operation" * "must not be used in normal operation"
*/ */
if (!driver || driver->speed != USB_SPEED_HIGH if (!driver || driver->speed < USB_SPEED_HIGH
|| !driver->setup) || !driver->setup)
return -EINVAL; return -EINVAL;
......
...@@ -1746,7 +1746,7 @@ static int r8a66597_start(struct usb_gadget *gadget, ...@@ -1746,7 +1746,7 @@ static int r8a66597_start(struct usb_gadget *gadget,
struct r8a66597 *r8a66597 = gadget_to_r8a66597(gadget); struct r8a66597 *r8a66597 = gadget_to_r8a66597(gadget);
if (!driver if (!driver
|| driver->speed != USB_SPEED_HIGH || driver->speed < USB_SPEED_HIGH
|| !driver->setup) || !driver->setup)
return -EINVAL; return -EINVAL;
if (!r8a66597) if (!r8a66597)
......
...@@ -2586,10 +2586,8 @@ static int s3c_hsotg_start(struct usb_gadget_driver *driver, ...@@ -2586,10 +2586,8 @@ static int s3c_hsotg_start(struct usb_gadget_driver *driver,
return -EINVAL; return -EINVAL;
} }
if (driver->speed != USB_SPEED_HIGH && if (driver->speed < USB_SPEED_FULL)
driver->speed != USB_SPEED_FULL) {
dev_err(hsotg->dev, "%s: bad speed\n", __func__); dev_err(hsotg->dev, "%s: bad speed\n", __func__);
}
if (!bind || !driver->setup) { if (!bind || !driver->setup) {
dev_err(hsotg->dev, "%s: missing entry points\n", __func__); dev_err(hsotg->dev, "%s: missing entry points\n", __func__);
......
...@@ -1142,8 +1142,7 @@ static int s3c_hsudc_start(struct usb_gadget_driver *driver, ...@@ -1142,8 +1142,7 @@ static int s3c_hsudc_start(struct usb_gadget_driver *driver,
int ret; int ret;
if (!driver if (!driver
|| (driver->speed != USB_SPEED_FULL && || driver->speed < USB_SPEED_FULL
driver->speed != USB_SPEED_HIGH)
|| !bind || !bind
|| !driver->unbind || !driver->disconnect || !driver->setup) || !driver->unbind || !driver->disconnect || !driver->setup)
return -EINVAL; return -EINVAL;
......
...@@ -1903,7 +1903,7 @@ static int musb_gadget_start(struct usb_gadget *g, ...@@ -1903,7 +1903,7 @@ static int musb_gadget_start(struct usb_gadget *g,
unsigned long flags; unsigned long flags;
int retval = -EINVAL; int retval = -EINVAL;
if (driver->speed != USB_SPEED_HIGH) if (driver->speed < USB_SPEED_HIGH)
goto err0; goto err0;
pm_runtime_get_sync(musb->controller); pm_runtime_get_sync(musb->controller);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment