Commit 4cf5e00b authored by Felipe Balbi's avatar Felipe Balbi

usb: gadget: net2280: convert to new style

with this patch we can finally remove the global
"the_controller" pointer.
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
parent 96f8db6a
......@@ -1401,17 +1401,18 @@ static int net2280_pullup(struct usb_gadget *_gadget, int is_on)
return 0;
}
static int net2280_start(struct usb_gadget_driver *driver,
int (*bind)(struct usb_gadget *));
static int net2280_stop(struct usb_gadget_driver *driver);
static int net2280_start(struct usb_gadget *_gadget,
struct usb_gadget_driver *driver);
static int net2280_stop(struct usb_gadget *_gadget,
struct usb_gadget_driver *driver);
static const struct usb_gadget_ops net2280_ops = {
.get_frame = net2280_get_frame,
.wakeup = net2280_wakeup,
.set_selfpowered = net2280_set_selfpowered,
.pullup = net2280_pullup,
.start = net2280_start,
.stop = net2280_stop,
.udc_start = net2280_start,
.udc_stop = net2280_stop,
};
/*-------------------------------------------------------------------------*/
......@@ -1744,8 +1745,6 @@ static void set_fifo_mode (struct net2280 *dev, int mode)
* perhaps to bind specific drivers to specific devices.
*/
static struct net2280 *the_controller;
static void usb_reset (struct net2280 *dev)
{
u32 tmp;
......@@ -1871,10 +1870,10 @@ static void ep0_start (struct net2280 *dev)
* disconnect is reported. then a host may connect again, or
* the driver might get unbound.
*/
static int net2280_start(struct usb_gadget_driver *driver,
int (*bind)(struct usb_gadget *))
static int net2280_start(struct usb_gadget *_gadget,
struct usb_gadget_driver *driver)
{
struct net2280 *dev = the_controller;
struct net2280 *dev;
int retval;
unsigned i;
......@@ -1882,14 +1881,11 @@ static int net2280_start(struct usb_gadget_driver *driver,
* (dev->usb->xcvrdiag & FORCE_FULL_SPEED_MODE)
* "must not be used in normal operation"
*/
if (!driver
|| driver->speed != USB_SPEED_HIGH
|| !bind || !driver->setup)
if (!driver || driver->speed != USB_SPEED_HIGH
|| !driver->setup)
return -EINVAL;
if (!dev)
return -ENODEV;
if (dev->driver)
return -EBUSY;
dev = container_of (_gadget, struct net2280, gadget);
for (i = 0; i < 7; i++)
dev->ep [i].irqs = 0;
......@@ -1899,14 +1895,6 @@ static int net2280_start(struct usb_gadget_driver *driver,
driver->driver.bus = NULL;
dev->driver = driver;
dev->gadget.dev.driver = &driver->driver;
retval = bind(&dev->gadget);
if (retval) {
DEBUG (dev, "bind to driver %s --> %d\n",
driver->driver.name, retval);
dev->driver = NULL;
dev->gadget.dev.driver = NULL;
return retval;
}
retval = device_create_file (&dev->pdev->dev, &dev_attr_function);
if (retval) goto err_unbind;
......@@ -1952,33 +1940,21 @@ stop_activity (struct net2280 *dev, struct usb_gadget_driver *driver)
for (i = 0; i < 7; i++)
nuke (&dev->ep [i]);
/* report disconnect; the driver is already quiesced */
if (driver) {
spin_unlock (&dev->lock);
driver->disconnect (&dev->gadget);
spin_lock (&dev->lock);
}
usb_reinit (dev);
}
static int net2280_stop(struct usb_gadget_driver *driver)
static int net2280_stop(struct usb_gadget *_gadget,
struct usb_gadget_driver *driver)
{
struct net2280 *dev = the_controller;
struct net2280 *dev;
unsigned long flags;
if (!dev)
return -ENODEV;
if (!driver || driver != dev->driver || !driver->unbind)
return -EINVAL;
dev = container_of (_gadget, struct net2280, gadget);
spin_lock_irqsave (&dev->lock, flags);
stop_activity (dev, driver);
spin_unlock_irqrestore (&dev->lock, flags);
net2280_pullup (&dev->gadget, 0);
driver->unbind (&dev->gadget);
dev->gadget.dev.driver = NULL;
dev->driver = NULL;
......@@ -2698,8 +2674,6 @@ static void net2280_remove (struct pci_dev *pdev)
pci_set_drvdata (pdev, NULL);
INFO (dev, "unbind\n");
the_controller = NULL;
}
/* wrap this driver around the specified device, but
......@@ -2713,14 +2687,6 @@ static int net2280_probe (struct pci_dev *pdev, const struct pci_device_id *id)
void __iomem *base = NULL;
int retval, i;
/* if you want to support more than one controller in a system,
* usb_gadget_driver_{register,unregister}() must change.
*/
if (the_controller) {
dev_warn (&pdev->dev, "ignoring\n");
return -EBUSY;
}
/* alloc, and start init */
dev = kzalloc (sizeof *dev, GFP_KERNEL);
if (dev == NULL){
......@@ -2847,8 +2813,6 @@ static int net2280_probe (struct pci_dev *pdev, const struct pci_device_id *id)
use_dma
? (use_dma_chaining ? "chaining" : "enabled")
: "disabled");
the_controller = dev;
retval = device_register (&dev->gadget.dev);
if (retval) goto done;
retval = device_create_file (&pdev->dev, &dev_attr_registers);
......
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