MMC core:
 - mmc: core: Fixup max_discard/trim calculations
 - mmc: core: Announce SD specs greater than 4.0
 - mmc: core: Add discard support for SD cards
 - mmc: core: Don't do retries for CMD6 (SWITCH command)
 - mmc: core: Various cleanups and re-structuring

MMC host:
 - cqhci: Add maintainers for eMMC CQHCI driver
 - sdhci: Consolidate WP GPIO code
 - sdhci: Add ADMA3 DMA support for V4 enabled host
 - sdhci-pci-o2micro: Fixup card detect support
 - sdhci-tegra: Add support for CMDQ
 - sdhci-tegra: Support SDMMC pads auto-calibration
 - sdhci-esdhc-imx: Add DCMD support and CMDQ support
 - sdhci-esdhc-imx: Add support for i.MX6ULL variant
 - sdhci-esdhc-imx: Fixup HS400 timing issue
 - sdhci-esdhc-imx: Add HS400_ES support for i.MX8QXP
 - renesas_sdhi: Avoid CRC errors by adjusting settings to speed mode
 - renesas_sdhi: Fixup card initialization for high speed mode
 - omap: Fixup timeout settings
 - atmel-mci: Enable 8 bits bus-width support
 - jz4740: Convert some legacy code to use modern APIs
 - mmci: Send a CMD12 to clear DPSM at errors for STM32 sdmmc
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: b305882fbc87 (mmc: core: optimize mmc_calc_max_discard)
Cc: stable@vger.kernel.org # v4.17+
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
1 file changed