From: Sergio Valverde <vlvrdv@gmail.com>
Cc: Sergio Valverde <vlvrdv@gmail.com>,
Ulf Hansson <ulf.hansson@linaro.org>,
Linus Walleij <linus.walleij@linaro.org>,
Shawn Lin <shawn.lin@rock-chips.com>,
Adrian Hunter <adrian.hunter@intel.com>,
Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>,
linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v2] mmc: core: optimize mmc_calc_max_discard
Date: Thu, 8 Feb 2018 11:41:43 -0600 [thread overview]
Message-ID: <1518111705-11122-1-git-send-email-vlvrdv@gmail.com> (raw)
In-Reply-To: <1518047981-23958-1-git-send-email-vlvrdv@gmail.com>
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>
---
Changes in v2:
- Evaluate max_discard to avoid unnecessary calls to mmc_can_trim.
drivers/mmc/core/core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index 1f0f44f..c32c0f4 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -2567,7 +2567,7 @@ unsigned int mmc_calc_max_discard(struct mmc_card *card)
return card->pref_erase;
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);
if (max_trim < max_discard)
max_discard = max_trim;
--
2.7.4
next prev parent reply other threads:[~2018-02-08 17:43 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-07 23:59 [PATCH] mmc: core: optimize mmc_calc_max_discard Sergio Valverde
2018-02-08 17:41 ` Sergio Valverde [this message]
2018-02-09 7:38 ` [PATCH v2] " Shawn Lin
2018-02-14 10:38 ` Ulf Hansson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1518111705-11122-1-git-send-email-vlvrdv@gmail.com \
--to=vlvrdv@gmail.com \
--cc=adrian.hunter@intel.com \
--cc=b.zolnierkie@samsung.com \
--cc=linus.walleij@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=shawn.lin@rock-chips.com \
--cc=ulf.hansson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).