Skip to content

Commit

Permalink
mmc_spi: don't use EINVAL for possible transmission errors
Browse files Browse the repository at this point in the history
This patch changes the reported error code for the responses
to a command from EINVAL to EFAULT/ENOSYS, as EINVAL is reserved
for non-recoverable host errors, and the responses from
the SD/MMC card may be because of recoverable transmission
errors in the command or in the response. Response codes
in SPI mode are NOT protected by a checksum, so don't trust them.

Signed-off-by: Wolfgang Muees <wolfgang.mues@auerswald.de>
Acked-by: Matt Fleming <matt@console-pimps.org>
Signed-off-by: Pierre Ossman <pierre@ossman.eu>
  • Loading branch information
Wolfgang Muees authored and Pierre Ossman committed Jun 13, 2009
1 parent c54f6bc commit fdd858d
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions drivers/mmc/host/mmc_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -335,15 +335,16 @@ static int mmc_spi_response_get(struct mmc_spi_host *host,

/* Status byte: the entire seven-bit R1 response. */
if (cmd->resp[0] != 0) {
if ((R1_SPI_PARAMETER | R1_SPI_ADDRESS
| R1_SPI_ILLEGAL_COMMAND)
if ((R1_SPI_PARAMETER | R1_SPI_ADDRESS)
& cmd->resp[0])
value = -EINVAL;
value = -EFAULT; /* Bad address */
else if (R1_SPI_ILLEGAL_COMMAND & cmd->resp[0])
value = -ENOSYS; /* Function not implemented */
else if (R1_SPI_COM_CRC & cmd->resp[0])
value = -EILSEQ;
value = -EILSEQ; /* Illegal byte sequence */
else if ((R1_SPI_ERASE_SEQ | R1_SPI_ERASE_RESET)
& cmd->resp[0])
value = -EIO;
value = -EIO; /* I/O error */
/* else R1_SPI_IDLE, "it's resetting" */
}

Expand Down

0 comments on commit fdd858d

Please sign in to comment.