Skip to content

Commit

Permalink
usb: gadget: pxa25x_udc: 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 1fb3b1c commit 6166c24
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 48 deletions.
62 changes: 14 additions & 48 deletions drivers/usb/gadget/pxa25x_udc.c
Original file line number Diff line number Diff line change
Expand Up @@ -996,18 +996,19 @@ static int pxa25x_udc_vbus_draw(struct usb_gadget *_gadget, unsigned mA)
return -EOPNOTSUPP;
}

static int pxa25x_start(struct usb_gadget_driver *driver,
int (*bind)(struct usb_gadget *, struct usb_gadget_driver *));
static int pxa25x_stop(struct usb_gadget_driver *driver);
static int pxa25x_udc_start(struct usb_gadget *g,
struct usb_gadget_driver *driver);
static int pxa25x_udc_stop(struct usb_gadget *g,
struct usb_gadget_driver *driver);

static const struct usb_gadget_ops pxa25x_udc_ops = {
.get_frame = pxa25x_udc_get_frame,
.wakeup = pxa25x_udc_wakeup,
.vbus_session = pxa25x_udc_vbus_session,
.pullup = pxa25x_udc_pullup,
.vbus_draw = pxa25x_udc_vbus_draw,
.start = pxa25x_start,
.stop = pxa25x_stop,
.udc_start = pxa25x_udc_start,
.udc_stop = pxa25x_udc_stop,
};

/*-------------------------------------------------------------------------*/
Expand Down Expand Up @@ -1254,58 +1255,33 @@ static void udc_enable (struct pxa25x_udc *dev)
* disconnect is reported. then a host may connect again, or
* the driver might get unbound.
*/
static int pxa25x_start(struct usb_gadget_driver *driver,
int (*bind)(struct usb_gadget *, struct usb_gadget_driver *))
static int pxa25x_udc_start(struct usb_gadget *g,
struct usb_gadget_driver *driver)
{
struct pxa25x_udc *dev = the_controller;
struct pxa25x_udc *dev = to_pxa25x(g);
int retval;

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

/* first hook up the driver ... */
dev->driver = driver;
dev->gadget.dev.driver = &driver->driver;
dev->pullup = 1;

retval = device_add (&dev->gadget.dev);
if (retval) {
fail:
dev->driver = NULL;
dev->gadget.dev.driver = NULL;
return retval;
}
retval = bind(&dev->gadget, driver);
if (retval) {
DMSG("bind to driver %s --> error %d\n",
driver->driver.name, retval);
device_del (&dev->gadget.dev);
goto fail;
}

/* ... then enable host detection and ep0; and we're ready
* for set_configuration as well as eventual disconnect.
*/
DMSG("registered gadget driver '%s'\n", driver->driver.name);

/* connect to bus through transceiver */
if (!IS_ERR_OR_NULL(dev->transceiver)) {
retval = otg_set_peripheral(dev->transceiver->otg,
&dev->gadget);
if (retval) {
DMSG("can't bind to transceiver\n");
if (driver->unbind)
driver->unbind(&dev->gadget);
if (retval)
goto bind_fail;
}
}

pullup(dev);
Expand Down Expand Up @@ -1334,22 +1310,14 @@ stop_activity(struct pxa25x_udc *dev, struct usb_gadget_driver *driver)
}
del_timer_sync(&dev->timer);

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

/* re-init driver-visible data structures */
udc_reinit(dev);
}

static int pxa25x_stop(struct usb_gadget_driver *driver)
static int pxa25x_udc_stop(struct usb_gadget*g,
struct usb_gadget_driver *driver)
{
struct pxa25x_udc *dev = the_controller;

if (!dev)
return -ENODEV;
if (!driver || driver != dev->driver || !driver->unbind)
return -EINVAL;
struct pxa25x_udc *dev = to_pxa25x(g);

local_irq_disable();
dev->pullup = 0;
Expand All @@ -1360,14 +1328,12 @@ static int pxa25x_stop(struct usb_gadget_driver *driver)
if (!IS_ERR_OR_NULL(dev->transceiver))
(void) otg_set_peripheral(dev->transceiver->otg, NULL);

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

device_del (&dev->gadget.dev);

DMSG("unregistered gadget driver '%s'\n", driver->driver.name);
dump_state(dev);

return 0;
}

Expand Down
1 change: 1 addition & 0 deletions drivers/usb/gadget/pxa25x_udc.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ struct pxa25x_udc {
struct dentry *debugfs_udc;
#endif
};
#define to_pxa25x(g) (container_of((g), struct pxa25x_udc, gadget))

/*-------------------------------------------------------------------------*/

Expand Down

0 comments on commit 6166c24

Please sign in to comment.