diff mbox series

[V2,1/3] mmc: Prepare all code for mmc_regulator_set_vqmmc() returning > 0

Message ID 20200416163649.336967-1-marex@denx.de (mailing list archive)
State New, archived
Headers show
Series [V2,1/3] mmc: Prepare all code for mmc_regulator_set_vqmmc() returning > 0 | expand

Commit Message

Marek Vasut April 16, 2020, 4:36 p.m. UTC
Patch all drivers which use mmc_regulator_set_vqmmc() and prepare them for
the fact that mmc_regulator_set_vqmmc() can return a value > 0, which would
happen if the signal voltage switch did NOT happen, because the voltage was
already set correctly.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Alexandre Torgue <alexandre.torgue@st.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Ludovic Barre <ludovic.barre@st.com>
Cc: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
Cc: Patrice Chotard <patrice.chotard@st.com>
Cc: Patrick Delaunay <patrick.delaunay@st.com>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Ulf Hansson <ulf.hansson@linaro.org>
Cc: linux-stm32@st-md-mailman.stormreply.com
To: linux-mmc@vger.kernel.org
---
V2: Patch only mmc_regulator_set_vqmmc()
---
 drivers/mmc/host/dw_mmc-k3.c         |  2 ++
 drivers/mmc/host/dw_mmc.c            |  2 ++
 drivers/mmc/host/meson-gx-mmc.c      |  7 ++++++-
 drivers/mmc/host/mtk-sd.c            |  2 ++
 drivers/mmc/host/renesas_sdhi_core.c |  2 ++
 drivers/mmc/host/sdhci-sprd.c        |  2 ++
 drivers/mmc/host/sdhci.c             |  6 ++++++
 drivers/mmc/host/sunxi-mmc.c         | 10 ++++++++--
 drivers/mmc/host/usdhi6rol0.c        |  2 ++
 9 files changed, 32 insertions(+), 3 deletions(-)

Comments

Ulf Hansson April 17, 2020, 9:30 a.m. UTC | #1
On Thu, 16 Apr 2020 at 18:36, Marek Vasut <marex@denx.de> wrote:
>
> Patch all drivers which use mmc_regulator_set_vqmmc() and prepare them for
> the fact that mmc_regulator_set_vqmmc() can return a value > 0, which would
> happen if the signal voltage switch did NOT happen, because the voltage was
> already set correctly.
>
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Alexandre Torgue <alexandre.torgue@st.com>
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Cc: Ludovic Barre <ludovic.barre@st.com>
> Cc: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
> Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
> Cc: Patrice Chotard <patrice.chotard@st.com>
> Cc: Patrick Delaunay <patrick.delaunay@st.com>
> Cc: Russell King <linux@armlinux.org.uk>
> Cc: Ulf Hansson <ulf.hansson@linaro.org>
> Cc: linux-stm32@st-md-mailman.stormreply.com
> To: linux-mmc@vger.kernel.org

Applied for next, thanks!

I took the liberty to re-work and simplify some of the code, please
have a look at my next branch to make sure I didn't screw something
up.

Kind regards
Uffe

