Skip to content

Commit 489d144

Browse files
cloehlestorulf
authored andcommitted
mmc: core: Fix ambiguous TRIM and DISCARD arg
Clean up the MMC_TRIM_ARGS define that became ambiguous with DISCARD introduction. While at it, let's fix one usage where MMC_TRIM_ARGS falsely included DISCARD too. Fixes: b3bf915 ("mmc: core: new discard feature support at eMMC v4.5") Signed-off-by: Christian Loehle <[email protected]> Acked-by: Adrian Hunter <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Ulf Hansson <[email protected]>
1 parent 222cfa0 commit 489d144

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

drivers/mmc/core/core.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1484,6 +1484,11 @@ void mmc_init_erase(struct mmc_card *card)
14841484
card->pref_erase = 0;
14851485
}
14861486

1487+
static bool is_trim_arg(unsigned int arg)
1488+
{
1489+
return (arg & MMC_TRIM_OR_DISCARD_ARGS) && arg != MMC_DISCARD_ARG;
1490+
}
1491+
14871492
static unsigned int mmc_mmc_erase_timeout(struct mmc_card *card,
14881493
unsigned int arg, unsigned int qty)
14891494
{
@@ -1766,7 +1771,7 @@ int mmc_erase(struct mmc_card *card, unsigned int from, unsigned int nr,
17661771
!(card->ext_csd.sec_feature_support & EXT_CSD_SEC_ER_EN))
17671772
return -EOPNOTSUPP;
17681773

1769-
if (mmc_card_mmc(card) && (arg & MMC_TRIM_ARGS) &&
1774+
if (mmc_card_mmc(card) && is_trim_arg(arg) &&
17701775
!(card->ext_csd.sec_feature_support & EXT_CSD_SEC_GB_CL_EN))
17711776
return -EOPNOTSUPP;
17721777

@@ -1796,7 +1801,7 @@ int mmc_erase(struct mmc_card *card, unsigned int from, unsigned int nr,
17961801
* identified by the card->eg_boundary flag.
17971802
*/
17981803
rem = card->erase_size - (from % card->erase_size);
1799-
if ((arg & MMC_TRIM_ARGS) && (card->eg_boundary) && (nr > rem)) {
1804+
if ((arg & MMC_TRIM_OR_DISCARD_ARGS) && card->eg_boundary && nr > rem) {
18001805
err = mmc_do_erase(card, from, from + rem - 1, arg);
18011806
from += rem;
18021807
if ((err) || (to <= from))

include/linux/mmc/mmc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ static inline bool mmc_ready_for_data(u32 status)
451451
#define MMC_SECURE_TRIM1_ARG 0x80000001
452452
#define MMC_SECURE_TRIM2_ARG 0x80008000
453453
#define MMC_SECURE_ARGS 0x80000000
454-
#define MMC_TRIM_ARGS 0x00008001
454+
#define MMC_TRIM_OR_DISCARD_ARGS 0x00008003
455455

456456
#define mmc_driver_type_mask(n) (1 << (n))
457457

0 commit comments

Comments
 (0)