aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/dwc3/core.c
diff options
context:
space:
mode:
authorRoger Quadros <rogerq@ti.com>2016-06-10 14:38:02 +0300
committerFelipe Balbi <felipe.balbi@linux.intel.com>2016-06-21 10:38:43 +0300
commit328082376aea6016b63bca1e5c067a9539f9e8c9 (patch)
tree015614fec0a9c5ad9014f5892b8aa9ec0ac5381b /drivers/usb/dwc3/core.c
parentusb: dwc3: gadget: simplify run_stop() break condition (diff)
downloadlinux-dev-328082376aea6016b63bca1e5c067a9539f9e8c9.tar.xz
linux-dev-328082376aea6016b63bca1e5c067a9539f9e8c9.zip
usb: dwc3: fix runtime PM in error path
If there is a failure after pm_runtime_enable/get_sync() we need to call pm_runtime_disable/put_sync(). Otherwise it will lead to an unbalanced pm_runtime_enable() on the subsequent probe if the earlier probe bailed out due to -EPROBE_DEFER. pm_runtime_get_sync() can fail as well so deal with that case too. Signed-off-by: Roger Quadros <rogerq@ti.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Diffstat (limited to 'drivers/usb/dwc3/core.c')
-rw-r--r--drivers/usb/dwc3/core.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 8fceeb1a32a4..ca22e4885116 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -965,14 +965,17 @@ static int dwc3_probe(struct platform_device *pdev)
pm_runtime_use_autosuspend(dev);
pm_runtime_set_autosuspend_delay(dev, DWC3_DEFAULT_AUTOSUSPEND_DELAY);
pm_runtime_enable(dev);
- pm_runtime_get_sync(dev);
+ ret = pm_runtime_get_sync(dev);
+ if (ret < 0)
+ goto err1;
+
pm_runtime_forbid(dev);
ret = dwc3_alloc_event_buffers(dwc, DWC3_EVENT_BUFFERS_SIZE);
if (ret) {
dev_err(dwc->dev, "failed to allocate event buffers\n");
ret = -ENOMEM;
- goto err0;
+ goto err2;
}
if (IS_ENABLED(CONFIG_USB_DWC3_HOST) &&
@@ -989,12 +992,12 @@ static int dwc3_probe(struct platform_device *pdev)
ret = dwc3_alloc_scratch_buffers(dwc);
if (ret)
- goto err1;
+ goto err3;
ret = dwc3_core_init(dwc);
if (ret) {
dev_err(dev, "failed to initialize core\n");
- goto err2;
+ goto err4;
}
/* Check the maximum_speed parameter */
@@ -1026,23 +1029,30 @@ static int dwc3_probe(struct platform_device *pdev)
ret = dwc3_core_init_mode(dwc);
if (ret)
- goto err3;
+ goto err5;
dwc3_debugfs_init(dwc);
pm_runtime_put(dev);
return 0;
-err3:
+err5:
dwc3_event_buffers_cleanup(dwc);
-err2:
+err4:
dwc3_free_scratch_buffers(dwc);
-err1:
+err3:
dwc3_free_event_buffers(dwc);
dwc3_ulpi_exit(dwc);
+err2:
+ pm_runtime_allow(&pdev->dev);
+
+err1:
+ pm_runtime_put_sync(&pdev->dev);
+ pm_runtime_disable(&pdev->dev);
+
err0:
/*
* restore res->start back to its original value so that, in case the