usb: gadget: r8a66597: convert to new style

convert to new style UDC registration and remove
the global 'the_controller' pointer.

Signed-off-by: Felipe Balbi <balbi@ti.com>
This commit is contained in:
Felipe Balbi 2011-10-10 17:18:51 +03:00
Родитель af1d7056a5
Коммит 478ff25ade
1 изменённых файлов: 8 добавлений и 29 удалений

Просмотреть файл

@ -1738,23 +1738,18 @@ static struct usb_ep_ops r8a66597_ep_ops = {
}; };
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
static struct r8a66597 *the_controller; static int r8a66597_start(struct usb_gadget *gadget,
struct usb_gadget_driver *driver)
static int r8a66597_start(struct usb_gadget_driver *driver,
int (*bind)(struct usb_gadget *))
{ {
struct r8a66597 *r8a66597 = the_controller; struct r8a66597 *r8a66597 = gadget_to_r8a66597(gadget);
int retval; int retval;
if (!driver if (!driver
|| driver->speed != USB_SPEED_HIGH || driver->speed != USB_SPEED_HIGH
|| !bind
|| !driver->setup) || !driver->setup)
return -EINVAL; return -EINVAL;
if (!r8a66597) if (!r8a66597)
return -ENODEV; return -ENODEV;
if (r8a66597->driver)
return -EBUSY;
/* hook up the driver */ /* hook up the driver */
driver->driver.bus = NULL; driver->driver.bus = NULL;
@ -1768,14 +1763,6 @@ static int r8a66597_start(struct usb_gadget_driver *driver,
goto error; goto error;
} }
retval = bind(&r8a66597->gadget);
if (retval) {
dev_err(r8a66597_to_dev(r8a66597),
"bind to driver error (%d)\n", retval);
device_del(&r8a66597->gadget.dev);
goto error;
}
init_controller(r8a66597); init_controller(r8a66597);
r8a66597_bset(r8a66597, VBSE, INTENB0); r8a66597_bset(r8a66597, VBSE, INTENB0);
if (r8a66597_read(r8a66597, INTSTS0) & VBSTS) { if (r8a66597_read(r8a66597, INTSTS0) & VBSTS) {
@ -1796,23 +1783,17 @@ error:
return retval; return retval;
} }
static int r8a66597_stop(struct usb_gadget_driver *driver) static int r8a66597_stop(struct usb_gadget *gadget,
struct usb_gadget_driver *driver)
{ {
struct r8a66597 *r8a66597 = the_controller; struct r8a66597 *r8a66597 = gadget_to_r8a66597(gadget);
unsigned long flags; unsigned long flags;
if (driver != r8a66597->driver || !driver->unbind)
return -EINVAL;
spin_lock_irqsave(&r8a66597->lock, flags); spin_lock_irqsave(&r8a66597->lock, flags);
if (r8a66597->gadget.speed != USB_SPEED_UNKNOWN)
r8a66597_usb_disconnect(r8a66597);
r8a66597_bclr(r8a66597, VBSE, INTENB0); r8a66597_bclr(r8a66597, VBSE, INTENB0);
disable_controller(r8a66597); disable_controller(r8a66597);
spin_unlock_irqrestore(&r8a66597->lock, flags); spin_unlock_irqrestore(&r8a66597->lock, flags);
driver->unbind(&r8a66597->gadget);
device_del(&r8a66597->gadget.dev); device_del(&r8a66597->gadget.dev);
r8a66597->driver = NULL; r8a66597->driver = NULL;
return 0; return 0;
@ -1842,8 +1823,8 @@ static int r8a66597_pullup(struct usb_gadget *gadget, int is_on)
static struct usb_gadget_ops r8a66597_gadget_ops = { static struct usb_gadget_ops r8a66597_gadget_ops = {
.get_frame = r8a66597_get_frame, .get_frame = r8a66597_get_frame,
.start = r8a66597_start, .udc_start = r8a66597_start,
.stop = r8a66597_stop, .udc_stop = r8a66597_stop,
.pullup = r8a66597_pullup, .pullup = r8a66597_pullup,
}; };
@ -2010,8 +1991,6 @@ static int __init r8a66597_probe(struct platform_device *pdev)
r8a66597->pipenum2ep[0] = &r8a66597->ep[0]; r8a66597->pipenum2ep[0] = &r8a66597->ep[0];
r8a66597->epaddr2ep[0] = &r8a66597->ep[0]; r8a66597->epaddr2ep[0] = &r8a66597->ep[0];
the_controller = r8a66597;
r8a66597->ep0_req = r8a66597_alloc_request(&r8a66597->ep[0].ep, r8a66597->ep0_req = r8a66597_alloc_request(&r8a66597->ep[0].ep,
GFP_KERNEL); GFP_KERNEL);
if (r8a66597->ep0_req == NULL) if (r8a66597->ep0_req == NULL)