[Linux-stm32] [PATCH V2 2/3] mmc: Return 1 from mmc_regulator_set_vqmmc() if switch skipped

Ulf Hansson ulf.hansson at linaro.org
Fri Apr 17 09:30:59 UTC 2020


On Thu, 16 Apr 2020 at 18:37, Marek Vasut <marex at denx.de> wrote:
>
> Adjust mmc_regulator_set_vqmmc() to return 1 if the voltage switch was
> skipped because the regulator voltage was already correct. This allows
> drivers to detect such condition and possibly skip various voltage
> switching extras.
>
> Signed-off-by: Marek Vasut <marex at denx.de>
> Cc: Alexandre Torgue <alexandre.torgue at st.com>
> Cc: Linus Walleij <linus.walleij at linaro.org>
> Cc: Ludovic Barre <ludovic.barre at st.com>
> Cc: Manivannan Sadhasivam <manivannan.sadhasivam at linaro.org>
> Cc: Maxime Coquelin <mcoquelin.stm32 at gmail.com>
> Cc: Patrice Chotard <patrice.chotard at st.com>
> Cc: Patrick Delaunay <patrick.delaunay at st.com>
> Cc: Russell King <linux at armlinux.org.uk>
> Cc: Ulf Hansson <ulf.hansson at linaro.org>
> Cc: linux-stm32 at st-md-mailman.stormreply.com
> To: linux-mmc at vger.kernel.org

Applied for next, thanks!

Kind regards
Uffe


> ---
> V2: - Rename variable curr_voltage to current_uV
>     - Update mmc_regulator_set_vqmmc() to handle the fact that
>       mmc_regulator_set_voltage_if_supported() can return value > 0
> ---
>  drivers/mmc/core/regulator.c | 17 ++++++++++++++---
>  1 file changed, 14 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/mmc/core/regulator.c b/drivers/mmc/core/regulator.c
> index b6febbcf8978..96b1d15045d6 100644
> --- a/drivers/mmc/core/regulator.c
> +++ b/drivers/mmc/core/regulator.c
> @@ -136,6 +136,8 @@ static int mmc_regulator_set_voltage_if_supported(struct regulator *regulator,
>                                                   int min_uV, int target_uV,
>                                                   int max_uV)
>  {
> +       int current_uV;
> +
>         /*
>          * Check if supported first to avoid errors since we may try several
>          * signal levels during power up and don't want to show errors.
> @@ -143,6 +145,14 @@ static int mmc_regulator_set_voltage_if_supported(struct regulator *regulator,
>         if (!regulator_is_supported_voltage(regulator, min_uV, max_uV))
>                 return -EINVAL;
>
> +       /*
> +        * The voltage is already set, no need to switch.
> +        * Return 1 to indicate that no switch happened.
> +        */
> +       current_uV = regulator_get_voltage(regulator);
> +       if (current_uV == target_uV)
> +               return 1;
> +
>         return regulator_set_voltage_triplet(regulator, min_uV, target_uV,
>                                              max_uV);
>  }
> @@ -198,9 +208,10 @@ int mmc_regulator_set_vqmmc(struct mmc_host *mmc, struct mmc_ios *ios)
>                  * voltage in two steps and try to stay close to vmmc
>                  * with a 0.3V tolerance at first.
>                  */
> -               if (!mmc_regulator_set_voltage_if_supported(mmc->supply.vqmmc,
> -                                               min_uV, volt, max_uV))
> -                       return 0;
> +               ret = mmc_regulator_set_voltage_if_supported(mmc->supply.vqmmc,
> +                                                       min_uV, volt, max_uV);
> +               if (ret >= 0)
> +                       return ret;
>
>                 return mmc_regulator_set_voltage_if_supported(mmc->supply.vqmmc,
>                                                 2700000, volt, 3600000);
> --
> 2.25.1
>



More information about the Linux-stm32 mailing list