Adjust mmc_set_signal_voltage() 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@xxxxxxx> Cc: Alexandre Torgue <alexandre.torgue@xxxxxx> Cc: Linus Walleij <linus.walleij@xxxxxxxxxx> Cc: Ludovic Barre <ludovic.barre@xxxxxx> Cc: Manivannan Sadhasivam <manivannan.sadhasivam@xxxxxxxxxx> Cc: Maxime Coquelin <mcoquelin.stm32@xxxxxxxxx> Cc: Patrice Chotard <patrice.chotard@xxxxxx> Cc: Patrick Delaunay <patrick.delaunay@xxxxxx> Cc: Russell King <linux@xxxxxxxxxxxxxxx> Cc: Ulf Hansson <ulf.hansson@xxxxxxxxxx> Cc: linux-stm32@xxxxxxxxxxxxxxxxxxxxxxxxxxxx To: linux-mmc@xxxxxxxxxxxxxxx --- drivers/mmc/core/regulator.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/mmc/core/regulator.c b/drivers/mmc/core/regulator.c index b6febbcf8978..2805ea8a070e 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 curr_voltage; + /* * 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. + */ + curr_voltage = regulator_get_voltage(regulator); + if (curr_voltage == target_uV) + return 1; + return regulator_set_voltage_triplet(regulator, min_uV, target_uV, max_uV); } -- 2.25.1