diff options
author | Christian Löhle <CLoehle@hyperstone.com> | 2023-01-16 11:18:59 +0000 |
---|---|---|
committer | Ulf Hansson <ulf.hansson@linaro.org> | 2023-02-09 15:16:51 +0100 |
commit | d4c2910981ff99b983734426dfa99632fb81ac6b (patch) | |
tree | e6a94c5568ac07c239143b43576f53f95b337801 | |
parent | a08f08ec675261a7d7c141f818a613a304e85be8 (diff) | |
download | mmc-utils-d4c2910981ff99b983734426dfa99632fb81ac6b.tar.gz |
mmc-utils: Add basic erase error check
Check for erase specific R1 errors so e.g. an OOR erase is not
reported as successful when it never executed.
There could be checks for more error bits but R1_ERASE_SEQ_ERROR
on CMD38 should catch all that are reported by hardware anyway.
Signed-off-by: Christian Loehle <cloehle@hyperstone.com>
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Link: https://lore.kernel.org/r/c91cdde6288d4db6aad45f5d50d129c8@hyperstone.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
-rw-r--r-- | mmc_cmds.c | 13 |
1 files changed, 12 insertions, 1 deletions
@@ -54,7 +54,6 @@ #define WPTYPE_PWRON 2 #define WPTYPE_PERM 3 - int read_extcsd(int fd, __u8 *ext_csd) { int ret = 0; @@ -2700,6 +2699,18 @@ static int erase(int dev_fd, __u32 argin, __u32 start, __u32 end) if (ret) perror("Erase multi-cmd ioctl"); + /* Does not work for SPI cards */ + if (multi_cmd->cmds[1].response[0] & R1_ERASE_PARAM) { + fprintf(stderr, "Erase start response: 0x%08x\n", + multi_cmd->cmds[0].response[0]); + ret = -EIO; + } + if (multi_cmd->cmds[2].response[0] & R1_ERASE_SEQ_ERROR) { + fprintf(stderr, "Erase response: 0x%08x\n", + multi_cmd->cmds[2].response[0]); + ret = -EIO; + } + free(multi_cmd); return ret; } |