aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergio Valverde <vlvrdv@gmail.com>2018-02-08 12:41:43 -0500
committerUlf Hansson <ulf.hansson@linaro.org>2018-03-05 03:01:00 -0500
commitb305882fbc878f10ad089348da147987c330a2ee (patch)
tree31fb0bcde41b9216f7288d69b45a49e19b8a6fd9
parent5a871bf081dd7915ed7b9942a5484ff0c742e2cc (diff)
mmc: core: optimize mmc_calc_max_discard
If the max_discard value is zero, the conditional branch that checks the trim capabilities will never update this value with max_trim. Change the condition statement to also check the max_discard value in order to avoid an unnecessary call to mmc_do_calc_max_discard. Signed-off-by: Sergio Valverde <vlvrdv@gmail.com> Reviewed-by: Shawn Lin <shawn.lin@rock-chip.com> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
-rw-r--r--drivers/mmc/core/core.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index c0ba6d8823b7..e01910dd964b 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -2369,7 +2369,7 @@ unsigned int mmc_calc_max_discard(struct mmc_card *card)
2369 return card->pref_erase; 2369 return card->pref_erase;
2370 2370
2371 max_discard = mmc_do_calc_max_discard(card, MMC_ERASE_ARG); 2371 max_discard = mmc_do_calc_max_discard(card, MMC_ERASE_ARG);
2372 if (mmc_can_trim(card)) { 2372 if (max_discard && mmc_can_trim(card)) {
2373 max_trim = mmc_do_calc_max_discard(card, MMC_TRIM_ARG); 2373 max_trim = mmc_do_calc_max_discard(card, MMC_TRIM_ARG);
2374 if (max_trim < max_discard) 2374 if (max_trim < max_discard)
2375 max_discard = max_trim; 2375 max_discard = max_trim;