From: "Wolfgang Mües" <wolfgang.mues@auerswald.de>
To: "Andrew Morton" <akpm@linux-foundation.org>,
linux-kernel@vger.kernel.org, linux-mmc@vger.kernel.org
Subject: [PATCH] mmc_spi: fail gracefully if host or card do not support the switch command
Date: Wed, 9 Sep 2009 14:02:30 +0100 [thread overview]
Message-ID: <200909091502.30345.wolfgang.mues@auerswald.de> (raw)
From: Wolfgang Muees <wolfgang.mues@auerswald.de>
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 bahaviour to fail gracefully if these commands can not
execute.
This patch should go into 2.6.31 to show up in embedded systems ASAP.
Signed-off-by: Wolfgang Muees <wolfgang.mues@auerswald.de>
---
diff -uprN 2_6_31_rc8/drivers/mmc/core/mmc.c 2_6_31_rc8_switch/drivers/mmc/core/mmc.c
--- 2_6_31_rc8/drivers/mmc/core/mmc.c 2009-08-28 02:59:04.000000000 +0200
+++ 2_6_31_rc8_switch/drivers/mmc/core/mmc.c 2009-09-09 14:44:45.000000000 +0200
@@ -180,11 +180,11 @@ static int mmc_read_ext_csd(struct mmc_c
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;
/*
diff -uprN 2_6_31_rc8/drivers/mmc/core/sd.c 2_6_31_rc8_switch/drivers/mmc/core/sd.c
--- 2_6_31_rc8/drivers/mmc/core/sd.c 2009-08-28 02:59:04.000000000 +0200
+++ 2_6_31_rc8_switch/drivers/mmc/core/sd.c 2009-09-09 14:45:34.000000000 +0200
@@ -210,11 +210,11 @@ static int mmc_read_switch(struct mmc_ca
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 "
---
regards
i. A. Wolfgang Mües
--
Auerswald GmbH & Co. KG
Hardware Development
Telefon: +49 (0)5306 9219 0
Telefax: +49 (0)5306 9219 94
E-Mail: Wolfgang.Mues@Auerswald.de
Web: http://www.auerswald.de
--------------------------------------------------------------
Auerswald GmbH & Co. KG, Vor den Grashöfen 1, 38162 Cremlingen
Registriert beim AG Braunschweig HRA 13289
p.h.G Auerswald Geschäftsführungsges. mbH
Registriert beim AG Braunschweig HRB 7463
Geschäftsführer: Dipl-Ing. Gerhard Auerswald
next reply other threads:[~2009-09-09 13:12 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-09 13:02 Wolfgang Mües [this message]
-- strict thread matches above, loose matches on Subject: below --
2009-06-11 15:13 Wolfgang Mües
2009-06-13 11:08 ` Pierre Ossman
2009-06-15 8:36 ` Wolfgang Mües
2009-06-15 19:24 ` Pierre Ossman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200909091502.30345.wolfgang.mues@auerswald.de \
--to=wolfgang.mues@auerswald.de \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®