Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mmc: host: Prepare host drivers for mmc_regulator_set_vqmmc() returning > 0

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>
Link: https://lore.kernel.org/r/20200416163649.336967-1-marex@denx.de
[Ulf: Re-worked/simplified the code a bit]
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

authored by

Marek Vasut and committed by
Ulf Hansson
9cbe0fc8 098c408b

+27 -20
+1 -1
drivers/mmc/host/dw_mmc-k3.c
··· 424 424 425 425 if (!IS_ERR(mmc->supply.vqmmc)) { 426 426 ret = mmc_regulator_set_vqmmc(mmc, ios); 427 - if (ret) { 427 + if (ret < 0) { 428 428 dev_err(host->dev, "Regulator set error %d\n", ret); 429 429 return ret; 430 430 }
+1 -2
drivers/mmc/host/dw_mmc.c
··· 1546 1546 1547 1547 if (!IS_ERR(mmc->supply.vqmmc)) { 1548 1548 ret = mmc_regulator_set_vqmmc(mmc, ios); 1549 - 1550 - if (ret) { 1549 + if (ret < 0) { 1551 1550 dev_dbg(&mmc->class_dev, 1552 1551 "Regulator set error %d - %s V\n", 1553 1552 ret, uhs & v18 ? "1.8" : "3.3");
+4 -1
drivers/mmc/host/meson-gx-mmc.c
··· 1004 1004 1005 1005 static int meson_mmc_voltage_switch(struct mmc_host *mmc, struct mmc_ios *ios) 1006 1006 { 1007 + int ret; 1008 + 1007 1009 /* vqmmc regulator is available */ 1008 1010 if (!IS_ERR(mmc->supply.vqmmc)) { 1009 1011 /* ··· 1015 1013 * to 1.8v. Please make sure the regulator framework is aware 1016 1014 * of your own regulator constraints 1017 1015 */ 1018 - return mmc_regulator_set_vqmmc(mmc, ios); 1016 + ret = mmc_regulator_set_vqmmc(mmc, ios); 1017 + return ret < 0 ? ret : 0; 1019 1018 } 1020 1019 1021 1020 /* no vqmmc regulator, assume fixed regulator at 3/3.3V */
+10 -9
drivers/mmc/host/mtk-sd.c
··· 1369 1369 static int msdc_ops_switch_volt(struct mmc_host *mmc, struct mmc_ios *ios) 1370 1370 { 1371 1371 struct msdc_host *host = mmc_priv(mmc); 1372 - int ret = 0; 1372 + int ret; 1373 1373 1374 1374 if (!IS_ERR(mmc->supply.vqmmc)) { 1375 1375 if (ios->signal_voltage != MMC_SIGNAL_VOLTAGE_330 && ··· 1379 1379 } 1380 1380 1381 1381 ret = mmc_regulator_set_vqmmc(mmc, ios); 1382 - if (ret) { 1382 + if (ret < 0) { 1383 1383 dev_dbg(host->dev, "Regulator set error %d (%d)\n", 1384 1384 ret, ios->signal_voltage); 1385 - } else { 1386 - /* Apply different pinctrl settings for different signal voltage */ 1387 - if (ios->signal_voltage == MMC_SIGNAL_VOLTAGE_180) 1388 - pinctrl_select_state(host->pinctrl, host->pins_uhs); 1389 - else 1390 - pinctrl_select_state(host->pinctrl, host->pins_default); 1385 + return ret; 1391 1386 } 1387 + 1388 + /* Apply different pinctrl settings for different signal voltage */ 1389 + if (ios->signal_voltage == MMC_SIGNAL_VOLTAGE_180) 1390 + pinctrl_select_state(host->pinctrl, host->pins_uhs); 1391 + else 1392 + pinctrl_select_state(host->pinctrl, host->pins_default); 1392 1393 } 1393 - return ret; 1394 + return 0; 1394 1395 } 1395 1396 1396 1397 static int msdc_card_busy(struct mmc_host *mmc)
+1 -1
drivers/mmc/host/renesas_sdhi_core.c
··· 237 237 MMC_SIGNAL_VOLTAGE_330 ? 0 : -EINVAL; 238 238 239 239 ret = mmc_regulator_set_vqmmc(host->mmc, ios); 240 - if (ret) 240 + if (ret < 0) 241 241 return ret; 242 242 243 243 return pinctrl_select_state(priv->pinctrl, pin_state);
+1 -1
drivers/mmc/host/sdhci-sprd.c
··· 434 434 435 435 if (!IS_ERR(mmc->supply.vqmmc)) { 436 436 ret = mmc_regulator_set_vqmmc(mmc, ios); 437 - if (ret) { 437 + if (ret < 0) { 438 438 pr_err("%s: Switching signalling voltage failed\n", 439 439 mmc_hostname(mmc)); 440 440 return ret;
+3 -3
drivers/mmc/host/sdhci.c
··· 2411 2411 2412 2412 if (!IS_ERR(mmc->supply.vqmmc)) { 2413 2413 ret = mmc_regulator_set_vqmmc(mmc, ios); 2414 - if (ret) { 2414 + if (ret < 0) { 2415 2415 pr_warn("%s: Switching to 3.3V signalling voltage failed\n", 2416 2416 mmc_hostname(mmc)); 2417 2417 return -EIO; ··· 2434 2434 return -EINVAL; 2435 2435 if (!IS_ERR(mmc->supply.vqmmc)) { 2436 2436 ret = mmc_regulator_set_vqmmc(mmc, ios); 2437 - if (ret) { 2437 + if (ret < 0) { 2438 2438 pr_warn("%s: Switching to 1.8V signalling voltage failed\n", 2439 2439 mmc_hostname(mmc)); 2440 2440 return -EIO; ··· 2466 2466 return -EINVAL; 2467 2467 if (!IS_ERR(mmc->supply.vqmmc)) { 2468 2468 ret = mmc_regulator_set_vqmmc(mmc, ios); 2469 - if (ret) { 2469 + if (ret < 0) { 2470 2470 pr_warn("%s: Switching to 1.2V signalling voltage failed\n", 2471 2471 mmc_hostname(mmc)); 2472 2472 return -EIO;
+6 -2
drivers/mmc/host/sunxi-mmc.c
··· 951 951 952 952 static int sunxi_mmc_volt_switch(struct mmc_host *mmc, struct mmc_ios *ios) 953 953 { 954 + int ret; 955 + 954 956 /* vqmmc regulator is available */ 955 - if (!IS_ERR(mmc->supply.vqmmc)) 956 - return mmc_regulator_set_vqmmc(mmc, ios); 957 + if (!IS_ERR(mmc->supply.vqmmc)) { 958 + ret = mmc_regulator_set_vqmmc(mmc, ios); 959 + return ret < 0 ? ret : 0; 960 + } 957 961 958 962 /* no vqmmc regulator, assume fixed regulator at 3/3.3V */ 959 963 if (mmc->ios.signal_voltage == MMC_SIGNAL_VOLTAGE_330)