Commit 904f470b authored by Wolfgang Muees's avatar Wolfgang Muees Committed by Greg Kroah-Hartman

mmc_spi: fail gracefully if host or card do not support the switch command

commit d08ebedd upstream.

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: default avatarWolfgang Muees <wolfgang.mues@auerswald.de>
Cc: <linux-mmc@vger.kernel.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent b0143604
...@@ -180,11 +180,11 @@ static int mmc_read_ext_csd(struct mmc_card *card) ...@@ -180,11 +180,11 @@ static int mmc_read_ext_csd(struct mmc_card *card)
err = mmc_send_ext_csd(card, ext_csd); err = mmc_send_ext_csd(card, ext_csd);
if (err) { if (err) {
/* /* If the host or the card can't do the switch,
* We all hosts that cannot perform the command * fail more gracefully. */
* to fail more gracefully if ((err != -EINVAL)
*/ && (err != -ENOSYS)
if (err != -EINVAL) && (err != -EFAULT))
goto out; goto out;
/* /*
......
...@@ -210,11 +210,11 @@ static int mmc_read_switch(struct mmc_card *card) ...@@ -210,11 +210,11 @@ static int mmc_read_switch(struct mmc_card *card)
err = mmc_sd_switch(card, 0, 0, 1, status); err = mmc_sd_switch(card, 0, 0, 1, status);
if (err) { if (err) {
/* /* If the host or the card can't do the switch,
* We all hosts that cannot perform the command * fail more gracefully. */
* to fail more gracefully if ((err != -EINVAL)
*/ && (err != -ENOSYS)
if (err != -EINVAL) && (err != -EFAULT))
goto out; goto out;
printk(KERN_WARNING "%s: problem reading switch " printk(KERN_WARNING "%s: problem reading switch "
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment