Skip to content

Commit

Permalink
mmc_spi: fail gracefully if host or card do not support the switch co…
Browse files Browse the repository at this point in the history
…mmand

Some time ago, I have send a patch to the mmc_spi subsystem changing the
error codes.  This was after a discussion with Pierre about using EINVAL
only for non-recoverable errors.  This patch was accepted as

http://git.kernel.org/linus/fdd858db7113ca64132de390188d7ca00701013d

Unfortunately, several weeks later, I realized that this patch has opened
a little can of worms because there are SD cards on the market which

a) claim that they support the switch command
AND
b) refuse to execute this command if operating in SPI mode.

So, such a card would get unusuable in an embedded linux system in SPI
mode, because the init sequence terminates with an error.

This patch adds the missing error codes to the caller of the switch
command and restores the old behaviour to fail gracefully if these
commands can not execute.

Signed-off-by: Wolfgang Muees <wolfgang.mues@auerswald.de>
Cc: <linux-mmc@vger.kernel.org>
Cc: <stable@kernel.org>		[2.6.31.x]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Wolfgang Muees authored and Linus Torvalds committed Sep 23, 2009
1 parent 82cf818 commit d08ebed
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions drivers/mmc/core/mmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,11 @@ static int mmc_read_ext_csd(struct mmc_card *card)

err = mmc_send_ext_csd(card, ext_csd);
if (err) {
/*
* We all hosts that cannot perform the command
* to fail more gracefully
*/
if (err != -EINVAL)
/* If the host or the card can't do the switch,
* fail more gracefully. */
if ((err != -EINVAL)
&& (err != -ENOSYS)
&& (err != -EFAULT))
goto out;

/*
Expand Down
10 changes: 5 additions & 5 deletions drivers/mmc/core/sd.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,11 +210,11 @@ static int mmc_read_switch(struct mmc_card *card)

err = mmc_sd_switch(card, 0, 0, 1, status);
if (err) {
/*
* We all hosts that cannot perform the command
* to fail more gracefully
*/
if (err != -EINVAL)
/* If the host or the card can't do the switch,
* fail more gracefully. */
if ((err != -EINVAL)
&& (err != -ENOSYS)
&& (err != -EFAULT))
goto out;

printk(KERN_WARNING "%s: problem reading switch "
Expand Down

0 comments on commit d08ebed

Please sign in to comment.