Commit b305882f authored by Sergio Valverde's avatar Sergio Valverde Committed by Ulf Hansson

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: default avatarSergio Valverde <vlvrdv@gmail.com>
Reviewed-by: default avatarShawn Lin <shawn.lin@rock-chip.com>
Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
parent 5a871bf0
...@@ -2369,7 +2369,7 @@ unsigned int mmc_calc_max_discard(struct mmc_card *card) ...@@ -2369,7 +2369,7 @@ unsigned int mmc_calc_max_discard(struct mmc_card *card)
return card->pref_erase; return card->pref_erase;
max_discard = mmc_do_calc_max_discard(card, MMC_ERASE_ARG); max_discard = mmc_do_calc_max_discard(card, MMC_ERASE_ARG);
if (mmc_can_trim(card)) { if (max_discard && mmc_can_trim(card)) {
max_trim = mmc_do_calc_max_discard(card, MMC_TRIM_ARG); max_trim = mmc_do_calc_max_discard(card, MMC_TRIM_ARG);
if (max_trim < max_discard) if (max_trim < max_discard)
max_discard = max_trim; max_discard = max_trim;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment