diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 5b5f6831d9f3..9d1f7db937d0 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -2085,23 +2085,14 @@ static int dwc3_get_num_ports(struct dwc3 *dwc) return 0; } -struct dwc3 *dwc3_probe(struct platform_device *pdev, struct resource *res, - bool ignore_clocks_and_resets, void *glue) +int dwc3_init(struct dwc3 *dwc, struct resource *res, bool ignore_clocks_and_resets) { - struct device *dev = &pdev->dev; + struct device *dev = dwc->dev; struct resource dwc_res; unsigned int hw_mode; void __iomem *regs; - struct dwc3 *dwc; int ret; - dwc = devm_kzalloc(dev, sizeof(*dwc), GFP_KERNEL); - if (!dwc) - return ERR_PTR(-ENOMEM); - - dwc->dev = dev; - dwc->glue = glue; - dwc->xhci_resources[0].start = res->start; dwc->xhci_resources[0].end = dwc->xhci_resources[0].start + DWC3_XHCI_REGS_END; @@ -2163,7 +2154,7 @@ struct dwc3 *dwc3_probe(struct platform_device *pdev, struct resource *res, goto err_disable_clks; } - platform_set_drvdata(pdev, dwc); + dev_set_drvdata(dev, dwc); dwc3_cache_hwparams(dwc); if (!dwc->sysdev_is_parent && @@ -2271,16 +2262,20 @@ static int dwc3_plat_probe(struct platform_device *pdev) return -ENODEV; } - dwc = dwc3_probe(pdev, res, false, NULL); - if (IS_ERR(dwc)) - return PTR_ERR(dwc); + dwc = devm_kzalloc(&pdev->dev, sizeof(*dwc), GFP_KERNEL); + if (!dwc) + return ERR_PTR(-ENOMEM); - platform_set_drvdata(pdev, dwc); + dwc->dev = &pdev->dev; + + ret = dwc3_init(dwc, res, false); + if (ret) + return ret; return 0; } -void dwc3_remove(struct dwc3 *dwc) +void dwc3_uninit(struct dwc3 *dwc) { pm_runtime_get_sync(dwc->dev); @@ -2306,11 +2301,11 @@ void dwc3_remove(struct dwc3 *dwc) if (dwc->usb_psy) power_supply_put(dwc->usb_psy); } -EXPORT_SYMBOL_GPL(dwc3_remove); +EXPORT_SYMBOL_GPL(dwc3_uninit); -static void dwc3_plat_remove(struct platform_device *pdev) +static void dwc3_remove(struct platform_device *pdev) { - dwc3_remove(platform_get_drvdata(pdev)); + dwc3_uninit(platform_get_drvdata(pdev)); } #ifdef CONFIG_PM @@ -2656,8 +2651,8 @@ MODULE_DEVICE_TABLE(acpi, dwc3_acpi_match); #endif static struct platform_driver dwc3_driver = { - .probe = dwc3_plat_probe, - .remove_new = dwc3_plat_remove, + .probe = dwc3_probe, + .remove_new = dwc3_remove, .driver = { .name = "dwc3", .of_match_table = of_match_ptr(of_dwc3_match), diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index 4a0ee9ef72e2..1e561fd8b86e 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h @@ -1160,7 +1160,6 @@ struct dwc3_scratchpad_array { * @gsbuscfg0_reqinfo: store GSBUSCFG0.DATRDREQINFO, DESRDREQINFO, * DATWRREQINFO, and DESWRREQINFO value passed from * glue driver. - * @glue: private reference to any glue context */ struct dwc3 { struct work_struct drd_work; @@ -1389,8 +1388,6 @@ struct dwc3 { int num_ep_resized; struct dentry *debug_root; u32 gsbuscfg0_reqinfo; - - void *glue; }; #define INCRX_BURST_MODE 0 diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c index 27b5013cd411..e9088a8873a8 100644 --- a/drivers/usb/dwc3/dwc3-qcom.c +++ b/drivers/usb/dwc3/dwc3-qcom.c @@ -76,7 +76,7 @@ struct dwc3_qcom_port { struct dwc3_qcom { struct device *dev; void __iomem *qscratch_base; - struct dwc3 *dwc; + struct dwc3 dwc; struct clk **clks; int num_clocks; struct reset_control *resets; @@ -964,9 +964,11 @@ static int dwc3_qcom_probe(struct platform_device *pdev) if (ignore_pipe_clk) dwc3_qcom_select_utmi_clk(qcom); - qcom->dwc = dwc3_probe(pdev, &res, true, qcom); - if (IS_ERR(qcom->dwc)) { - ret = dev_err_probe(dev, PTR_ERR(qcom->dwc), "failed to register DWC3 Core\n"); + qcom->dwc.dev = dev; + + ret = dwc3_init(&qcom->dwc, &res, true); + if (ret) { + ret = dev_err_probe(dev, ret, "failed to register DWC3 Core\n"); goto clk_disable; } @@ -995,7 +997,7 @@ static int dwc3_qcom_probe(struct platform_device *pdev) interconnect_exit: dwc3_qcom_interconnect_exit(qcom); remove_core: - dwc3_remove(qcom->dwc); + dwc3_uninit(qcom->dwc); clk_disable: for (i = qcom->num_clocks - 1; i >= 0; i--) { clk_disable_unprepare(qcom->clks[i]); @@ -1010,7 +1012,7 @@ static int dwc3_qcom_probe(struct platform_device *pdev) static void dwc3_qcom_remove(struct platform_device *pdev) { struct dwc3 *dwc = platform_get_drvdata(pdev); - struct dwc3_qcom *qcom = dwc->glue; + struct dwc3_qcom *qcom = to_dwc3_qcom(dwc); struct device *dev = &pdev->dev; int i; @@ -1030,7 +1032,7 @@ static void dwc3_qcom_remove(struct platform_device *pdev) static int __maybe_unused dwc3_qcom_pm_suspend(struct device *dev) { struct dwc3 *dwc = dev_get_drvdata(dev); - struct dwc3_qcom *qcom = dwc->glue; + struct dwc3_qcom *qcom = to_dwc3_qcom(dwc); bool wakeup = device_may_wakeup(dev); int ret; @@ -1050,7 +1052,7 @@ static int __maybe_unused dwc3_qcom_pm_suspend(struct device *dev) static int __maybe_unused dwc3_qcom_pm_resume(struct device *dev) { struct dwc3 *dwc = dev_get_drvdata(dev); - struct dwc3_qcom *qcom = dwc->glue; + struct dwc3_qcom *qcom = to_dwc3_qcom(dwc); bool wakeup = device_may_wakeup(dev); int ret; @@ -1070,7 +1072,7 @@ static int __maybe_unused dwc3_qcom_pm_resume(struct device *dev) static int __maybe_unused dwc3_qcom_runtime_suspend(struct device *dev) { struct dwc3 *dwc = dev_get_drvdata(dev); - struct dwc3_qcom *qcom = dwc->glue; + struct dwc3_qcom *qcom = to_dwc3_qcom(dwc); int ret; ret = dwc3_runtime_suspend(qcom->dwc); @@ -1090,7 +1092,7 @@ static void __maybe_unused dwc3_qcom_complete(struct device *dev) static int __maybe_unused dwc3_qcom_runtime_resume(struct device *dev) { struct dwc3 *dwc = dev_get_drvdata(dev); - struct dwc3_qcom *qcom = dwc->glue; + struct dwc3_qcom *qcom = to_dwc3_qcom(dwc); int ret; ret = dwc3_qcom_resume(qcom, true);