mmc_spi: fail gracefully if host or card do not support the switch command
PATCH 1/1 mmc_spi: fail gracefully if host or card do not support the switch command
From: Wolfgang Muees <[email protected]>
The switch command (typically speed switching from 25 to 50 MHz clock) can be rejected by _both_ the host controller/driver and by the card. Elder revisions of the SD card do not support speed switching. Fail gracefully if the reject is comming from the card.
---
drivers/mmc/core/mmc.c +5 -5
@@ -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;/*
drivers/mmc/core/sd.c +5 -5
@@ -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
Signature · 13 lines
Auerswald GmbH & Co. KG Hardware Development Telefon: +49 (0)5306 9219 0 Telefax: +49 (0)5306 9219 94 E-Mail: [email protected] 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
Quoted 9 lines · On Thu, 11 Jun 2009 16:13:27 +0100 Wolfgang Mües <[email protected]>…
From: Wolfgang Muees <[email protected]>
The switch command (typically speed switching from 25 to 50 MHz clock) can be rejected by _both_ the host controller/driver and by the card. Elder revisions of the SD card do not support speed switching. Fail gracefully if the reject is comming from the card.
Signed-off-by Wolfgang Muees <[email protected]>
Have you ever seen this in practice? For SD there are several checks before the switch command is actually issued. Sounds like there is something else wrong here. Have you turned off your EMP thingy? ;)
PS. Please use the @ossman.eu address.
Rgds
Signature · 6 lines
-- Pierre Ossman WARNING: This correspondence is being monitored by the Swedish government. Make sure your server uses encryption for SMTP traffic and consider using PGP for end-to-end encryption.
Hello Pierre,
Am Samstag, 13. Juni 2009 schrieb Pierre Ossman:
Quoted 6 lines
Quoted 4 lines
The switch command (typically speed switching from 25 to 50 MHz clock) can be rejected by _both_ the host controller/driver and by the card. Elder revisions of the SD card do not support speed switching. Fail gracefully if the reject is comming from the card.
Have you ever seen this in practice?
Yes, I have. An old 1 GByte SD card.
Quoted 2 lines
For SD there are several checks
before the switch command is actually issued.
But there are two cases not covered by these checks:
a) the switch command is supported, but the card is not capable of switching to 50 MHz.
b) the card rejects the switch command in SPI mode, because it is not mandatory here.
So yes, the checks can be improved. But only extending the error codes was a simple, fast and minimal solution.
regards
i. A. Wolfgang Mües
Signature · 13 lines
Auerswald GmbH & Co. KG Hardware Development Telefon: +49 (0)5306 9219 0 Telefax: +49 (0)5306 9219 94 E-Mail: [email protected] 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
Quoted 9 lines · On Mon, 15 Jun 2009 10:36:05 +0200 Wolfgang Mües <[email protected]>…
Am Samstag, 13. Juni 2009 schrieb Pierre Ossman:
Quoted 2 lines
For SD there are several checks
before the switch command is actually issued.But there are two cases not covered by these checks:
a) the switch command is supported, but the card is not capable of switching to 50 MHz.
But a successful switch command (even if the response is that the card cannot do it) should not need the checks you added. The switch data structure is checked further down.
Quoted 2 lines
b) the card rejects the switch command in SPI mode, because it is not mandatory here.
I cannot see anything in the spec backing up this claim.
Rgds
Signature · 6 lines
-- Pierre Ossman WARNING: This correspondence is being monitored by the Swedish government. Make sure your server uses encryption for SMTP traffic and consider using PGP for end-to-end encryption.