OSDN Git Service

mmc: core: Adjust and reuse the macro of R1_STATUS(x)
authorShawn Lin <shawn.lin@rock-chips.com>
Wed, 30 May 2018 02:11:43 +0000 (10:11 +0800)
committerUlf Hansson <ulf.hansson@linaro.org>
Mon, 16 Jul 2018 09:21:45 +0000 (11:21 +0200)
commita94a7483a91cb6a0d15a4413e8fc853f33a4e1b9
tree3d402009c224b88ff2ff05dfa2a96311cfb9ecb4
parent2fb166e50e2f1cbf07cbfa1385a7b4bc922813db
mmc: core: Adjust and reuse the macro of R1_STATUS(x)

R1_STATUS(x) now is only used by ioctl_rpmb_card_status_poll(),
which checks all bits as possible. But according to the spec,
bit 17 and bit 18 should be ignored, as well bit 14 which is
reserved(must be set to 0) quoting from the spec and these rule
apply to all places checking the device status. So change
its checking from 0xFFFFE000 to 0xFFF9A000.

As a bonus, we reuse it for mmc_do_erase() as well as
mmc_switch_status_error().
(1) Currently mmc_switch_status_error() doesn't check bit 25, but
it means device is locked but not unlocked by CMD42 prior to any
operations which need check busy, which is also not allowed.
(2) mmc_do_erase() also forgot to to check bit 15, WP_ERASE_SKIP.
The spec says "Only partial address space was erased due to existing
write protected blocks.", which obviously means we should fail this I/O.
Otherwise, the partial erased data stored in nonvalatile flash violates
the data integrity from the view of I/O owner, which probably confuse
it when further used.

So reusing R1_STATUS for them not only improve the readability but also
slove real problems.

Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
drivers/mmc/core/core.c
drivers/mmc/core/mmc_ops.c
include/linux/mmc/mmc.h