diff --git a/drivers/mmc/host/dw_mmc-k3.c b/drivers/mmc/host/dw_mmc-k3.c
index 23b6f65b3785..50977ff18074 100644
--- a/drivers/mmc/host/dw_mmc-k3.c
+++ b/drivers/mmc/host/dw_mmc-k3.c
@@ -424,7 +424,7 @@ static int dw_mci_hi3660_switch_voltage(struct
mmc_host *mmc,

        if (!IS_ERR(mmc->supply.vqmmc)) {
                ret = mmc_regulator_set_vqmmc(mmc, ios);
-               if (ret) {
+               if (ret < 0) {
                        dev_err(host->dev, "Regulator set error %d\n", ret);
                        return ret;
                }
diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
index bc5278ab5707..5d1f8a3ec3a5 100644
--- a/drivers/mmc/host/dw_mmc.c
+++ b/drivers/mmc/host/dw_mmc.c
@@ -1546,8 +1546,7 @@ static int dw_mci_switch_voltage(struct mmc_host
*mmc, struct mmc_ios *ios)

        if (!IS_ERR(mmc->supply.vqmmc)) {
                ret = mmc_regulator_set_vqmmc(mmc, ios);
-
-               if (ret) {
+               if (ret < 0) {
                        dev_dbg(&mmc->class_dev,
                                         "Regulator set error %d - %s V\n",
                                         ret, uhs & v18 ? "1.8" : "3.3");



> ---
> V2: Patch only mmc_regulator_set_vqmmc()
> ---
>  drivers/mmc/host/dw_mmc-k3.c         |  2 ++
>  drivers/mmc/host/dw_mmc.c            |  2 ++
>  drivers/mmc/host/meson-gx-mmc.c      |  7 ++++++-
>  drivers/mmc/host/mtk-sd.c            |  2 ++
>  drivers/mmc/host/renesas_sdhi_core.c |  2 ++
>  drivers/mmc/host/sdhci-sprd.c        |  2 ++
>  drivers/mmc/host/sdhci.c             |  6 ++++++
>  drivers/mmc/host/sunxi-mmc.c         | 10 ++++++++--
>  drivers/mmc/host/usdhi6rol0.c        |  2 ++
>  9 files changed, 32 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/mmc/host/dw_mmc-k3.c b/drivers/mmc/host/dw_mmc-k3.c
> index 23b6f65b3785..695e29452367 100644
> --- a/drivers/mmc/host/dw_mmc-k3.c
> +++ b/drivers/mmc/host/dw_mmc-k3.c
> @@ -424,6 +424,8 @@ static int dw_mci_hi3660_switch_voltage(struct mmc_host *mmc,
>
>         if (!IS_ERR(mmc->supply.vqmmc)) {
>                 ret = mmc_regulator_set_vqmmc(mmc, ios);
> +               if (ret > 0)
> +                       ret = 0;
>                 if (ret) {
>                         dev_err(host->dev, "Regulator set error %d\n", ret);
>                         return ret;
> diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
> index bc5278ab5707..3f82170f1d98 100644
> --- a/drivers/mmc/host/dw_mmc.c
> +++ b/drivers/mmc/host/dw_mmc.c
> @@ -1546,6 +1546,8 @@ static int dw_mci_switch_voltage(struct mmc_host *mmc, struct mmc_ios *ios)
>
>         if (!IS_ERR(mmc->supply.vqmmc)) {
>                 ret = mmc_regulator_set_vqmmc(mmc, ios);
> +               if (ret > 0)
> +                       ret = 0;
>
>                 if (ret) {
>                         dev_dbg(&mmc->class_dev,
> diff --git a/drivers/mmc/host/meson-gx-mmc.c b/drivers/mmc/host/meson-gx-mmc.c
> index 35400cf2a2e4..79e15fa6f4fd 100644
> --- a/drivers/mmc/host/meson-gx-mmc.c
> +++ b/drivers/mmc/host/meson-gx-mmc.c
> @@ -1004,6 +1004,8 @@ static int meson_mmc_card_busy(struct mmc_host *mmc)
>
>  static int meson_mmc_voltage_switch(struct mmc_host *mmc, struct mmc_ios *ios)
>  {
> +       int ret;
> +
>         /* vqmmc regulator is available */
>         if (!IS_ERR(mmc->supply.vqmmc)) {
>                 /*
> @@ -1013,7 +1015,10 @@ static int meson_mmc_voltage_switch(struct mmc_host *mmc, struct mmc_ios *ios)
>                  * to 1.8v. Please make sure the regulator framework is aware
>                  * of your own regulator constraints
>                  */
> -               return mmc_regulator_set_vqmmc(mmc, ios);
> +               ret = mmc_regulator_set_vqmmc(mmc, ios);
> +               if (ret > 0)
> +                       ret = 0;
> +               return ret;
>         }
>
>         /* no vqmmc regulator, assume fixed regulator at 3/3.3V */
> diff --git a/drivers/mmc/host/mtk-sd.c b/drivers/mmc/host/mtk-sd.c
> index b221c02cc71f..9688797f097d 100644
> --- a/drivers/mmc/host/mtk-sd.c
> +++ b/drivers/mmc/host/mtk-sd.c
> @@ -1379,6 +1379,8 @@ static int msdc_ops_switch_volt(struct mmc_host *mmc, struct mmc_ios *ios)
>                 }
>
>                 ret = mmc_regulator_set_vqmmc(mmc, ios);
> +               if (ret > 0)
> +                       ret = 0;
>                 if (ret) {
>                         dev_dbg(host->dev, "Regulator set error %d (%d)\n",
>                                 ret, ios->signal_voltage);
> diff --git a/drivers/mmc/host/renesas_sdhi_core.c b/drivers/mmc/host/renesas_sdhi_core.c
> index 68432bb0255b..7ffe17bb1e62 100644
> --- a/drivers/mmc/host/renesas_sdhi_core.c
> +++ b/drivers/mmc/host/renesas_sdhi_core.c
> @@ -237,6 +237,8 @@ static int renesas_sdhi_start_signal_voltage_switch(struct mmc_host *mmc,
>                         MMC_SIGNAL_VOLTAGE_330 ? 0 : -EINVAL;
>
>         ret = mmc_regulator_set_vqmmc(host->mmc, ios);
> +       if (ret > 0)
> +               ret = 0;
>         if (ret)
>                 return ret;
>
> diff --git a/drivers/mmc/host/sdhci-sprd.c b/drivers/mmc/host/sdhci-sprd.c
> index 60c3a4c620f9..2a27af3eceef 100644
> --- a/drivers/mmc/host/sdhci-sprd.c
> +++ b/drivers/mmc/host/sdhci-sprd.c
> @@ -434,6 +434,8 @@ static int sdhci_sprd_voltage_switch(struct mmc_host *mmc, struct mmc_ios *ios)
>
>         if (!IS_ERR(mmc->supply.vqmmc)) {
>                 ret = mmc_regulator_set_vqmmc(mmc, ios);
> +               if (ret > 0)
> +                       ret = 0;
>                 if (ret) {
>                         pr_err("%s: Switching signalling voltage failed\n",
>                                mmc_hostname(mmc));
> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
> index 344a7e0e33fe..a100fb633b40 100644
> --- a/drivers/mmc/host/sdhci.c
> +++ b/drivers/mmc/host/sdhci.c
> @@ -2411,6 +2411,8 @@ int sdhci_start_signal_voltage_switch(struct mmc_host *mmc,
>
>                 if (!IS_ERR(mmc->supply.vqmmc)) {
>                         ret = mmc_regulator_set_vqmmc(mmc, ios);
> +                       if (ret > 0)
> +                               ret = 0;
>                         if (ret) {
>                                 pr_warn("%s: Switching to 3.3V signalling voltage failed\n",
>                                         mmc_hostname(mmc));
> @@ -2434,6 +2436,8 @@ int sdhci_start_signal_voltage_switch(struct mmc_host *mmc,
>                         return -EINVAL;
>                 if (!IS_ERR(mmc->supply.vqmmc)) {
>                         ret = mmc_regulator_set_vqmmc(mmc, ios);
> +                       if (ret > 0)
> +                               ret = 0;
>                         if (ret) {
>                                 pr_warn("%s: Switching to 1.8V signalling voltage failed\n",
>                                         mmc_hostname(mmc));
> @@ -2466,6 +2470,8 @@ int sdhci_start_signal_voltage_switch(struct mmc_host *mmc,
>                         return -EINVAL;
>                 if (!IS_ERR(mmc->supply.vqmmc)) {
>                         ret = mmc_regulator_set_vqmmc(mmc, ios);
> +                       if (ret > 0)
> +                               ret = 0;
>                         if (ret) {
>                                 pr_warn("%s: Switching to 1.2V signalling voltage failed\n",
>                                         mmc_hostname(mmc));
> diff --git a/drivers/mmc/host/sunxi-mmc.c b/drivers/mmc/host/sunxi-mmc.c
> index f87d7967457f..f70a4249b72b 100644
> --- a/drivers/mmc/host/sunxi-mmc.c
> +++ b/drivers/mmc/host/sunxi-mmc.c
> @@ -951,9 +951,15 @@ static void sunxi_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
>
>  static int sunxi_mmc_volt_switch(struct mmc_host *mmc, struct mmc_ios *ios)
>  {
> +       int ret;
> +
>         /* vqmmc regulator is available */
> -       if (!IS_ERR(mmc->supply.vqmmc))
> -               return mmc_regulator_set_vqmmc(mmc, ios);
> +       if (!IS_ERR(mmc->supply.vqmmc)) {
> +               ret = mmc_regulator_set_vqmmc(mmc, ios);
> +               if (ret > 0)
> +                       ret = 0;
> +               return ret;
> +       }
>
>         /* no vqmmc regulator, assume fixed regulator at 3/3.3V */
>         if (mmc->ios.signal_voltage == MMC_SIGNAL_VOLTAGE_330)
> diff --git a/drivers/mmc/host/usdhi6rol0.c b/drivers/mmc/host/usdhi6rol0.c
> index 9a0b1e4e405d..72e698071ddf 100644
> --- a/drivers/mmc/host/usdhi6rol0.c
> +++ b/drivers/mmc/host/usdhi6rol0.c
> @@ -1174,6 +1174,8 @@ static int usdhi6_sig_volt_switch(struct mmc_host *mmc, struct mmc_ios *ios)
>         int ret;
>
>         ret = mmc_regulator_set_vqmmc(mmc, ios);
> +       if (ret > 0)
> +               ret = 0;
>         if (ret < 0)
>                 return ret;
>
> --
> 2.25.1
>
Marek Vasut April 17, 2020, 3:30 p.m. UTC | #2
On 4/17/20 11:30 AM, Ulf Hansson wrote:
> On Thu, 16 Apr 2020 at 18:36, Marek Vasut <marex@denx.de> wrote:
>>
>> Patch all drivers which use mmc_regulator_set_vqmmc() and prepare them for
>> the fact that mmc_regulator_set_vqmmc() can return a value > 0, which would
>> happen if the signal voltage switch did NOT happen, because the voltage was
>> already set correctly.
>>
>> Signed-off-by: Marek Vasut <marex@denx.de>
>> Cc: Alexandre Torgue <alexandre.torgue@st.com>
>> Cc: Linus Walleij <linus.walleij@linaro.org>
>> Cc: Ludovic Barre <ludovic.barre@st.com>
>> Cc: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
>> Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
>> Cc: Patrice Chotard <patrice.chotard@st.com>
>> Cc: Patrick Delaunay <patrick.delaunay@st.com>
>> Cc: Russell King <linux@armlinux.org.uk>
>> Cc: Ulf Hansson <ulf.hansson@linaro.org>
>> Cc: linux-stm32@st-md-mailman.stormreply.com
>> To: linux-mmc@vger.kernel.org
> 
> Applied for next, thanks!
> 
> I took the liberty to re-work and simplify some of the code, please
> have a look at my next branch to make sure I didn't screw something
> up.

Where is your next branch ?
Ulf Hansson April 20, 2020, 8:18 a.m. UTC | #3
On Fri, 17 Apr 2020 at 17:33, Marek Vasut <marex@denx.de> wrote:
>
> On 4/17/20 11:30 AM, Ulf Hansson wrote:
> > On Thu, 16 Apr 2020 at 18:36, Marek Vasut <marex@denx.de> wrote:
> >>
> >> Patch all drivers which use mmc_regulator_set_vqmmc() and prepare them for
> >> the fact that mmc_regulator_set_vqmmc() can return a value > 0, which would
> >> happen if the signal voltage switch did NOT happen, because the voltage was
> >> already set correctly.
> >>
> >> Signed-off-by: Marek Vasut <marex@denx.de>
> >> Cc: Alexandre Torgue <alexandre.torgue@st.com>
> >> Cc: Linus Walleij <linus.walleij@linaro.org>
> >> Cc: Ludovic Barre <ludovic.barre@st.com>
> >> Cc: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
> >> Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
> >> Cc: Patrice Chotard <patrice.chotard@st.com>
> >> Cc: Patrick Delaunay <patrick.delaunay@st.com>
> >> Cc: Russell King <linux@armlinux.org.uk>
> >> Cc: Ulf Hansson <ulf.hansson@linaro.org>
> >> Cc: linux-stm32@st-md-mailman.stormreply.com
> >> To: linux-mmc@vger.kernel.org
> >
> > Applied for next, thanks!
> >
> > I took the liberty to re-work and simplify some of the code, please
> > have a look at my next branch to make sure I didn't screw something
> > up.
>
> Where is your next branch ?

It's listed in the MAINTAINERS file.

git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc.git

Kind regards
Uffe
Marek Vasut April 20, 2020, 11:58 a.m. UTC | #4
On 4/20/20 10:18 AM, Ulf Hansson wrote:
> On Fri, 17 Apr 2020 at 17:33, Marek Vasut <marex@denx.de> wrote:
>>
>> On 4/17/20 11:30 AM, Ulf Hansson wrote:
>>> On Thu, 16 Apr 2020 at 18:36, Marek Vasut <marex@denx.de> wrote:
>>>>
>>>> Patch all drivers which use mmc_regulator_set_vqmmc() and prepare them for
>>>> the fact that mmc_regulator_set_vqmmc() can return a value > 0, which would
>>>> happen if the signal voltage switch did NOT happen, because the voltage was
>>>> already set correctly.
>>>>
>>>> Signed-off-by: Marek Vasut <marex@denx.de>
>>>> Cc: Alexandre Torgue <alexandre.torgue@st.com>
>>>> Cc: Linus Walleij <linus.walleij@linaro.org>
>>>> Cc: Ludovic Barre <ludovic.barre@st.com>
>>>> Cc: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
>>>> Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
>>>> Cc: Patrice Chotard <patrice.chotard@st.com>
>>>> Cc: Patrick Delaunay <patrick.delaunay@st.com>
>>>> Cc: Russell King <linux@armlinux.org.uk>
>>>> Cc: Ulf Hansson <ulf.hansson@linaro.org>
>>>> Cc: linux-stm32@st-md-mailman.stormreply.com
>>>> To: linux-mmc@vger.kernel.org
>>>
>>> Applied for next, thanks!
>>>
>>> I took the liberty to re-work and simplify some of the code, please
>>> have a look at my next branch to make sure I didn't screw something
>>> up.
>>
>> Where is your next branch ?
> 
> It's listed in the MAINTAINERS file.
> 
> git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc.git

All right, this one. The adjustments look OK, thanks.

I noticed this one in mtk-sd.c:
/* Apply different pinctrl settings for different signal voltage */
if (ios->signal_voltage == MMC_SIGNAL_VOLTAGE_180)
	pinctrl_select_state(host->pinctrl, host->pins_uhs);
else
	pinctrl_select_state(host->pinctrl, host->pins_default);

I would almost think that the MTK platforms would support 1V2 modes too,
so the above should rather be:

if (ios->signal_voltage == MMC_SIGNAL_VOLTAGE_330)
	pinctrl_select_state(host->pinctrl, host->pins_default);
else
	pinctrl_select_state(host->pinctrl, host->pins_uhs);

But I have no hardware to test, and it's a topic for another patch.
diff mbox series

Patch

diff --git a/drivers/mmc/host/dw_mmc-k3.c b/drivers/mmc/host/dw_mmc-k3.c
index 23b6f65b3785..695e29452367 100644
--- a/drivers/mmc/host/dw_mmc-k3.c
+++ b/drivers/mmc/host/dw_mmc-k3.c
@@ -424,6 +424,8 @@  static int dw_mci_hi3660_switch_voltage(struct mmc_host *mmc,
 
 	if (!IS_ERR(mmc->supply.vqmmc)) {
 		ret = mmc_regulator_set_vqmmc(mmc, ios);
+		if (ret > 0)
+			ret = 0;
 		if (ret) {
 			dev_err(host->dev, "Regulator set error %d\n", ret);
 			return ret;
diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
index bc5278ab5707..3f82170f1d98 100644
--- a/drivers/mmc/host/dw_mmc.c
+++ b/drivers/mmc/host/dw_mmc.c
@@ -1546,6 +1546,8 @@  static int dw_mci_switch_voltage(struct mmc_host *mmc, struct mmc_ios *ios)
 
 	if (!IS_ERR(mmc->supply.vqmmc)) {
 		ret = mmc_regulator_set_vqmmc(mmc, ios);
+		if (ret > 0)
+			ret = 0;
 
 		if (ret) {
 			dev_dbg(&mmc->class_dev,
diff --git a/drivers/mmc/host/meson-gx-mmc.c b/drivers/mmc/host/meson-gx-mmc.c
index 35400cf2a2e4..79e15fa6f4fd 100644
--- a/drivers/mmc/host/meson-gx-mmc.c
+++ b/drivers/mmc/host/meson-gx-mmc.c
@@ -1004,6 +1004,8 @@  static int meson_mmc_card_busy(struct mmc_host *mmc)
 
 static int meson_mmc_voltage_switch(struct mmc_host *mmc, struct mmc_ios *ios)
 {
+	int ret;
+
 	/* vqmmc regulator is available */
 	if (!IS_ERR(mmc->supply.vqmmc)) {
 		/*
@@ -1013,7 +1015,10 @@  static int meson_mmc_voltage_switch(struct mmc_host *mmc, struct mmc_ios *ios)
 		 * to 1.8v. Please make sure the regulator framework is aware
 		 * of your own regulator constraints
 		 */
-		return mmc_regulator_set_vqmmc(mmc, ios);
+		ret = mmc_regulator_set_vqmmc(mmc, ios);
+		if (ret > 0)
+			ret = 0;
+		return ret;
 	}
 
 	/* no vqmmc regulator, assume fixed regulator at 3/3.3V */
diff --git a/drivers/mmc/host/mtk-sd.c b/drivers/mmc/host/mtk-sd.c
index b221c02cc71f..9688797f097d 100644
--- a/drivers/mmc/host/mtk-sd.c
+++ b/drivers/mmc/host/mtk-sd.c
@@ -1379,6 +1379,8 @@  static int msdc_ops_switch_volt(struct mmc_host *mmc, struct mmc_ios *ios)
 		}
 
 		ret = mmc_regulator_set_vqmmc(mmc, ios);
+		if (ret > 0)
+			ret = 0;
 		if (ret) {
 			dev_dbg(host->dev, "Regulator set error %d (%d)\n",
 				ret, ios->signal_voltage);
diff --git a/drivers/mmc/host/renesas_sdhi_core.c b/drivers/mmc/host/renesas_sdhi_core.c
index 68432bb0255b..7ffe17bb1e62 100644
--- a/drivers/mmc/host/renesas_sdhi_core.c
+++ b/drivers/mmc/host/renesas_sdhi_core.c
@@ -237,6 +237,8 @@  static int renesas_sdhi_start_signal_voltage_switch(struct mmc_host *mmc,
 			MMC_SIGNAL_VOLTAGE_330 ? 0 : -EINVAL;
 
 	ret = mmc_regulator_set_vqmmc(host->mmc, ios);
+	if (ret > 0)
+		ret = 0;
 	if (ret)
 		return ret;
 
diff --git a/drivers/mmc/host/sdhci-sprd.c b/drivers/mmc/host/sdhci-sprd.c
index 60c3a4c620f9..2a27af3eceef 100644
--- a/drivers/mmc/host/sdhci-sprd.c
+++ b/drivers/mmc/host/sdhci-sprd.c
@@ -434,6 +434,8 @@  static int sdhci_sprd_voltage_switch(struct mmc_host *mmc, struct mmc_ios *ios)
 
 	if (!IS_ERR(mmc->supply.vqmmc)) {
 		ret = mmc_regulator_set_vqmmc(mmc, ios);
+		if (ret > 0)
+			ret = 0;
 		if (ret) {
 			pr_err("%s: Switching signalling voltage failed\n",
 			       mmc_hostname(mmc));
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 344a7e0e33fe..a100fb633b40 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -2411,6 +2411,8 @@  int sdhci_start_signal_voltage_switch(struct mmc_host *mmc,
 
 		if (!IS_ERR(mmc->supply.vqmmc)) {
 			ret = mmc_regulator_set_vqmmc(mmc, ios);
+			if (ret > 0)
+				ret = 0;
 			if (ret) {
 				pr_warn("%s: Switching to 3.3V signalling voltage failed\n",
 					mmc_hostname(mmc));
@@ -2434,6 +2436,8 @@  int sdhci_start_signal_voltage_switch(struct mmc_host *mmc,
 			return -EINVAL;
 		if (!IS_ERR(mmc->supply.vqmmc)) {
 			ret = mmc_regulator_set_vqmmc(mmc, ios);
+			if (ret > 0)
+				ret = 0;
 			if (ret) {
 				pr_warn("%s: Switching to 1.8V signalling voltage failed\n",
 					mmc_hostname(mmc));
@@ -2466,6 +2470,8 @@  int sdhci_start_signal_voltage_switch(struct mmc_host *mmc,
 			return -EINVAL;
 		if (!IS_ERR(mmc->supply.vqmmc)) {
 			ret = mmc_regulator_set_vqmmc(mmc, ios);
+			if (ret > 0)
+				ret = 0;
 			if (ret) {
 				pr_warn("%s: Switching to 1.2V signalling voltage failed\n",
 					mmc_hostname(mmc));
diff --git a/drivers/mmc/host/sunxi-mmc.c b/drivers/mmc/host/sunxi-mmc.c
index f87d7967457f..f70a4249b72b 100644
--- a/drivers/mmc/host/sunxi-mmc.c
+++ b/drivers/mmc/host/sunxi-mmc.c
@@ -951,9 +951,15 @@  static void sunxi_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
 
 static int sunxi_mmc_volt_switch(struct mmc_host *mmc, struct mmc_ios *ios)
 {
+	int ret;
+
 	/* vqmmc regulator is available */
-	if (!IS_ERR(mmc->supply.vqmmc))
-		return mmc_regulator_set_vqmmc(mmc, ios);
+	if (!IS_ERR(mmc->supply.vqmmc)) {
+		ret = mmc_regulator_set_vqmmc(mmc, ios);
+		if (ret > 0)
+			ret = 0;
+		return ret;
+	}
 
 	/* no vqmmc regulator, assume fixed regulator at 3/3.3V */
 	if (mmc->ios.signal_voltage == MMC_SIGNAL_VOLTAGE_330)
diff --git a/drivers/mmc/host/usdhi6rol0.c b/drivers/mmc/host/usdhi6rol0.c
index 9a0b1e4e405d..72e698071ddf 100644
--- a/drivers/mmc/host/usdhi6rol0.c
+++ b/drivers/mmc/host/usdhi6rol0.c
@@ -1174,6 +1174,8 @@  static int usdhi6_sig_volt_switch(struct mmc_host *mmc, struct mmc_ios *ios)
 	int ret;
 
 	ret = mmc_regulator_set_vqmmc(mmc, ios);
+	if (ret > 0)
+		ret = 0;
 	if (ret < 0)
 		return ret;