usb: gadget: pxa25x_udc: convert to udc_start/udc_stop
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>
This commit is contained in:
parent
1fb3b1cffc
commit
6166c24669
@ -996,9 +996,10 @@ static int pxa25x_udc_vbus_draw(struct usb_gadget *_gadget, unsigned mA)
|
|||||||
return -EOPNOTSUPP;
|
return -EOPNOTSUPP;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int pxa25x_start(struct usb_gadget_driver *driver,
|
static int pxa25x_udc_start(struct usb_gadget *g,
|
||||||
int (*bind)(struct usb_gadget *, struct usb_gadget_driver *));
|
struct usb_gadget_driver *driver);
|
||||||
static int pxa25x_stop(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 = {
|
static const struct usb_gadget_ops pxa25x_udc_ops = {
|
||||||
.get_frame = pxa25x_udc_get_frame,
|
.get_frame = pxa25x_udc_get_frame,
|
||||||
@ -1006,8 +1007,8 @@ static const struct usb_gadget_ops pxa25x_udc_ops = {
|
|||||||
.vbus_session = pxa25x_udc_vbus_session,
|
.vbus_session = pxa25x_udc_vbus_session,
|
||||||
.pullup = pxa25x_udc_pullup,
|
.pullup = pxa25x_udc_pullup,
|
||||||
.vbus_draw = pxa25x_udc_vbus_draw,
|
.vbus_draw = pxa25x_udc_vbus_draw,
|
||||||
.start = pxa25x_start,
|
.udc_start = pxa25x_udc_start,
|
||||||
.stop = pxa25x_stop,
|
.udc_stop = pxa25x_udc_stop,
|
||||||
};
|
};
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------*/
|
/*-------------------------------------------------------------------------*/
|
||||||
@ -1254,23 +1255,12 @@ static void udc_enable (struct pxa25x_udc *dev)
|
|||||||
* disconnect is reported. then a host may connect again, or
|
* disconnect is reported. then a host may connect again, or
|
||||||
* the driver might get unbound.
|
* the driver might get unbound.
|
||||||
*/
|
*/
|
||||||
static int pxa25x_start(struct usb_gadget_driver *driver,
|
static int pxa25x_udc_start(struct usb_gadget *g,
|
||||||
int (*bind)(struct usb_gadget *, struct usb_gadget_driver *))
|
struct usb_gadget_driver *driver)
|
||||||
{
|
{
|
||||||
struct pxa25x_udc *dev = the_controller;
|
struct pxa25x_udc *dev = to_pxa25x(g);
|
||||||
int retval;
|
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 ... */
|
/* first hook up the driver ... */
|
||||||
dev->driver = driver;
|
dev->driver = driver;
|
||||||
dev->gadget.dev.driver = &driver->driver;
|
dev->gadget.dev.driver = &driver->driver;
|
||||||
@ -1278,35 +1268,21 @@ static int pxa25x_start(struct usb_gadget_driver *driver,
|
|||||||
|
|
||||||
retval = device_add (&dev->gadget.dev);
|
retval = device_add (&dev->gadget.dev);
|
||||||
if (retval) {
|
if (retval) {
|
||||||
fail:
|
|
||||||
dev->driver = NULL;
|
dev->driver = NULL;
|
||||||
dev->gadget.dev.driver = NULL;
|
dev->gadget.dev.driver = NULL;
|
||||||
return retval;
|
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
|
/* ... then enable host detection and ep0; and we're ready
|
||||||
* for set_configuration as well as eventual disconnect.
|
* for set_configuration as well as eventual disconnect.
|
||||||
*/
|
*/
|
||||||
DMSG("registered gadget driver '%s'\n", driver->driver.name);
|
|
||||||
|
|
||||||
/* connect to bus through transceiver */
|
/* connect to bus through transceiver */
|
||||||
if (!IS_ERR_OR_NULL(dev->transceiver)) {
|
if (!IS_ERR_OR_NULL(dev->transceiver)) {
|
||||||
retval = otg_set_peripheral(dev->transceiver->otg,
|
retval = otg_set_peripheral(dev->transceiver->otg,
|
||||||
&dev->gadget);
|
&dev->gadget);
|
||||||
if (retval) {
|
if (retval)
|
||||||
DMSG("can't bind to transceiver\n");
|
|
||||||
if (driver->unbind)
|
|
||||||
driver->unbind(&dev->gadget);
|
|
||||||
goto bind_fail;
|
goto bind_fail;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
pullup(dev);
|
pullup(dev);
|
||||||
dump_state(dev);
|
dump_state(dev);
|
||||||
@ -1334,22 +1310,14 @@ stop_activity(struct pxa25x_udc *dev, struct usb_gadget_driver *driver)
|
|||||||
}
|
}
|
||||||
del_timer_sync(&dev->timer);
|
del_timer_sync(&dev->timer);
|
||||||
|
|
||||||
/* report disconnect; the driver is already quiesced */
|
|
||||||
if (driver)
|
|
||||||
driver->disconnect(&dev->gadget);
|
|
||||||
|
|
||||||
/* re-init driver-visible data structures */
|
/* re-init driver-visible data structures */
|
||||||
udc_reinit(dev);
|
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;
|
struct pxa25x_udc *dev = to_pxa25x(g);
|
||||||
|
|
||||||
if (!dev)
|
|
||||||
return -ENODEV;
|
|
||||||
if (!driver || driver != dev->driver || !driver->unbind)
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
local_irq_disable();
|
local_irq_disable();
|
||||||
dev->pullup = 0;
|
dev->pullup = 0;
|
||||||
@ -1360,14 +1328,12 @@ static int pxa25x_stop(struct usb_gadget_driver *driver)
|
|||||||
if (!IS_ERR_OR_NULL(dev->transceiver))
|
if (!IS_ERR_OR_NULL(dev->transceiver))
|
||||||
(void) otg_set_peripheral(dev->transceiver->otg, NULL);
|
(void) otg_set_peripheral(dev->transceiver->otg, NULL);
|
||||||
|
|
||||||
driver->unbind(&dev->gadget);
|
|
||||||
dev->gadget.dev.driver = NULL;
|
dev->gadget.dev.driver = NULL;
|
||||||
dev->driver = NULL;
|
dev->driver = NULL;
|
||||||
|
|
||||||
device_del (&dev->gadget.dev);
|
device_del (&dev->gadget.dev);
|
||||||
|
|
||||||
DMSG("unregistered gadget driver '%s'\n", driver->driver.name);
|
|
||||||
dump_state(dev);
|
dump_state(dev);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,6 +126,7 @@ struct pxa25x_udc {
|
|||||||
struct dentry *debugfs_udc;
|
struct dentry *debugfs_udc;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
#define to_pxa25x(g) (container_of((g), struct pxa25x_udc, gadget))
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------*/
|
/*-------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user