Skip to content

Commit

Permalink
usb: gadget: fusb300_udc: convert to udc_start/udc_stop
Browse files Browse the repository at this point in the history
Mechanical change making use of the new (can we
still call it new ?) interface for registering
UDC drivers.

Signed-off-by: Felipe Balbi <balbi@ti.com>
  • Loading branch information
Felipe Balbi committed Jan 24, 2013
1 parent 45005f6 commit 8de94ff
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 47 deletions.
65 changes: 18 additions & 47 deletions drivers/usb/gadget/fusb300_udc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1308,65 +1308,28 @@ static void init_controller(struct fusb300 *fusb300)
iowrite32(0xcfffff9f, fusb300->reg + FUSB300_OFFSET_IGER1);
}
/*------------------------------------------------------------------------*/
static struct fusb300 *the_controller;

static int fusb300_udc_start(struct usb_gadget_driver *driver,
int (*bind)(struct usb_gadget *, struct usb_gadget_driver *))
static int fusb300_udc_start(struct usb_gadget *g,
struct usb_gadget_driver *driver)
{
struct fusb300 *fusb300 = the_controller;
int retval;

if (!driver
|| driver->max_speed < USB_SPEED_FULL
|| !bind
|| !driver->setup)
return -EINVAL;

if (!fusb300)
return -ENODEV;

if (fusb300->driver)
return -EBUSY;
struct fusb300 *fusb300 = to_fusb300(g);

/* hook up the driver */
driver->driver.bus = NULL;
fusb300->driver = driver;
fusb300->gadget.dev.driver = &driver->driver;

retval = device_add(&fusb300->gadget.dev);
if (retval) {
pr_err("device_add error (%d)\n", retval);
goto error;
}

retval = bind(&fusb300->gadget, driver);
if (retval) {
pr_err("bind to driver error (%d)\n", retval);
device_del(&fusb300->gadget.dev);
goto error;
}

return 0;

error:
fusb300->driver = NULL;
fusb300->gadget.dev.driver = NULL;

return retval;
}

static int fusb300_udc_stop(struct usb_gadget_driver *driver)
static int fusb300_udc_stop(struct usb_gadget *g,
struct usb_gadget_driver *driver)
{
struct fusb300 *fusb300 = the_controller;

if (driver != fusb300->driver || !driver->unbind)
return -EINVAL;
struct fusb300 *fusb300 = to_fusb300(g);

driver->unbind(&fusb300->gadget);
fusb300->gadget.dev.driver = NULL;

init_controller(fusb300);
device_del(&fusb300->gadget.dev);
fusb300->driver = NULL;

return 0;
Expand All @@ -1380,8 +1343,8 @@ static int fusb300_udc_pullup(struct usb_gadget *_gadget, int is_active)

static struct usb_gadget_ops fusb300_gadget_ops = {
.pullup = fusb300_udc_pullup,
.start = fusb300_udc_start,
.stop = fusb300_udc_stop,
.udc_start = fusb300_udc_start,
.udc_stop = fusb300_udc_stop,
};

static int __exit fusb300_remove(struct platform_device *pdev)
Expand Down Expand Up @@ -1505,8 +1468,6 @@ static int __init fusb300_probe(struct platform_device *pdev)
fusb300->gadget.ep0 = &fusb300->ep[0]->ep;
INIT_LIST_HEAD(&fusb300->gadget.ep0->ep_list);

the_controller = fusb300;

fusb300->ep0_req = fusb300_alloc_request(&fusb300->ep[0]->ep,
GFP_KERNEL);
if (fusb300->ep0_req == NULL)
Expand All @@ -1517,9 +1478,19 @@ static int __init fusb300_probe(struct platform_device *pdev)
if (ret)
goto err_add_udc;

ret = device_add(&fusb300->gadget.dev);
if (ret) {
pr_err("device_add error (%d)\n", ret);
goto err_add_device;
}

dev_info(&pdev->dev, "version %s\n", DRIVER_VERSION);

return 0;

err_add_device:
usb_del_gadget_udc(&fusb300->gadget);

err_add_udc:
fusb300_free_request(&fusb300->ep[0]->ep, fusb300->ep0_req);

Expand Down
2 changes: 2 additions & 0 deletions drivers/usb/gadget/fusb300_udc.h
Original file line number Diff line number Diff line change
Expand Up @@ -673,4 +673,6 @@ struct fusb300 {
u8 reenum; /* if re-enumeration */
};

#define to_fusb300(g) (container_of((g), struct fusb300, gadget))

#endif

0 comments on commit 8de94ff

Please sign in to comment.