From: Roger Quadros <rogerq@ti.com>
To: <balbi@kernel.org>, <grygorii.strashko@ti.com>
Cc: <linux-usb@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
Roger Quadros <rogerq@ti.com>
Subject: [PATCH] usb: dwc3: fix runtime PM in error path
Date: Fri, 10 Jun 2016 11:54:38 +0300 [thread overview]
Message-ID: <1465548878-30085-1-git-send-email-rogerq@ti.com> (raw)
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.
Signed-off-by: Roger Quadros <rogerq@ti.com>
---
drivers/usb/dwc3/core.c | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 5bf38f8..222d2c9 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -1419,7 +1419,7 @@ static int dwc3_probe(struct platform_device *pdev)
if (ret) {
dev_err(dwc->dev, "failed to allocate event buffers\n");
ret = -ENOMEM;
- goto err0;
+ goto err1;
}
if (IS_ENABLED(CONFIG_USB_DWC3_HOST) &&
@@ -1436,12 +1436,12 @@ static int dwc3_probe(struct platform_device *pdev)
ret = dwc3_alloc_scratch_buffers(dwc);
if (ret)
- goto err1;
+ goto err2;
ret = dwc3_core_init(dwc);
if (ret) {
dev_err(dev, "failed to initialize core\n");
- goto err2;
+ goto err3;
}
/* Check the maximum_speed parameter */
@@ -1473,23 +1473,28 @@ static int dwc3_probe(struct platform_device *pdev)
ret = dwc3_core_init_mode(dwc);
if (ret)
- goto err3;
+ goto err4;
dwc3_debugfs_init(dwc);
pm_runtime_put(dev);
return 0;
-err3:
+err4:
dwc3_event_buffers_cleanup(dwc);
-err2:
+err3:
dwc3_free_scratch_buffers(dwc);
-err1:
+err2:
dwc3_free_event_buffers(dwc);
dwc3_ulpi_exit(dwc);
+err1:
+ pm_runtime_allow(&pdev->dev);
+ 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
--
2.7.4
next reply other threads:[~2016-06-10 8:54 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-10 8:54 Roger Quadros [this message]
2016-06-10 9:16 ` [PATCH] usb: dwc3: fix runtime PM in error path Felipe Balbi
2016-06-10 9:52 ` Roger Quadros
2016-06-10 10:05 ` Felipe Balbi
2016-06-10 11:37 ` [PATCH v2] " Roger Quadros
2016-06-10 11:38 ` Roger Quadros
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1465548878-30085-1-git-send-email-rogerq@ti.com \
--to=rogerq@ti.com \
--cc=balbi@kernel.org \
--cc=grygorii.strashko@ti.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).