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

usb: gadget: imx_udc: convert to new style start/stop

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 code. I kept the gloval controller variable because
it keeps init simple.
Compile tested only.
Signed-off-by: NSebastian Andrzej Siewior <sebastian@breakpoint.cc>
Signed-off-by: NFelipe Balbi <balbi@ti.com>
上级 504d14c4
...@@ -1237,14 +1237,15 @@ irq_handler_t intr_handler(int i) ...@@ -1237,14 +1237,15 @@ irq_handler_t intr_handler(int i)
******************************************************************************* *******************************************************************************
*/ */
static int imx_udc_start(struct usb_gadget_driver *driver, static int imx_udc_start(struct usb_gadget *gadget,
int (*bind)(struct usb_gadget *)); struct usb_gadget_driver *driver);
static int imx_udc_stop(struct usb_gadget_driver *driver); static int imx_udc_stop(struct usb_gadget *gadget,
struct usb_gadget_driver *driver);
static const struct usb_gadget_ops imx_udc_ops = { static const struct usb_gadget_ops imx_udc_ops = {
.get_frame = imx_udc_get_frame, .get_frame = imx_udc_get_frame,
.wakeup = imx_udc_wakeup, .wakeup = imx_udc_wakeup,
.start = imx_udc_start, .udc_start = imx_udc_start,
.stop = imx_udc_stop, .udc_stop = imx_udc_stop,
}; };
static struct imx_udc_struct controller = { static struct imx_udc_struct controller = {
...@@ -1329,23 +1330,13 @@ static struct imx_udc_struct controller = { ...@@ -1329,23 +1330,13 @@ static struct imx_udc_struct controller = {
* USB gadget driver functions * USB gadget driver functions
******************************************************************************* *******************************************************************************
*/ */
static int imx_udc_start(struct usb_gadget_driver *driver, static int imx_udc_start(struct usb_gadget *gadget,
int (*bind)(struct usb_gadget *)) struct usb_gadget_driver *driver)
{ {
struct imx_udc_struct *imx_usb = &controller; struct imx_udc_struct *imx_usb;
int retval; int retval;
if (!driver imx_usb = container_of(gadget, struct imx_udc_struct, gadget);
|| driver->max_speed < USB_SPEED_FULL
|| !bind
|| !driver->disconnect
|| !driver->setup)
return -EINVAL;
if (!imx_usb)
return -ENODEV;
if (imx_usb->driver)
return -EBUSY;
/* first hook up the driver ... */ /* first hook up the driver ... */
imx_usb->driver = driver; imx_usb->driver = driver;
imx_usb->gadget.dev.driver = &driver->driver; imx_usb->gadget.dev.driver = &driver->driver;
...@@ -1353,14 +1344,6 @@ static int imx_udc_start(struct usb_gadget_driver *driver, ...@@ -1353,14 +1344,6 @@ static int imx_udc_start(struct usb_gadget_driver *driver,
retval = device_add(&imx_usb->gadget.dev); retval = device_add(&imx_usb->gadget.dev);
if (retval) if (retval)
goto fail; goto fail;
retval = bind(&imx_usb->gadget);
if (retval) {
D_ERR(imx_usb->dev, "<%s> bind to driver %s --> error %d\n",
__func__, driver->driver.name, retval);
device_del(&imx_usb->gadget.dev);
goto fail;
}
D_INI(imx_usb->dev, "<%s> registered gadget driver '%s'\n", D_INI(imx_usb->dev, "<%s> registered gadget driver '%s'\n",
__func__, driver->driver.name); __func__, driver->driver.name);
...@@ -1374,20 +1357,16 @@ static int imx_udc_start(struct usb_gadget_driver *driver, ...@@ -1374,20 +1357,16 @@ static int imx_udc_start(struct usb_gadget_driver *driver,
return retval; return retval;
} }
static int imx_udc_stop(struct usb_gadget_driver *driver) static int imx_udc_stop(struct usb_gadget *gadget,
struct usb_gadget_driver *driver)
{ {
struct imx_udc_struct *imx_usb = &controller; struct imx_udc_struct *imx_usb = container_of(gadget,
struct imx_udc_struct, gadget);
if (!imx_usb)
return -ENODEV;
if (!driver || driver != imx_usb->driver || !driver->unbind)
return -EINVAL;
udc_stop_activity(imx_usb, driver); udc_stop_activity(imx_usb, driver);
imx_udc_disable(imx_usb); imx_udc_disable(imx_usb);
del_timer(&imx_usb->timer); del_timer(&imx_usb->timer);
driver->unbind(&imx_usb->gadget);
imx_usb->gadget.dev.driver = NULL; imx_usb->gadget.dev.driver = NULL;
imx_usb->driver = NULL; imx_usb->driver = NULL;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册