mmc: core: Check SWITCH_ERROR bit from each CMD13 response when polling
authorUlf Hansson <ulf.hansson@linaro.org>
Mon, 21 Nov 2016 14:49:48 +0000 (15:49 +0100)
committerNitin Garg <nitin.garg@nxp.com>
Mon, 19 Mar 2018 20:36:51 +0000 (15:36 -0500)
commit49325e59c89b5647ca96f23a0cb14fce4d355ef2
treeab4b0a02a25fe83c15cd624dfef95538baf164e5
parent200f5dbef3fb21b2889f1e50461ba7140cc2f905
mmc: core: Check SWITCH_ERROR bit from each CMD13 response when polling

According to the JEDEC specification, the SWITCH_ERROR bit in the device
status from a R1 response, is an error bit which may be cleared as soon as
the response that reports the error is sent.

When polling with CMD13 to find out when the card stops signaling busy
after a CMD6 has been sent, we currently parse only the last CMD13 response
for the SWITCH_ERROR bit. Consequentially we could loose important
information about the card.

In worst case if the card stops signaling busy within the allowed timeout,
we could end up believing that the CMD6 command completed successfully,
when in fact it didn't.

To improve the behaviour, let's parse each CMD13 response to see if the
SWITCH_ERROR bit is set in the device status. In such case, we abort the
polling loop and report the error.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Tested-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
(cherry picked from commit 5ec32f84111a500c142961c82dd415c22e64e2be)
drivers/mmc/core/mmc_ops.c