linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ide/libata: fix ata_id_is_cfa() (take 3)
@ 2009-01-27 13:19 Sergei Shtylyov
  2009-01-27 13:38 ` Alan Cox
  0 siblings, 1 reply; 13+ messages in thread
From: Sergei Shtylyov @ 2009-01-27 13:19 UTC (permalink / raw)
  To: bzolnier, jgarzik; +Cc: linux-ide, alan, gdu

When checking for the CFA feature set support, ata_id_is_cfa() tests bit 2 in
word 82 of the identify data instead the word 83;  it also checks the ATA/PI
version support in the word 80 (which the CompactFlash specifications have as
reserved), this having no slightest chance to work on the modern CF cards that
don't have 0x848A in the word 0...

Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>

---
The patch has been updated to keep Alan feeling safe; there's a hope however
that his paranoia will assume more consistent form. :-)
I'm not sure who should queue this patch... it's against Linus' tree.

 include/linux/ata.h |   15 ++++++++++-----
 1 files changed, 10 insertions(+), 5 deletions(-)

Index: linux-2.6/include/linux/ata.h
===================================================================
--- linux-2.6.orig/include/linux/ata.h
+++ linux-2.6/include/linux/ata.h
@@ -731,12 +731,17 @@ static inline int ata_id_current_chs_val
 
 static inline int ata_id_is_cfa(const u16 *id)
 {
-	if (id[ATA_ID_CONFIG] == 0x848A)	/* Standard CF */
+	if (id[ATA_ID_CONFIG] == 0x848A)	/* Traditional CF */
 		return 1;
-	/* Could be CF hiding as standard ATA */
-	if (ata_id_major_version(id) >= 3 &&
-	    id[ATA_ID_COMMAND_SET_1] != 0xFFFF &&
-	   (id[ATA_ID_COMMAND_SET_1] & (1 << 2)))
+	/*
+	 * CF specs don't require specific value in the word 0 anymore and yet
+	 * they forbid to report the ATA version in the word 80 and require the
+	 * CFA feature set support to be indicated in the word 83 in this case.
+	 * Let's hope that the modern cards at least follow the word 80 rule
+	 * because some certainly don't follow the word 83 rule... :-/
+	 */
+	if (!id[ATA_ID_MAJOR_VER] &&
+	    (id[ATA_ID_COMMAND_SET_2] & 0xC004) == 0x4004)
 		return 1;
 	return 0;
 }


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2009-01-28 15:03 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-27 13:19 [PATCH] ide/libata: fix ata_id_is_cfa() (take 3) Sergei Shtylyov
2009-01-27 13:38 ` Alan Cox
2009-01-27 13:49   ` Jeff Garzik
2009-01-27 16:09     ` Sergei Shtylyov
2009-01-27 16:21       ` Sergei Shtylyov
2009-01-27 15:56   ` Mark Lord
2009-01-27 16:16     ` Sergei Shtylyov
2009-01-27 16:18       ` Mark Lord
2009-01-27 16:26         ` Sergei Shtylyov
2009-01-27 16:28           ` Mark Lord
2009-01-28  7:51       ` Dmitry Gryazin
2009-01-28 15:03         ` ide/libata: fix ata_id_is_cfa() .. hdparm-9.10 Mark Lord
2009-01-27 17:41     ` [PATCH] ide/libata: fix ata_id_is_cfa() (take 3) Mark Lord

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).