[PATCH] libata: improve handling of diagostic fail (and hardware that misreports it)
[pandora-kernel.git] / drivers / ata / libata-core.c
index bb66a12..753b015 100644 (file)
@@ -616,8 +616,11 @@ ata_dev_try_classify(struct ata_port *ap, unsigned int device, u8 *r_err)
        if (r_err)
                *r_err = err;
 
-       /* see if device passed diags */
-       if (err == 1)
+       /* see if device passed diags: if master then continue and warn later */
+       if (err == 0 && device == 0)
+               /* diagnostic fail : do nothing _YET_ */
+               ap->device[device].horkage |= ATA_HORKAGE_DIAGNOSTIC;
+       else if (err == 1)
                /* do nothing */ ;
        else if ((device == 0) && (err == 0x81))
                /* do nothing */ ;
@@ -1276,10 +1279,15 @@ int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class,
        swap_buf_le16(id, ATA_ID_WORDS);
 
        /* sanity check */
-       if ((class == ATA_DEV_ATA) != (ata_id_is_ata(id) | ata_id_is_cfa(id))) {
-               rc = -EINVAL;
-               reason = "device reports illegal type";
-               goto err_out;
+       rc = -EINVAL;
+       reason = "device reports illegal type";
+
+       if (class == ATA_DEV_ATA) {
+               if (!ata_id_is_ata(id) && !ata_id_is_cfa(id))
+                       goto err_out;
+       } else {
+               if (ata_id_is_ata(id))
+                       goto err_out;
        }
 
        if (post_reset && class == ATA_DEV_ATA) {
@@ -1518,6 +1526,18 @@ int ata_dev_configure(struct ata_device *dev, int print_info)
                                       cdb_intr_string);
        }
 
+       if (dev->horkage & ATA_HORKAGE_DIAGNOSTIC) {
+               /* Let the user know. We don't want to disallow opens for
+                  rescue purposes, or in case the vendor is just a blithering
+                  idiot */
+                if (print_info) {
+                       ata_dev_printk(dev, KERN_WARNING,
+"Drive reports diagnostics failure. This may indicate a drive\n");
+                       ata_dev_printk(dev, KERN_WARNING,
+"fault or invalid emulation. Contact drive vendor for information.\n");
+               }
+       }
+
        ata_set_port_max_cmd_len(ap);
 
        /* limit bridge transfers to udma5, 200 sectors */