/* Returns 0 if no error, -ENODEV, -EINVAL otherwise  */
int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
/* Returns 0 if no error, -ENODEV, -EINVAL otherwise  */
int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
{
	struct pxa_udc *udc = the_controller;
	if (!udc)
		return -ENODEV;
	if (!driver || driver != udc->driver || !driver->unbind)
		return -EINVAL;
	stop_activity(udc, driver);
	udc_disable(udc);
	dplus_pullup(udc, 0);
	driver->unbind(&udc->gadget);
	udc->driver = NULL;
	device_del(&udc->gadget.dev);
	dev_info(udc->dev, "unregistered gadget driver '%s'\n",
		 driver->driver.name);
	if (udc->transceiver)
		return otg_set_peripheral(udc->transceiver, NULL);
	return 0;
}