Skip to content

Commit

Permalink
usb: gadget: imx_udc: convert to new style start/stop
Browse files Browse the repository at this point in the history
This patches converts the driver into the new style start/stop interface.
As a result the driver no longer uses the static global controller
variable in start/stop code. I kept the gloval controller variable because
it keeps init simple.
Compile tested only.

Signed-off-by: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
Signed-off-by: Felipe Balbi <balbi@ti.com>
  • Loading branch information
Sebastian Andrzej Siewior authored and Felipe Balbi committed May 4, 2012
1 parent 504d14c commit 66ec8ed
Showing 1 changed file with 16 additions and 37 deletions.
53 changes: 16 additions & 37 deletions drivers/usb/gadget/imx_udc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1237,14 +1237,15 @@ irq_handler_t intr_handler(int i)
*******************************************************************************
*/

static int imx_udc_start(struct usb_gadget_driver *driver,
int (*bind)(struct usb_gadget *));
static int imx_udc_stop(struct usb_gadget_driver *driver);
static int imx_udc_start(struct usb_gadget *gadget,
struct usb_gadget_driver *driver);
static int imx_udc_stop(struct usb_gadget *gadget,
struct usb_gadget_driver *driver);
static const struct usb_gadget_ops imx_udc_ops = {
.get_frame = imx_udc_get_frame,
.wakeup = imx_udc_wakeup,
.start = imx_udc_start,
.stop = imx_udc_stop,
.get_frame = imx_udc_get_frame,
.wakeup = imx_udc_wakeup,
.udc_start = imx_udc_start,
.udc_stop = imx_udc_stop,
};

static struct imx_udc_struct controller = {
Expand Down Expand Up @@ -1329,38 +1330,20 @@ static struct imx_udc_struct controller = {
* USB gadget driver functions
*******************************************************************************
*/
static int imx_udc_start(struct usb_gadget_driver *driver,
int (*bind)(struct usb_gadget *))
static int imx_udc_start(struct usb_gadget *gadget,
struct usb_gadget_driver *driver)
{
struct imx_udc_struct *imx_usb = &controller;
struct imx_udc_struct *imx_usb;
int retval;

if (!driver
|| driver->max_speed < USB_SPEED_FULL
|| !bind
|| !driver->disconnect
|| !driver->setup)
return -EINVAL;
if (!imx_usb)
return -ENODEV;
if (imx_usb->driver)
return -EBUSY;

imx_usb = container_of(gadget, struct imx_udc_struct, gadget);
/* first hook up the driver ... */
imx_usb->driver = driver;
imx_usb->gadget.dev.driver = &driver->driver;

retval = device_add(&imx_usb->gadget.dev);
if (retval)
goto fail;
retval = bind(&imx_usb->gadget);
if (retval) {
D_ERR(imx_usb->dev, "<%s> bind to driver %s --> error %d\n",
__func__, driver->driver.name, retval);
device_del(&imx_usb->gadget.dev);

goto fail;
}

D_INI(imx_usb->dev, "<%s> registered gadget driver '%s'\n",
__func__, driver->driver.name);
Expand All @@ -1374,20 +1357,16 @@ static int imx_udc_start(struct usb_gadget_driver *driver,
return retval;
}

static int imx_udc_stop(struct usb_gadget_driver *driver)
static int imx_udc_stop(struct usb_gadget *gadget,
struct usb_gadget_driver *driver)
{
struct imx_udc_struct *imx_usb = &controller;

if (!imx_usb)
return -ENODEV;
if (!driver || driver != imx_usb->driver || !driver->unbind)
return -EINVAL;
struct imx_udc_struct *imx_usb = container_of(gadget,
struct imx_udc_struct, gadget);

udc_stop_activity(imx_usb, driver);
imx_udc_disable(imx_usb);
del_timer(&imx_usb->timer);

driver->unbind(&imx_usb->gadget);
imx_usb->gadget.dev.driver = NULL;
imx_usb->driver = NULL;

Expand Down

0 comments on commit 66ec8ed

Please sign in to comment.