Patchwork [U-Boot,07/17] usb: mv_udc: Clean up the initial variable check

login
register
mail settings
Submitter Marek Vasut
Date July 10, 2013, 1:16 a.m.
Message ID <1373419003-10919-8-git-send-email-marex@denx.de>
Download mbox | patch
Permalink /patch/257934/
State Awaiting Upstream
Delegated to: Marek Vasut
Headers show

Comments

Marek Vasut - July 10, 2013, 1:16 a.m.
Clean up the code that checks the validity of a USB gadget driver
in usb_gadget_register_driver(). Moreover, limit the speed of the
driver to either FULL or HIGH, this is more precise and once we
have xHCI support, also more correct.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Fabio Estevam <fabio.estevam@freescale.com>
Cc: Lei Wen <leiwen@marvell.com>
Cc: Otavio Salvador <otavio@ossystems.com.br>
Cc: Stefano Babic <sbabic@denx.de>
---
 drivers/usb/gadget/mv_udc.c |   11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

Patch

diff --git a/drivers/usb/gadget/mv_udc.c b/drivers/usb/gadget/mv_udc.c
index fd3be77..5b2c16a 100644
--- a/drivers/usb/gadget/mv_udc.c
+++ b/drivers/usb/gadget/mv_udc.c
@@ -487,13 +487,12 @@  int usb_gadget_register_driver(struct usb_gadget_driver *driver)
 	struct mv_udc *udc;
 	int ret;
 
-	if (!driver
-			|| driver->speed < USB_SPEED_FULL
-			|| !driver->bind
-			|| !driver->setup) {
-		DBG("bad parameter.\n");
+	if (!driver)
+		return -EINVAL;
+	if (!driver->bind || !driver->setup || !driver->disconnect)
+		return -EINVAL;
+	if (driver->speed != USB_SPEED_FULL && driver->speed != USB_SPEED_HIGH)
 		return -EINVAL;
-	}
 
 	ret = usb_lowlevel_init(0, (void **)&controller.ctrl);
 	if (ret)