From patchwork Tue Apr 15 01:42:42 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Bresticker X-Patchwork-Id: 3988291 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 244C89F3E2 for ; Tue, 15 Apr 2014 01:46:09 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5A350201FE for ; Tue, 15 Apr 2014 01:46:08 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8169F201EC for ; Tue, 15 Apr 2014 01:46:07 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WZsPI-0003yw-5X; Tue, 15 Apr 2014 01:43:28 +0000 Received: from mail-pa0-f73.google.com ([209.85.220.73]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WZsP4-0003td-VB for linux-arm-kernel@lists.infradead.org; Tue, 15 Apr 2014 01:43:15 +0000 Received: by mail-pa0-f73.google.com with SMTP id kq14so1163179pab.2 for ; Mon, 14 Apr 2014 18:42:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=TYtcbDzlnfHyqPtzFAU2oXkYa8AfKmQCie0j6or9EKA=; b=lXaQ5GuzpBaFqUauAevBIGXd6slg/KLHsJ8Qh0gVdxtdlJsjeOHtyfYO7APbzM3WJY ejnWyP7GnQzKQdL+KGUo3U17CAAp5ZBI4PjAyEr79eG7nCBVTaFHEHYXurbRI3CMBa9z Cmw39H6E0SJMxTuV/XsqAp5xC9iuxUgbPR8BfRRQx+6o2lrIQybhA/M7M+uQXwipwUAf cnH5ld4vhsOArbocvQLwjkkNOBJxPrvqw5HBL+ZP4b87w2044XLHJV/Wl5jDNzylo0N4 4SzS6NCAzZ2jVkjLYNe3Zj3Q/tkaofqi1bK3kfIfn24wZaCgn8Eb+Hb7Lmv+IMTvdZCt 5NHA== X-Gm-Message-State: ALoCoQlxBA4FOBaBQK2YjjQe1q6BdbxIoel8yvYmS30QscoHk4ovxp0xZk+Klr0Dv1J/7+oqnV6xT48X7dkYyQyDmaMBGHYyg167UFsHntRY0XOfH85IDu5MDCbAPaMLyooHNaxvLBgrZphwVEa8e+b3fGtQ2UkchuL7djgBcv5KnH/am96FMYYVSlfRko/4TVuGp+zc7lEuq7NyHSlUabnDdki9Rfm1Jg== X-Received: by 10.66.65.109 with SMTP id w13mr21398412pas.21.1397526174196; Mon, 14 Apr 2014 18:42:54 -0700 (PDT) Received: from corp2gmr1-1.hot.corp.google.com (corp2gmr1-1.hot.corp.google.com [172.24.189.92]) by gmr-mx.google.com with ESMTPS id s65si2520531yhc.2.2014.04.14.18.42.54 for (version=TLSv1.1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 14 Apr 2014 18:42:54 -0700 (PDT) Received: from abrestic.mtv.corp.google.com (abrestic.mtv.corp.google.com [172.22.72.111]) by corp2gmr1-1.hot.corp.google.com (Postfix) with ESMTP id F26C331C1E3; Mon, 14 Apr 2014 18:42:53 -0700 (PDT) Received: by abrestic.mtv.corp.google.com (Postfix, from userid 137652) id B6657220757; Mon, 14 Apr 2014 18:42:53 -0700 (PDT) From: Andrew Bresticker To: Stephen Warren , Thierry Reding , Chris Ball , Ulf Hansson Subject: [PATCH 3/4] mmc: sdhci: defer probing on regulator_get_optional() failures Date: Mon, 14 Apr 2014 18:42:42 -0700 Message-Id: <1397526163-20126-4-git-send-email-abrestic@chromium.org> X-Mailer: git-send-email 1.9.1.423.g4596e3a In-Reply-To: <1397526163-20126-1-git-send-email-abrestic@chromium.org> References: <1397526163-20126-1-git-send-email-abrestic@chromium.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140414_184315_022179_DE8D7BB2 X-CRM114-Status: GOOD ( 13.73 ) X-Spam-Score: -1.7 (-) Cc: linux-tegra@vger.kernel.org, Andrew Bresticker , linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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; }