Commit dc9e2873 authored by Felipe Balbi's avatar Felipe Balbi

usb: chipidea: let udc-core manage gadget->dev

By simply setting a flag, we can drop some
boilerplate code.
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
parent 45f596a6
...@@ -1717,11 +1717,11 @@ static int udc_start(struct ci13xxx *ci) ...@@ -1717,11 +1717,11 @@ static int udc_start(struct ci13xxx *ci)
INIT_LIST_HEAD(&ci->gadget.ep_list); INIT_LIST_HEAD(&ci->gadget.ep_list);
dev_set_name(&ci->gadget.dev, "gadget");
ci->gadget.dev.dma_mask = dev->dma_mask; ci->gadget.dev.dma_mask = dev->dma_mask;
ci->gadget.dev.coherent_dma_mask = dev->coherent_dma_mask; ci->gadget.dev.coherent_dma_mask = dev->coherent_dma_mask;
ci->gadget.dev.parent = dev; ci->gadget.dev.parent = dev;
ci->gadget.dev.release = udc_release; ci->gadget.dev.release = udc_release;
ci->gadget.register_my_device = true;
/* alloc resources */ /* alloc resources */
ci->qh_pool = dma_pool_create("ci13xxx_qh", dev, ci->qh_pool = dma_pool_create("ci13xxx_qh", dev,
...@@ -1761,15 +1761,9 @@ static int udc_start(struct ci13xxx *ci) ...@@ -1761,15 +1761,9 @@ static int udc_start(struct ci13xxx *ci)
hw_enable_vbus_intr(ci); hw_enable_vbus_intr(ci);
} }
retval = device_register(&ci->gadget.dev);
if (retval) {
put_device(&ci->gadget.dev);
goto put_transceiver;
}
retval = dbg_create_files(ci->dev); retval = dbg_create_files(ci->dev);
if (retval) if (retval)
goto unreg_device; goto put_transceiver;
if (!IS_ERR_OR_NULL(ci->transceiver)) { if (!IS_ERR_OR_NULL(ci->transceiver)) {
retval = otg_set_peripheral(ci->transceiver->otg, retval = otg_set_peripheral(ci->transceiver->otg,
...@@ -1797,8 +1791,6 @@ static int udc_start(struct ci13xxx *ci) ...@@ -1797,8 +1791,6 @@ static int udc_start(struct ci13xxx *ci)
dev_err(dev, "error = %i\n", retval); dev_err(dev, "error = %i\n", retval);
remove_dbg: remove_dbg:
dbg_remove_files(ci->dev); dbg_remove_files(ci->dev);
unreg_device:
device_unregister(&ci->gadget.dev);
put_transceiver: put_transceiver:
if (!IS_ERR_OR_NULL(ci->transceiver) && ci->global_phy) if (!IS_ERR_OR_NULL(ci->transceiver) && ci->global_phy)
usb_put_phy(ci->transceiver); usb_put_phy(ci->transceiver);
...@@ -1837,7 +1829,6 @@ static void udc_stop(struct ci13xxx *ci) ...@@ -1837,7 +1829,6 @@ static void udc_stop(struct ci13xxx *ci)
usb_put_phy(ci->transceiver); usb_put_phy(ci->transceiver);
} }
dbg_remove_files(ci->dev); dbg_remove_files(ci->dev);
device_unregister(&ci->gadget.dev);
/* my kobject is dynamic, I swear! */ /* my kobject is dynamic, I swear! */
memset(&ci->gadget, 0, sizeof(ci->gadget)); memset(&ci->gadget, 0, sizeof(ci->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