Commit 3381fb60 authored by Felipe Balbi's avatar Felipe Balbi

usb: gadget: m66592-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 eb65796e
...@@ -1463,42 +1463,16 @@ static struct usb_ep_ops m66592_ep_ops = { ...@@ -1463,42 +1463,16 @@ static struct usb_ep_ops m66592_ep_ops = {
}; };
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
static struct m66592 *the_controller; static int m66592_udc_start(struct usb_gadget *g,
struct usb_gadget_driver *driver)
static int m66592_start(struct usb_gadget_driver *driver,
int (*bind)(struct usb_gadget *, struct usb_gadget_driver *))
{ {
struct m66592 *m66592 = the_controller; struct m66592 *m66592 = to_m66592(g);
int retval;
if (!driver
|| driver->max_speed < USB_SPEED_HIGH
|| !bind
|| !driver->setup)
return -EINVAL;
if (!m66592)
return -ENODEV;
if (m66592->driver)
return -EBUSY;
/* hook up the driver */ /* hook up the driver */
driver->driver.bus = NULL; driver->driver.bus = NULL;
m66592->driver = driver; m66592->driver = driver;
m66592->gadget.dev.driver = &driver->driver; m66592->gadget.dev.driver = &driver->driver;
retval = device_add(&m66592->gadget.dev);
if (retval) {
pr_err("device_add error (%d)\n", retval);
goto error;
}
retval = bind(&m66592->gadget, driver);
if (retval) {
pr_err("bind to driver error (%d)\n", retval);
device_del(&m66592->gadget.dev);
goto error;
}
m66592_bset(m66592, M66592_VBSE | M66592_URST, M66592_INTENB0); m66592_bset(m66592, M66592_VBSE | M66592_URST, M66592_INTENB0);
if (m66592_read(m66592, M66592_INTSTS0) & M66592_VBSTS) { if (m66592_read(m66592, M66592_INTSTS0) & M66592_VBSTS) {
m66592_start_xclock(m66592); m66592_start_xclock(m66592);
...@@ -1510,26 +1484,12 @@ static int m66592_start(struct usb_gadget_driver *driver, ...@@ -1510,26 +1484,12 @@ static int m66592_start(struct usb_gadget_driver *driver,
} }
return 0; return 0;
error:
m66592->driver = NULL;
m66592->gadget.dev.driver = NULL;
return retval;
} }
static int m66592_stop(struct usb_gadget_driver *driver) static int m66592_udc_stop(struct usb_gadget *g,
struct usb_gadget_driver *driver)
{ {
struct m66592 *m66592 = the_controller; struct m66592 *m66592 = to_m66592(g);
unsigned long flags;
if (driver != m66592->driver || !driver->unbind)
return -EINVAL;
spin_lock_irqsave(&m66592->lock, flags);
if (m66592->gadget.speed != USB_SPEED_UNKNOWN)
m66592_usb_disconnect(m66592);
spin_unlock_irqrestore(&m66592->lock, flags);
m66592_bclr(m66592, M66592_VBSE | M66592_URST, M66592_INTENB0); m66592_bclr(m66592, M66592_VBSE | M66592_URST, M66592_INTENB0);
...@@ -1539,8 +1499,8 @@ static int m66592_stop(struct usb_gadget_driver *driver) ...@@ -1539,8 +1499,8 @@ static int m66592_stop(struct usb_gadget_driver *driver)
init_controller(m66592); init_controller(m66592);
disable_controller(m66592); disable_controller(m66592);
device_del(&m66592->gadget.dev);
m66592->driver = NULL; m66592->driver = NULL;
return 0; return 0;
} }
...@@ -1568,8 +1528,8 @@ static int m66592_pullup(struct usb_gadget *gadget, int is_on) ...@@ -1568,8 +1528,8 @@ static int m66592_pullup(struct usb_gadget *gadget, int is_on)
static struct usb_gadget_ops m66592_gadget_ops = { static struct usb_gadget_ops m66592_gadget_ops = {
.get_frame = m66592_get_frame, .get_frame = m66592_get_frame,
.start = m66592_start, .udc_start = m66592_udc_start,
.stop = m66592_stop, .udc_stop = m66592_udc_stop,
.pullup = m66592_pullup, .pullup = m66592_pullup,
}; };
...@@ -1578,6 +1538,7 @@ static int __exit m66592_remove(struct platform_device *pdev) ...@@ -1578,6 +1538,7 @@ static int __exit m66592_remove(struct platform_device *pdev)
struct m66592 *m66592 = dev_get_drvdata(&pdev->dev); struct m66592 *m66592 = dev_get_drvdata(&pdev->dev);
usb_del_gadget_udc(&m66592->gadget); usb_del_gadget_udc(&m66592->gadget);
device_del(&m66592->gadget.dev);
del_timer_sync(&m66592->timer); del_timer_sync(&m66592->timer);
iounmap(m66592->reg); iounmap(m66592->reg);
...@@ -1706,8 +1667,6 @@ static int __init m66592_probe(struct platform_device *pdev) ...@@ -1706,8 +1667,6 @@ static int __init m66592_probe(struct platform_device *pdev)
m66592->pipenum2ep[0] = &m66592->ep[0]; m66592->pipenum2ep[0] = &m66592->ep[0];
m66592->epaddr2ep[0] = &m66592->ep[0]; m66592->epaddr2ep[0] = &m66592->ep[0];
the_controller = m66592;
m66592->ep0_req = m66592_alloc_request(&m66592->ep[0].ep, GFP_KERNEL); m66592->ep0_req = m66592_alloc_request(&m66592->ep[0].ep, GFP_KERNEL);
if (m66592->ep0_req == NULL) if (m66592->ep0_req == NULL)
goto clean_up3; goto clean_up3;
...@@ -1715,6 +1674,12 @@ static int __init m66592_probe(struct platform_device *pdev) ...@@ -1715,6 +1674,12 @@ static int __init m66592_probe(struct platform_device *pdev)
init_controller(m66592); init_controller(m66592);
ret = device_add(&m66592->gadget.dev);
if (ret) {
pr_err("device_add error (%d)\n", ret);
goto err_device_add;
}
ret = usb_add_gadget_udc(&pdev->dev, &m66592->gadget); ret = usb_add_gadget_udc(&pdev->dev, &m66592->gadget);
if (ret) if (ret)
goto err_add_udc; goto err_add_udc;
...@@ -1723,6 +1688,9 @@ static int __init m66592_probe(struct platform_device *pdev) ...@@ -1723,6 +1688,9 @@ static int __init m66592_probe(struct platform_device *pdev)
return 0; return 0;
err_add_udc: err_add_udc:
device_del(&m66592->gadget.dev);
err_device_add:
m66592_free_request(&m66592->ep[0].ep, m66592->ep0_req); m66592_free_request(&m66592->ep[0].ep, m66592->ep0_req);
clean_up3: clean_up3:
......
...@@ -492,6 +492,7 @@ struct m66592 { ...@@ -492,6 +492,7 @@ struct m66592 {
int isochronous; int isochronous;
int num_dma; int num_dma;
}; };
#define to_m66592(g) (container_of((g), struct m66592, gadget))
#define gadget_to_m66592(_gadget) container_of(_gadget, struct m66592, gadget) #define gadget_to_m66592(_gadget) container_of(_gadget, struct m66592, gadget)
#define m66592_to_gadget(m66592) (&m66592->gadget) #define m66592_to_gadget(m66592) (&m66592->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