Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751924AbaDYVdj (ORCPT ); Fri, 25 Apr 2014 17:33:39 -0400 Received: from mail-ve0-f182.google.com ([209.85.128.182]:35404 "EHLO mail-ve0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751710AbaDYVdg (ORCPT ); Fri, 25 Apr 2014 17:33:36 -0400 MIME-Version: 1.0 In-Reply-To: <1398451211-19693-1-git-send-email-tim.kryger@linaro.org> References: <1398451211-19693-1-git-send-email-tim.kryger@linaro.org> Date: Fri, 25 Apr 2014 14:33:35 -0700 X-Google-Sender-Auth: ebsSoKMccxEaU8sfQaOUAGgsIis Message-ID: Subject: Re: [PATCH RESEND] mmc: core: Improve support for deferred regulators From: Andrew Bresticker To: Tim Kryger Cc: Chris Ball , Ulf Hansson , Mike Looijmans , Linux MMC List , Linux Kernel Mailing List Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Tim, > It is important that callers of mmc_regulator_get_supply know if either > vmmc or vqmmc are present but not yet available. To support this need, > modify this function to return zero except when either of the regulator > get operations fail with -EPROBE_DEFER. Current callers don't check the > return value and may continue to use IS_ERR on the vmmc/vqmmc values to > determine if those regulators are available. Furthermore, since all of > these callers are capable of dealing with absent regulators, switch over > to use the non-optional variety of the regulator get call. > > Signed-off-by: Tim Kryger > --- > drivers/mmc/core/core.c | 27 +++++++++++++++++---------- > 1 file changed, 17 insertions(+), 10 deletions(-) > > diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c > index acbc3f2..095eef0 100644 > --- a/drivers/mmc/core/core.c > +++ b/drivers/mmc/core/core.c > @@ -1313,21 +1313,28 @@ EXPORT_SYMBOL_GPL(mmc_regulator_set_ocr); > 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); > + } I think we also need to handle the case where supply is NULL, i.e. !CONFIG_REGULATOR. The SDHCI driver, for example, calls regulator_is_supported_voltage() which will always return false on NULL regulators. Perhaps we should set the supplies to ERR_PTR(-ENODEV) in that case? Thanks, Andrew > > - 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; > } > -- > 1.7.9.5 > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/