From patchwork Tue May 6 22:57:01 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tim Kryger X-Patchwork-Id: 29739 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ig0-f199.google.com (mail-ig0-f199.google.com [209.85.213.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C5D15202E6 for ; Tue, 6 May 2014 22:57:19 +0000 (UTC) Received: by mail-ig0-f199.google.com with SMTP id c1sf820759igq.2 for ; Tue, 06 May 2014 15:57:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :mime-version:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe:content-type; bh=tpWRx9mMKrCutgNCesZC0T9ar2U5TQzLwVkV8XjU2oY=; b=Fsp+0KtqMtGmEO7R9O6YyNLm/u8iR2SF2GhsI9Y5qZVt/28Wj3u86Ls53Ov4axClV9 UVG1sT2YKoLk7eO0wwFw5TnbFT1tQ0Xl/N+AKcMYFsAtDCN9jxF6ntcXZtQdXMFyUEFj yHt4bD/QBMKzz9cshbUdU0T+gBfG25ax7hfvcwxft9d2p+ukGkJkpvgX1hOQ7C9s2LTI SdWYe13vGgpQLkqS9SQV5hlnCuqATeTG7rUVcVIDHXZ54vhVqI3p3R6Ucm77o//xi+Qi hD6ZYs0EEKUbXY3XFi7CNsqhRAnPXIotw96gw9nuzMT3tsBAueGpPFTGGLDtZkRSLfdJ CsJw== X-Gm-Message-State: ALoCoQkD96Jo7H9h0xbxxpQQFQqJAqgYxOOvgF+kVOdZZLonONCbC7wC+Ioc2CFpzWjJ0houB+lU X-Received: by 10.43.92.68 with SMTP id bp4mr2470958icc.26.1399417039179; Tue, 06 May 2014 15:57:19 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.83.240 with SMTP id j103ls3108609qgd.47.gmail; Tue, 06 May 2014 15:57:19 -0700 (PDT) X-Received: by 10.52.141.74 with SMTP id rm10mr4435794vdb.6.1399417039022; Tue, 06 May 2014 15:57:19 -0700 (PDT) Received: from mail-ve0-f175.google.com (mail-ve0-f175.google.com [209.85.128.175]) by mx.google.com with ESMTPS id v14si2569349vco.111.2014.05.06.15.57.19 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 06 May 2014 15:57:19 -0700 (PDT) Received-SPF: none (google.com: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) client-ip=209.85.128.175; Received: by mail-ve0-f175.google.com with SMTP id jw12so218227veb.6 for ; Tue, 06 May 2014 15:57:18 -0700 (PDT) X-Received: by 10.52.13.41 with SMTP id e9mr22743177vdc.21.1399417038940; Tue, 06 May 2014 15:57:18 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp261475vcb; Tue, 6 May 2014 15:57:18 -0700 (PDT) X-Received: by 10.66.66.66 with SMTP id d2mr11399856pat.24.1399417037597; Tue, 06 May 2014 15:57:17 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id tf5si8910745pac.213.2014.05.06.15.57.16; Tue, 06 May 2014 15:57:16 -0700 (PDT) Received-SPF: none (google.com: linux-mmc-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751349AbaEFW5P (ORCPT + 6 others); Tue, 6 May 2014 18:57:15 -0400 Received: from mail-gw3-out.broadcom.com ([216.31.210.64]:37981 "EHLO mail-gw3-out.broadcom.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750912AbaEFW5O (ORCPT ); Tue, 6 May 2014 18:57:14 -0400 X-IronPort-AV: E=Sophos;i="4.97,998,1389772800"; d="scan'208";a="27853750" Received: from irvexchcas08.broadcom.com (HELO IRVEXCHCAS08.corp.ad.broadcom.com) ([10.9.208.57]) by mail-gw3-out.broadcom.com with ESMTP; 06 May 2014 16:18:29 -0700 Received: from IRVEXCHSMTP1.corp.ad.broadcom.com (10.9.207.51) by IRVEXCHCAS08.corp.ad.broadcom.com (10.9.208.57) with Microsoft SMTP Server (TLS) id 14.3.174.1; Tue, 6 May 2014 15:56:59 -0700 Received: from mail-sj1-12.sj.broadcom.com (10.10.10.20) by IRVEXCHSMTP1.corp.ad.broadcom.com (10.9.207.51) with Microsoft SMTP Server id 14.3.174.1; Tue, 6 May 2014 15:57:12 -0700 Received: from dhcp-sv1-10-19-114-209.sj.broadcom.com (mps-infra-lab3.sj.broadcom.com [10.19.114.109]) by mail-sj1-12.sj.broadcom.com (Postfix) with ESMTP id 8BD9127A81; Tue, 6 May 2014 15:57:12 -0700 (PDT) Received: by dhcp-sv1-10-19-114-209.sj.broadcom.com (Postfix, from userid 1004) id 4BA402520E80; Tue, 6 May 2014 15:57:12 -0700 (PDT) From: Tim Kryger To: Chris Ball , Ulf Hansson CC: Tim Kryger , Mike Looijmans , Andrew Bresticker , "Linux MMC List" , Linux Kernel Mailing List Subject: [PATCH v2] mmc: core: Improve support for deferred regulators Date: Tue, 6 May 2014 15:57:01 -0700 Message-ID: <1399417021-18873-1-git-send-email-tim.kryger@linaro.org> X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 Sender: linux-mmc-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: tim.kryger@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Callers of mmc_regulator_get_supply could benefit from knowing if either of the regulators are present but not yet available. Since callers do not currently examine the return value, modify this function to return zero or -EPROBE_DEFER if either regulator get returns the same. Furthermore, since callers check vmmc/vqmmc using IS_ERR and can deal with absent regulators, switch to devm_regulator_get_optional. This has the added benefit of allowing this function to behave correctly even in the !CONFIG_REGULATOR case such that the stub can be removed. Signed-off-by: Tim Kryger --- drivers/mmc/core/core.c | 31 +++++++++++++++++++------------ include/linux/mmc/host.h | 8 ++------ 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index acbc3f2..2d9f6c5 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -1310,31 +1310,38 @@ int mmc_regulator_set_ocr(struct mmc_host *mmc, } EXPORT_SYMBOL_GPL(mmc_regulator_set_ocr); +#endif /* CONFIG_REGULATOR */ + int mmc_regulator_get_supply(struct mmc_host *mmc) { struct device *dev = mmc_dev(mmc); - struct regulator *supply; int ret; - supply = devm_regulator_get(dev, "vmmc"); - mmc->supply.vmmc = supply; + mmc->supply.vmmc = devm_regulator_get_optional(dev, "vmmc"); mmc->supply.vqmmc = devm_regulator_get_optional(dev, "vqmmc"); - if (IS_ERR(supply)) - return PTR_ERR(supply); + if (IS_ERR(mmc->supply.vmmc)) { + if (PTR_ERR(mmc->supply.vmmc) == -EPROBE_DEFER) + return -EPROBE_DEFER; + dev_info(dev, "No vmmc regulator found\n"); + } else { + ret = mmc_regulator_get_ocrmask(mmc->supply.vmmc); + if (ret > 0) + mmc->ocr_avail = ret; + else + dev_warn(dev, "Failed getting OCR mask: %d\n", ret); + } - ret = mmc_regulator_get_ocrmask(supply); - if (ret > 0) - mmc->ocr_avail = ret; - else - dev_warn(mmc_dev(mmc), "Failed getting OCR mask: %d\n", ret); + if (IS_ERR(mmc->supply.vqmmc)) { + if (PTR_ERR(mmc->supply.vqmmc) == -EPROBE_DEFER) + return -EPROBE_DEFER; + dev_info(dev, "No vqmmc regulator found\n"); + } return 0; } EXPORT_SYMBOL_GPL(mmc_regulator_get_supply); -#endif /* CONFIG_REGULATOR */ - /* * Mask off any voltages we don't support and select * the lowest voltage diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h index cb61ea4..cfa2ecb 100644 --- a/include/linux/mmc/host.h +++ b/include/linux/mmc/host.h @@ -396,7 +396,6 @@ int mmc_regulator_get_ocrmask(struct regulator *supply); int mmc_regulator_set_ocr(struct mmc_host *mmc, struct regulator *supply, unsigned short vdd_bit); -int mmc_regulator_get_supply(struct mmc_host *mmc); #else static inline int mmc_regulator_get_ocrmask(struct regulator *supply) { @@ -409,13 +408,10 @@ static inline int mmc_regulator_set_ocr(struct mmc_host *mmc, { return 0; } - -static inline int mmc_regulator_get_supply(struct mmc_host *mmc) -{ - return 0; -} #endif +int mmc_regulator_get_supply(struct mmc_host *mmc); + int mmc_pm_notify(struct notifier_block *notify_block, unsigned long, void *); static inline int mmc_card_is_removable(struct mmc_host *host)