Commit d76630386d59d203ad4594d7e91be1f2e258ab93

Authored by Marek Vasut
1 parent be7ed2533d

usb: mv_udc: Clean up the initial variable check

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>

Showing 1 changed file with 5 additions and 6 deletions Side-by-side Diff

drivers/usb/gadget/mv_udc.c
... ... @@ -471,13 +471,12 @@
471 471 struct mv_udc *udc;
472 472 int ret;
473 473  
474   - if (!driver
475   - || driver->speed < USB_SPEED_FULL
476   - || !driver->bind
477   - || !driver->setup) {
478   - DBG("bad parameter.\n");
  474 + if (!driver)
479 475 return -EINVAL;
480   - }
  476 + if (!driver->bind || !driver->setup || !driver->disconnect)
  477 + return -EINVAL;
  478 + if (driver->speed != USB_SPEED_FULL && driver->speed != USB_SPEED_HIGH)
  479 + return -EINVAL;
481 480  
482 481 ret = usb_lowlevel_init(0, (void **)&controller.ctrl);
483 482 if (ret)