mirror of
https://github.com/torvalds/linux.git
synced 2024-11-17 17:41:44 +00:00
usb: gadget: at91_udc: convert to new style start/stop interface
This patches converts the driver into the new style start/stop interface. As a result the driver no longer uses the static global controller variable in start/stop functions. I kept the controller variable since it makes the init code a little simpler. Compile tested only. Cc: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sebastian Andrzej Siewior <sebastian@breakpoint.cc> Signed-off-by: Felipe Balbi <balbi@ti.com>
This commit is contained in:
parent
955846a60a
commit
f3d8bf34c2
@ -977,18 +977,18 @@ static int at91_set_selfpowered(struct usb_gadget *gadget, int is_on)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int at91_start(struct usb_gadget_driver *driver,
|
static int at91_start(struct usb_gadget *gadget,
|
||||||
int (*bind)(struct usb_gadget *));
|
struct usb_gadget_driver *driver);
|
||||||
static int at91_stop(struct usb_gadget_driver *driver);
|
static int at91_stop(struct usb_gadget *gadget,
|
||||||
|
struct usb_gadget_driver *driver);
|
||||||
static const struct usb_gadget_ops at91_udc_ops = {
|
static const struct usb_gadget_ops at91_udc_ops = {
|
||||||
.get_frame = at91_get_frame,
|
.get_frame = at91_get_frame,
|
||||||
.wakeup = at91_wakeup,
|
.wakeup = at91_wakeup,
|
||||||
.set_selfpowered = at91_set_selfpowered,
|
.set_selfpowered = at91_set_selfpowered,
|
||||||
.vbus_session = at91_vbus_session,
|
.vbus_session = at91_vbus_session,
|
||||||
.pullup = at91_pullup,
|
.pullup = at91_pullup,
|
||||||
.start = at91_start,
|
.udc_start = at91_start,
|
||||||
.stop = at91_stop,
|
.udc_stop = at91_stop,
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* VBUS-powered devices may also also want to support bigger
|
* VBUS-powered devices may also also want to support bigger
|
||||||
@ -1626,66 +1626,34 @@ static void at91_vbus_timer(unsigned long data)
|
|||||||
schedule_work(&udc->vbus_timer_work);
|
schedule_work(&udc->vbus_timer_work);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int at91_start(struct usb_gadget_driver *driver,
|
static int at91_start(struct usb_gadget *gadget,
|
||||||
int (*bind)(struct usb_gadget *))
|
struct usb_gadget_driver *driver)
|
||||||
{
|
{
|
||||||
struct at91_udc *udc = &controller;
|
struct at91_udc *udc;
|
||||||
int retval;
|
|
||||||
unsigned long flags;
|
|
||||||
|
|
||||||
if (!driver
|
|
||||||
|| driver->max_speed < USB_SPEED_FULL
|
|
||||||
|| !bind
|
|
||||||
|| !driver->setup) {
|
|
||||||
DBG("bad parameter.\n");
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (udc->driver) {
|
|
||||||
DBG("UDC already has a gadget driver\n");
|
|
||||||
return -EBUSY;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
udc = container_of(gadget, struct at91_udc, gadget);
|
||||||
udc->driver = driver;
|
udc->driver = driver;
|
||||||
udc->gadget.dev.driver = &driver->driver;
|
udc->gadget.dev.driver = &driver->driver;
|
||||||
dev_set_drvdata(&udc->gadget.dev, &driver->driver);
|
dev_set_drvdata(&udc->gadget.dev, &driver->driver);
|
||||||
udc->enabled = 1;
|
udc->enabled = 1;
|
||||||
udc->selfpowered = 1;
|
udc->selfpowered = 1;
|
||||||
|
|
||||||
retval = bind(&udc->gadget);
|
|
||||||
if (retval) {
|
|
||||||
DBG("bind() returned %d\n", retval);
|
|
||||||
udc->driver = NULL;
|
|
||||||
udc->gadget.dev.driver = NULL;
|
|
||||||
dev_set_drvdata(&udc->gadget.dev, NULL);
|
|
||||||
udc->enabled = 0;
|
|
||||||
udc->selfpowered = 0;
|
|
||||||
return retval;
|
|
||||||
}
|
|
||||||
|
|
||||||
spin_lock_irqsave(&udc->lock, flags);
|
|
||||||
pullup(udc, 1);
|
|
||||||
spin_unlock_irqrestore(&udc->lock, flags);
|
|
||||||
|
|
||||||
DBG("bound to %s\n", driver->driver.name);
|
DBG("bound to %s\n", driver->driver.name);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int at91_stop(struct usb_gadget_driver *driver)
|
static int at91_stop(struct usb_gadget *gadget,
|
||||||
|
struct usb_gadget_driver *driver)
|
||||||
{
|
{
|
||||||
struct at91_udc *udc = &controller;
|
struct at91_udc *udc;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
|
||||||
if (!driver || driver != udc->driver || !driver->unbind)
|
udc = container_of(gadget, struct at91_udc, gadget);
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
spin_lock_irqsave(&udc->lock, flags);
|
spin_lock_irqsave(&udc->lock, flags);
|
||||||
udc->enabled = 0;
|
udc->enabled = 0;
|
||||||
at91_udp_write(udc, AT91_UDP_IDR, ~0);
|
at91_udp_write(udc, AT91_UDP_IDR, ~0);
|
||||||
pullup(udc, 0);
|
|
||||||
spin_unlock_irqrestore(&udc->lock, flags);
|
spin_unlock_irqrestore(&udc->lock, flags);
|
||||||
|
|
||||||
driver->unbind(&udc->gadget);
|
|
||||||
udc->gadget.dev.driver = NULL;
|
udc->gadget.dev.driver = NULL;
|
||||||
dev_set_drvdata(&udc->gadget.dev, NULL);
|
dev_set_drvdata(&udc->gadget.dev, NULL);
|
||||||
udc->driver = NULL;
|
udc->driver = NULL;
|
||||||
|
Loading…
Reference in New Issue
Block a user