summaryrefslogtreecommitdiff
path: root/drivers/usb
diff options
context:
space:
mode:
authorFelipe Balbi <balbi@ti.com>2013-01-24 14:52:24 +0200
committerFelipe Balbi <balbi@ti.com>2013-03-18 11:16:39 +0200
commitf07bd56bbdaa2340ebf46af9a37e7b2d1b4578e3 (patch)
tree00e341ad9d37d01667a82462b76365ca353cfe37 /drivers/usb
parent7eaf8f2a7da6506df0e6edc4fdb22678f0eb3602 (diff)
downloadlinux-3.10-f07bd56bbdaa2340ebf46af9a37e7b2d1b4578e3.tar.gz
linux-3.10-f07bd56bbdaa2340ebf46af9a37e7b2d1b4578e3.tar.bz2
linux-3.10-f07bd56bbdaa2340ebf46af9a37e7b2d1b4578e3.zip
usb: gadget: udc-core: allow udc class register gadget device
Currently all UDC drivers are calling device_register() before calling usb_add_gadget_udc(). In order to avoid code duplication, we can allow udc-core.c register that device. However that would become a really large patch, so to cope with the meanwhile and allow us to write bite-sized patches, we're adding a flag which will be set by UDC driver once it removes the code for registering the gadget device. Once all are converted, the new flag will be removed. Reviewed-by: Tomasz Figa <tomasz.figa@gmail.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/gadget/udc-core.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/drivers/usb/gadget/udc-core.c b/drivers/usb/gadget/udc-core.c
index 2a9cd369f71..919505426ec 100644
--- a/drivers/usb/gadget/udc-core.c
+++ b/drivers/usb/gadget/udc-core.c
@@ -173,6 +173,14 @@ int usb_add_gadget_udc(struct device *parent, struct usb_gadget *gadget)
if (!udc)
goto err1;
+ if (gadget->register_my_device) {
+ dev_set_name(&gadget->dev, "gadget");
+
+ ret = device_register(&gadget->dev);
+ if (ret)
+ goto err2;
+ }
+
device_initialize(&udc->dev);
udc->dev.release = usb_udc_release;
udc->dev.class = udc_class;
@@ -180,7 +188,7 @@ int usb_add_gadget_udc(struct device *parent, struct usb_gadget *gadget)
udc->dev.parent = parent;
ret = dev_set_name(&udc->dev, "%s", kobject_name(&parent->kobj));
if (ret)
- goto err2;
+ goto err3;
udc->gadget = gadget;
@@ -189,18 +197,22 @@ int usb_add_gadget_udc(struct device *parent, struct usb_gadget *gadget)
ret = device_add(&udc->dev);
if (ret)
- goto err3;
+ goto err4;
mutex_unlock(&udc_lock);
return 0;
-err3:
+
+err4:
list_del(&udc->list);
mutex_unlock(&udc_lock);
-err2:
+err3:
put_device(&udc->dev);
+err2:
+ if (gadget->register_my_device)
+ put_device(&gadget->dev);
err1:
return ret;
}
@@ -254,6 +266,9 @@ found:
kobject_uevent(&udc->dev.kobj, KOBJ_REMOVE);
device_unregister(&udc->dev);
+
+ if (gadget->register_my_device)
+ device_unregister(&gadget->dev);
}
EXPORT_SYMBOL_GPL(usb_del_gadget_udc);