Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=54936f8b099325992f0f212a5e366fd5257c6c9c
Commit:     54936f8b099325992f0f212a5e366fd5257c6c9c
Parent:     f4d6d00466ef4879e4289f18c2f59210a06a7ada
Author:     Tejun Heo <[EMAIL PROTECTED]>
AuthorDate: Fri May 11 14:35:29 2007 +0200
Committer:  Jeff Garzik <[EMAIL PROTECTED]>
CommitDate: Fri May 11 18:09:18 2007 -0400

    libata: fallback to the other IDENTIFY on device error, take#2
    
    It seems the world isn't as frank as we thought and some devices lie
    about who they are.  Fallback to the other IDENTIFY if IDENTIFY is
    aborted by the device.  As this is the strategy used by IDE for a long
    time, it shouldn't cause too much problem.
    
    Signed-off-by: Tejun Heo <[EMAIL PROTECTED]>
    Cc: William Thompson <[EMAIL PROTECTED]>
    Signed-off-by: Jeff Garzik <[EMAIL PROTECTED]>
---
 drivers/ata/libata-core.c |   22 +++++++++++++++++++++-
 1 files changed, 21 insertions(+), 1 deletions(-)

diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 6ac4f32..335ac8f 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -1660,7 +1660,7 @@ int ata_dev_read_id(struct ata_device *dev, unsigned int 
*p_class,
        struct ata_taskfile tf;
        unsigned int err_mask = 0;
        const char *reason;
-       int tried_spinup = 0;
+       int may_fallback = 1, tried_spinup = 0;
        int rc;
 
        if (ata_msg_ctl(ap))
@@ -1704,11 +1704,31 @@ int ata_dev_read_id(struct ata_device *dev, unsigned 
int *p_class,
                        return -ENOENT;
                }
 
+               /* Device or controller might have reported the wrong
+                * device class.  Give a shot at the other IDENTIFY if
+                * the current one is aborted by the device.
+                */
+               if (may_fallback &&
+                   (err_mask == AC_ERR_DEV) && (tf.feature & ATA_ABORTED)) {
+                       may_fallback = 0;
+
+                       if (class == ATA_DEV_ATA)
+                               class = ATA_DEV_ATAPI;
+                       else
+                               class = ATA_DEV_ATA;
+                       goto retry;
+               }
+
                rc = -EIO;
                reason = "I/O error";
                goto err_out;
        }
 
+       /* Falling back doesn't make sense if ID data was read
+        * successfully at least once.
+        */
+       may_fallback = 0;
+
        swap_buf_le16(id, ATA_ID_WORDS);
 
        /* sanity check */
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to