]> git.baikalelectronics.ru Git - kernel.git/commit
mmc:fix a bug when max_discard is 0
authorJiong Wu <lohengrin1024@gmail.com>
Thu, 28 Feb 2019 16:18:33 +0000 (00:18 +0800)
committerUlf Hansson <ulf.hansson@linaro.org>
Fri, 1 Mar 2019 08:50:10 +0000 (09:50 +0100)
commitbcd94722e8d1065971f750a4b897edc62c408d0e
tree1b8470579a6f38604ee40fc3e25f37480a737255
parent044ab9e2a5147d302881a86fe8a9fdcc5ca4b01b
mmc:fix a bug when max_discard is 0

The original purpose of the code I fix is to replace max_discard with
max_trim if max_trim is less than max_discard. When max_discard is 0
we should replace max_discard with max_trim as well, because
max_discard equals 0 happens only when the max_do_calc_max_discard
process is overflowed, so if mmc_can_trim(card) is true, max_discard
should be replaced by an available max_trim.
However, in the original code, there are two lines of code interfere
the right process.
1) if (max_discard && mmc_can_trim(card))
when max_discard is 0, it skips the process checking if max_discard
needs to be replaced with max_trim.
2) if (max_trim < max_discard)
the condition is false when max_discard is 0. it also skips the process
that replaces max_discard with max_trim, in fact, we should replace the
0-valued max_discard with max_trim.

Signed-off-by: Jiong Wu <Lohengrin1024@gmail.com>
Fixes: 3ead3a709fda (mmc: core: optimize mmc_calc_max_discard)
Cc: stable@vger.kernel.org # v4.17+
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
drivers/mmc/core/core.c