From: abrestic@chromium.org (Andrew Bresticker)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 3/4] mmc: sdhci: defer probing on regulator_get_optional() failures
Date: Mon, 14 Apr 2014 18:42:42 -0700 [thread overview]
Message-ID: <1397526163-20126-4-git-send-email-abrestic@chromium.org> (raw)
In-Reply-To: <1397526163-20126-1-git-send-email-abrestic@chromium.org>
If regulator_get_optional() returns EPROBE_DEFER, it indicates
that the regulator may show up later (e.g. the DT property is
present but the corresponding regulator may not have probed).
Instead of continuing without the regulator, return EPROBE_DEFER
from sdhci_add_host(). Also, fix regulator leaks in the error
paths in sdhci_add_host().
Signed-off-by: Andrew Bresticker <abrestic@chromium.org>
---
drivers/mmc/host/sdhci.c | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 9a79fc4..e87c5d3 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -2978,7 +2978,9 @@ int sdhci_add_host(struct sdhci_host *host)
/* If vqmmc regulator and no 1.8V signalling, then there's no UHS */
host->vqmmc = regulator_get_optional(mmc_dev(mmc), "vqmmc");
if (IS_ERR_OR_NULL(host->vqmmc)) {
- if (PTR_ERR(host->vqmmc) < 0) {
+ if (PTR_ERR(host->vqmmc) == -EPROBE_DEFER) {
+ return PTR_ERR(host->vqmmc);
+ } else if (PTR_ERR(host->vqmmc) < 0) {
pr_info("%s: no vqmmc regulator found\n",
mmc_hostname(mmc));
host->vqmmc = NULL;
@@ -2993,6 +2995,7 @@ int sdhci_add_host(struct sdhci_host *host)
if (ret) {
pr_warn("%s: Failed to enable vqmmc regulator: %d\n",
mmc_hostname(mmc), ret);
+ regulator_put(host->vqmmc);
host->vqmmc = NULL;
}
}
@@ -3056,7 +3059,10 @@ int sdhci_add_host(struct sdhci_host *host)
host->vmmc = regulator_get_optional(mmc_dev(mmc), "vmmc");
if (IS_ERR_OR_NULL(host->vmmc)) {
- if (PTR_ERR(host->vmmc) < 0) {
+ if (PTR_ERR(host->vmmc) == -EPROBE_DEFER) {
+ ret = PTR_ERR(host->vmmc);
+ goto put_vqmmc;
+ } else if (PTR_ERR(host->vmmc) < 0) {
pr_info("%s: no vmmc regulator found\n",
mmc_hostname(mmc));
host->vmmc = NULL;
@@ -3150,7 +3156,8 @@ int sdhci_add_host(struct sdhci_host *host)
if (mmc->ocr_avail == 0) {
pr_err("%s: Hardware doesn't report any "
"support voltages.\n", mmc_hostname(mmc));
- return -ENODEV;
+ ret = -ENODEV;
+ goto put_vmmc;
}
spin_lock_init(&host->lock);
@@ -3280,6 +3287,12 @@ reset:
untasklet:
tasklet_kill(&host->card_tasklet);
tasklet_kill(&host->finish_tasklet);
+put_vmmc:
+ if (host->vmmc)
+ regulator_put(host->vmmc);
+put_vqmmc:
+ if (host->vqmmc)
+ regulator_put(host->vqmmc);
return ret;
}
--
1.9.1.423.g4596e3a
next prev parent reply other threads:[~2014-04-15 1:42 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-15 1:42 [PATCH 0/4] Tegra SD/MMC fixes Andrew Bresticker
2014-04-15 1:42 ` [PATCH 1/4] mmc: tegra: disable UHS modes Andrew Bresticker
2014-04-15 1:42 ` [PATCH 2/4] mmc: tegra: fix reporting of base clock frequency Andrew Bresticker
2014-04-15 18:25 ` Stephen Warren
2014-04-15 19:36 ` Andrew Bresticker
2014-04-15 1:42 ` Andrew Bresticker [this message]
2014-04-15 6:06 ` [PATCH 3/4] mmc: sdhci: defer probing on regulator_get_optional() failures Alexandre Courbot
2014-04-15 22:56 ` Andrew Bresticker
2014-04-15 18:28 ` Stephen Warren
2014-04-15 19:59 ` Andrew Bresticker
2014-04-15 20:42 ` Russell King - ARM Linux
2014-04-15 19:03 ` Tim Kryger
2014-04-15 19:44 ` Andrew Bresticker
2014-04-15 1:42 ` [PATCH 4/4] ARM: tegra: fix Venice2 VQMMC regulators Andrew Bresticker
2014-04-15 18:31 ` Stephen Warren
2014-04-15 19:12 ` Chris Ball
2014-04-16 0:29 ` Andrew Bresticker
2014-04-16 16:19 ` Stephen Warren
2014-04-16 20:24 ` Andrew Bresticker
2014-04-16 23:08 ` [PATCH v2 0/3] Tegra SD/MMC fixes Andrew Bresticker
2014-04-16 23:08 ` [PATCH v2 1/3] mmc: tegra: disable UHS modes Andrew Bresticker
2014-05-20 17:25 ` Stephen Warren
2014-05-21 0:43 ` Chris Ball
2014-05-22 11:00 ` Ulf Hansson
2014-05-22 15:25 ` Andrew Bresticker
2014-04-16 23:08 ` [PATCH v2 2/3] mmc: tegra: fix reporting of base clock frequency Andrew Bresticker
2014-04-16 23:08 ` [PATCH v2 3/3] ARM: tegra: fix Venice2 SD card VQMMC supply Andrew Bresticker
2014-04-16 23:16 ` Stephen Warren
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=1397526163-20126-4-git-send-email-abrestic@chromium.org \
--to=abrestic@chromium.org \
--cc=linux-arm-kernel@lists.infradead.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).