Skip to content

Commit

Permalink
usb: gadget: fsl_udc_core: convert to udc_start/udc_stop
Browse files Browse the repository at this point in the history
Mechanical change making use of the new (can we
still call it new ?) interface for registering
UDC drivers.

Signed-off-by: Felipe Balbi <balbi@ti.com>
  • Loading branch information
Felipe Balbi committed Jan 24, 2013
1 parent 950b3c1 commit eb65796
Showing 1 changed file with 11 additions and 47 deletions.
58 changes: 11 additions & 47 deletions drivers/usb/gadget/fsl_udc_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1254,9 +1254,10 @@ static int fsl_pullup(struct usb_gadget *gadget, int is_on)
return 0;
}

static int fsl_start(struct usb_gadget_driver *driver,
int (*bind)(struct usb_gadget *, struct usb_gadget_driver *));
static int fsl_stop(struct usb_gadget_driver *driver);
static int fsl_udc_start(struct usb_gadget *g,
struct usb_gadget_driver *driver);
static int fsl_udc_stop(struct usb_gadget *g,
struct usb_gadget_driver *driver);
/* defined in gadget.h */
static struct usb_gadget_ops fsl_gadget_ops = {
.get_frame = fsl_get_frame,
Expand All @@ -1265,8 +1266,8 @@ static struct usb_gadget_ops fsl_gadget_ops = {
.vbus_session = fsl_vbus_session,
.vbus_draw = fsl_vbus_draw,
.pullup = fsl_pullup,
.start = fsl_start,
.stop = fsl_stop,
.udc_start = fsl_udc_start,
.udc_stop = fsl_udc_stop,
};

/* Set protocol stall on ep0, protocol stall will automatically be cleared
Expand Down Expand Up @@ -1950,22 +1951,12 @@ static irqreturn_t fsl_udc_irq(int irq, void *_udc)
* Hook to gadget drivers
* Called by initialization code of gadget drivers
*----------------------------------------------------------------*/
static int fsl_start(struct usb_gadget_driver *driver,
int (*bind)(struct usb_gadget *, struct usb_gadget_driver *))
static int fsl_udc_start(struct usb_gadget *g,
struct usb_gadget_driver *driver)
{
int retval = -ENODEV;
int retval = 0;
unsigned long flags = 0;

if (!udc_controller)
return -ENODEV;

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

if (udc_controller->driver)
return -EBUSY;

/* lock is needed but whether should use this lock or another */
spin_lock_irqsave(&udc_controller->lock, flags);

Expand All @@ -1975,15 +1966,6 @@ static int fsl_start(struct usb_gadget_driver *driver,
udc_controller->gadget.dev.driver = &driver->driver;
spin_unlock_irqrestore(&udc_controller->lock, flags);

/* bind udc driver to gadget driver */
retval = bind(&udc_controller->gadget, driver);
if (retval) {
VDBG("bind to %s --> %d", driver->driver.name, retval);
udc_controller->gadget.dev.driver = NULL;
udc_controller->driver = NULL;
goto out;
}

if (!IS_ERR_OR_NULL(udc_controller->transceiver)) {
/* Suspend the controller until OTG enable it */
udc_controller->stopped = 1;
Expand All @@ -2009,28 +1991,17 @@ static int fsl_start(struct usb_gadget_driver *driver,
udc_controller->ep0_state = WAIT_FOR_SETUP;
udc_controller->ep0_dir = 0;
}
printk(KERN_INFO "%s: bind to driver %s\n",
udc_controller->gadget.name, driver->driver.name);

out:
if (retval)
printk(KERN_WARNING "gadget driver register failed %d\n",
retval);
return retval;
}

/* Disconnect from gadget driver */
static int fsl_stop(struct usb_gadget_driver *driver)
static int fsl_udc_stop(struct usb_gadget *g,
struct usb_gadget_driver *driver)
{
struct fsl_ep *loop_ep;
unsigned long flags;

if (!udc_controller)
return -ENODEV;

if (!driver || driver != udc_controller->driver || !driver->unbind)
return -EINVAL;

if (!IS_ERR_OR_NULL(udc_controller->transceiver))
otg_set_peripheral(udc_controller->transceiver->otg, NULL);

Expand All @@ -2051,16 +2022,9 @@ static int fsl_stop(struct usb_gadget_driver *driver)
nuke(loop_ep, -ESHUTDOWN);
spin_unlock_irqrestore(&udc_controller->lock, flags);

/* report disconnect; the controller is already quiesced */
driver->disconnect(&udc_controller->gadget);

/* unbind gadget and unhook driver. */
driver->unbind(&udc_controller->gadget);
udc_controller->gadget.dev.driver = NULL;
udc_controller->driver = NULL;

printk(KERN_WARNING "unregistered gadget driver '%s'\n",
driver->driver.name);
return 0;
}

Expand Down

0 comments on commit eb65796

Please sign in to comment.