]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
ide: add ide_dev_is_sata() helper (take 2)
authorSergei Shtylyov <sshtylyov@ru.mvista.com>
Tue, 11 Sep 2007 20:28:36 +0000 (22:28 +0200)
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Tue, 11 Sep 2007 20:28:36 +0000 (22:28 +0200)
Make the SATA drive detection code from eighty_ninty_three() into inline
ide_dev_is_sata() helper fixing it along the way to be more strict while
checking word 80 for the reserved values...

Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
drivers/ide/ide-iops.c
include/linux/ide.h

index f4cd2700cae5f6ed366542e7c86c041482d2d6fe..646a54e233d361451bfab4982a1da96956be82a2 100644 (file)
@@ -615,8 +615,7 @@ u8 eighty_ninty_three (ide_drive_t *drive)
        if (hwif->cbl != ATA_CBL_PATA80 && !ivb)
                goto no_80w;
 
-       /* Check for SATA but only if we are ATA5 or higher */
-       if (id->hw_config == 0 && (id->major_rev_num & 0x7FE0))
+       if (ide_dev_is_sata(id))
                return 1;
 
        /*
index c792b4fd1588f1b36c987ebebc45e25489de6021..b9f66c10caa04b26a413fb450ce8237d91c74e5a 100644 (file)
@@ -1378,6 +1378,19 @@ static inline int ide_dev_has_iordy(struct hd_driveid *id)
        return ((id->field_valid & 2) && (id->capability & 8)) ? 1 : 0;
 }
 
+static inline int ide_dev_is_sata(struct hd_driveid *id)
+{
+       /*
+        * See if word 93 is 0 AND drive is at least ATA-5 compatible
+        * verifying that word 80 by casting it to a signed type --
+        * this trick allows us to filter out the reserved values of
+        * 0x0000 and 0xffff along with the earlier ATA revisions...
+        */
+       if (id->hw_config == 0 && (short)id->major_rev_num >= 0x0020)
+               return 1;
+       return 0;
+}
+
 u8 ide_dump_status(ide_drive_t *, const char *, u8);
 
 typedef struct ide_pio_timings_s {