提交 d809f78f 编写于 作者: S Sebastian Andrzej Siewior 提交者: Felipe Balbi

usb: gadget: atmel_usba_udc: convert to newstyle 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 the_udc
variable in start/stop functions. I kept the the_udc variable since it
makes the init code a little simpler.
Someone with hardware might want to look if it possible to move the vbus
irq/toggle_bias code into ->pullup().

Compile tested only.

Cc: Nicolas Ferre <nicolas.ferre@atmel.com>
Signed-off-by: NSebastian Andrzej Siewior <sebastian@breakpoint.cc>
Signed-off-by: NFelipe Balbi <balbi@ti.com>
上级 f3d8bf34
...@@ -1008,16 +1008,16 @@ usba_udc_set_selfpowered(struct usb_gadget *gadget, int is_selfpowered) ...@@ -1008,16 +1008,16 @@ usba_udc_set_selfpowered(struct usb_gadget *gadget, int is_selfpowered)
return 0; return 0;
} }
static int atmel_usba_start(struct usb_gadget_driver *driver, static int atmel_usba_start(struct usb_gadget *gadget,
int (*bind)(struct usb_gadget *)); struct usb_gadget_driver *driver);
static int atmel_usba_stop(struct usb_gadget_driver *driver); static int atmel_usba_stop(struct usb_gadget *gadget,
struct usb_gadget_driver *driver);
static const struct usb_gadget_ops usba_udc_ops = { static const struct usb_gadget_ops usba_udc_ops = {
.get_frame = usba_udc_get_frame, .get_frame = usba_udc_get_frame,
.wakeup = usba_udc_wakeup, .wakeup = usba_udc_wakeup,
.set_selfpowered = usba_udc_set_selfpowered, .set_selfpowered = usba_udc_set_selfpowered,
.start = atmel_usba_start, .udc_start = atmel_usba_start,
.stop = atmel_usba_stop, .udc_stop = atmel_usba_stop,
}; };
static struct usb_endpoint_descriptor usba_ep0_desc = { static struct usb_endpoint_descriptor usba_ep0_desc = {
...@@ -1795,21 +1795,13 @@ static irqreturn_t usba_vbus_irq(int irq, void *devid) ...@@ -1795,21 +1795,13 @@ static irqreturn_t usba_vbus_irq(int irq, void *devid)
return IRQ_HANDLED; return IRQ_HANDLED;
} }
static int atmel_usba_start(struct usb_gadget_driver *driver, static int atmel_usba_start(struct usb_gadget *gadget,
int (*bind)(struct usb_gadget *)) struct usb_gadget_driver *driver)
{ {
struct usba_udc *udc = &the_udc; struct usba_udc *udc = container_of(gadget, struct usba_udc, gadget);
unsigned long flags; unsigned long flags;
int ret;
if (!udc->pdev)
return -ENODEV;
spin_lock_irqsave(&udc->lock, flags); spin_lock_irqsave(&udc->lock, flags);
if (udc->driver) {
spin_unlock_irqrestore(&udc->lock, flags);
return -EBUSY;
}
udc->devstatus = 1 << USB_DEVICE_SELF_POWERED; udc->devstatus = 1 << USB_DEVICE_SELF_POWERED;
udc->driver = driver; udc->driver = driver;
...@@ -1819,13 +1811,6 @@ static int atmel_usba_start(struct usb_gadget_driver *driver, ...@@ -1819,13 +1811,6 @@ static int atmel_usba_start(struct usb_gadget_driver *driver,
clk_enable(udc->pclk); clk_enable(udc->pclk);
clk_enable(udc->hclk); clk_enable(udc->hclk);
ret = bind(&udc->gadget);
if (ret) {
DBG(DBG_ERR, "Could not bind to driver %s: error %d\n",
driver->driver.name, ret);
goto err_driver_bind;
}
DBG(DBG_GADGET, "registered driver `%s'\n", driver->driver.name); DBG(DBG_GADGET, "registered driver `%s'\n", driver->driver.name);
udc->vbus_prev = 0; udc->vbus_prev = 0;
...@@ -1842,23 +1827,14 @@ static int atmel_usba_start(struct usb_gadget_driver *driver, ...@@ -1842,23 +1827,14 @@ static int atmel_usba_start(struct usb_gadget_driver *driver,
spin_unlock_irqrestore(&udc->lock, flags); spin_unlock_irqrestore(&udc->lock, flags);
return 0; return 0;
err_driver_bind:
udc->driver = NULL;
udc->gadget.dev.driver = NULL;
return ret;
} }
static int atmel_usba_stop(struct usb_gadget_driver *driver) static int atmel_usba_stop(struct usb_gadget *gadget,
struct usb_gadget_driver *driver)
{ {
struct usba_udc *udc = &the_udc; struct usba_udc *udc = container_of(gadget, struct usba_udc, gadget);
unsigned long flags; unsigned long flags;
if (!udc->pdev)
return -ENODEV;
if (driver != udc->driver || !driver->unbind)
return -EINVAL;
if (gpio_is_valid(udc->vbus_pin)) if (gpio_is_valid(udc->vbus_pin))
disable_irq(gpio_to_irq(udc->vbus_pin)); disable_irq(gpio_to_irq(udc->vbus_pin));
...@@ -1871,10 +1847,6 @@ static int atmel_usba_stop(struct usb_gadget_driver *driver) ...@@ -1871,10 +1847,6 @@ static int atmel_usba_stop(struct usb_gadget_driver *driver)
toggle_bias(0); toggle_bias(0);
usba_writel(udc, CTRL, USBA_DISABLE_MASK); usba_writel(udc, CTRL, USBA_DISABLE_MASK);
if (udc->driver->disconnect)
udc->driver->disconnect(&udc->gadget);
driver->unbind(&udc->gadget);
udc->gadget.dev.driver = NULL; udc->gadget.dev.driver = NULL;
udc->driver = NULL; udc->driver = NULL;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册