Commit 950b3c1d authored by Felipe Balbi's avatar Felipe Balbi

usb: gadget: goku_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: default avatarFelipe Balbi <balbi@ti.com>
parent 8de94fff
...@@ -993,14 +993,15 @@ static int goku_get_frame(struct usb_gadget *_gadget) ...@@ -993,14 +993,15 @@ static int goku_get_frame(struct usb_gadget *_gadget)
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
static int goku_start(struct usb_gadget_driver *driver, static int goku_udc_start(struct usb_gadget *g,
int (*bind)(struct usb_gadget *, struct usb_gadget_driver *)); struct usb_gadget_driver *driver);
static int goku_stop(struct usb_gadget_driver *driver); static int goku_udc_stop(struct usb_gadget *g,
struct usb_gadget_driver *driver);
static const struct usb_gadget_ops goku_ops = { static const struct usb_gadget_ops goku_ops = {
.get_frame = goku_get_frame, .get_frame = goku_get_frame,
.start = goku_start, .udc_start = goku_udc_start,
.stop = goku_stop, .udc_stop = goku_udc_stop,
// no remote wakeup // no remote wakeup
// not selfpowered // not selfpowered
}; };
...@@ -1339,50 +1340,28 @@ static void udc_enable(struct goku_udc *dev) ...@@ -1339,50 +1340,28 @@ static void udc_enable(struct goku_udc *dev)
* - one function driver, initted second * - one function driver, initted second
*/ */
static struct goku_udc *the_controller;
/* when a driver is successfully registered, it will receive /* when a driver is successfully registered, it will receive
* control requests including set_configuration(), which enables * control requests including set_configuration(), which enables
* non-control requests. then usb traffic follows until a * non-control requests. then usb traffic follows until a
* 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 goku_start(struct usb_gadget_driver *driver, static int goku_udc_start(struct usb_gadget *g,
int (*bind)(struct usb_gadget *, struct usb_gadget_driver *)) struct usb_gadget_driver *driver)
{ {
struct goku_udc *dev = the_controller; struct goku_udc *dev = to_goku_udc(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;
/* hook up the driver */ /* hook up the driver */
driver->driver.bus = NULL; driver->driver.bus = NULL;
dev->driver = driver; dev->driver = driver;
dev->gadget.dev.driver = &driver->driver; dev->gadget.dev.driver = &driver->driver;
retval = bind(&dev->gadget, driver);
if (retval) {
DBG(dev, "bind to driver %s --> error %d\n",
driver->driver.name, retval);
dev->driver = NULL;
dev->gadget.dev.driver = NULL;
return retval;
}
/* 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.
*/ */
udc_enable(dev); udc_enable(dev);
DBG(dev, "registered gadget driver '%s'\n", driver->driver.name);
return 0; return 0;
} }
...@@ -1400,35 +1379,23 @@ stop_activity(struct goku_udc *dev, struct usb_gadget_driver *driver) ...@@ -1400,35 +1379,23 @@ stop_activity(struct goku_udc *dev, struct usb_gadget_driver *driver)
udc_reset (dev); udc_reset (dev);
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
nuke(&dev->ep [i], -ESHUTDOWN); nuke(&dev->ep [i], -ESHUTDOWN);
if (driver) {
spin_unlock(&dev->lock);
driver->disconnect(&dev->gadget);
spin_lock(&dev->lock);
}
if (dev->driver) if (dev->driver)
udc_enable(dev); udc_enable(dev);
} }
static int goku_stop(struct usb_gadget_driver *driver) static int goku_udc_stop(struct usb_gadget *g,
struct usb_gadget_driver *driver)
{ {
struct goku_udc *dev = the_controller; struct goku_udc *dev = to_goku_udc(g);
unsigned long flags; unsigned long flags;
if (!dev)
return -ENODEV;
if (!driver || driver != dev->driver || !driver->unbind)
return -EINVAL;
spin_lock_irqsave(&dev->lock, flags); spin_lock_irqsave(&dev->lock, flags);
dev->driver = NULL; dev->driver = NULL;
stop_activity(dev, driver); stop_activity(dev, driver);
spin_unlock_irqrestore(&dev->lock, flags); spin_unlock_irqrestore(&dev->lock, flags);
driver->unbind(&dev->gadget);
dev->gadget.dev.driver = NULL; dev->gadget.dev.driver = NULL;
DBG(dev, "unregistered driver '%s'\n", driver->driver.name);
return 0; return 0;
} }
...@@ -1754,7 +1721,6 @@ static void goku_remove(struct pci_dev *pdev) ...@@ -1754,7 +1721,6 @@ static void goku_remove(struct pci_dev *pdev)
pci_set_drvdata(pdev, NULL); pci_set_drvdata(pdev, NULL);
dev->regs = NULL; dev->regs = NULL;
the_controller = NULL;
INFO(dev, "unbind\n"); INFO(dev, "unbind\n");
} }
...@@ -1770,13 +1736,6 @@ static int goku_probe(struct pci_dev *pdev, const struct pci_device_id *id) ...@@ -1770,13 +1736,6 @@ static int goku_probe(struct pci_dev *pdev, const struct pci_device_id *id)
void __iomem *base = NULL; void __iomem *base = NULL;
int retval; int retval;
/* if you want to support more than one controller in a system,
* usb_gadget_driver_{register,unregister}() must change.
*/
if (the_controller) {
pr_warning("ignoring %s\n", pci_name(pdev));
return -EBUSY;
}
if (!pdev->irq) { if (!pdev->irq) {
printk(KERN_ERR "Check PCI %s IRQ setup!\n", pci_name(pdev)); printk(KERN_ERR "Check PCI %s IRQ setup!\n", pci_name(pdev));
retval = -ENODEV; retval = -ENODEV;
...@@ -1851,7 +1810,6 @@ static int goku_probe(struct pci_dev *pdev, const struct pci_device_id *id) ...@@ -1851,7 +1810,6 @@ static int goku_probe(struct pci_dev *pdev, const struct pci_device_id *id)
create_proc_read_entry(proc_node_name, 0, NULL, udc_proc_read, dev); create_proc_read_entry(proc_node_name, 0, NULL, udc_proc_read, dev);
#endif #endif
the_controller = dev;
retval = device_register(&dev->gadget.dev); retval = device_register(&dev->gadget.dev);
if (retval) { if (retval) {
put_device(&dev->gadget.dev); put_device(&dev->gadget.dev);
......
...@@ -261,6 +261,7 @@ struct goku_udc { ...@@ -261,6 +261,7 @@ struct goku_udc {
/* statistics... */ /* statistics... */
unsigned long irqs; unsigned long irqs;
}; };
#define to_goku_udc(g) (container_of((g), struct goku_udc, gadget))
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment