[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[tyndur-devel] [PATCH] ata: Fix fuer Fehlerbehandlung in ATAPI



! ata: Das Fehlerregister ist nur gueltig, wenn ERR im Statusregister
  gesetzt ist.

Signed-off-by: Kevin Wolf <kevin@xxxxxxxxxx>
---
 src/modules/cdi/ata/atapi.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/modules/cdi/ata/atapi.c b/src/modules/cdi/ata/atapi.c
index 28b823a..77b1074 100644
--- a/src/modules/cdi/ata/atapi.c
+++ b/src/modules/cdi/ata/atapi.c
@@ -119,6 +119,7 @@ int atapi_request(struct cdi_scsi_device* scsi,struct cdi_scsi_packet* packet)
 
     if (ata_request(&request))
     {
+        int status;
         struct ata_request rw_request = {
             .dev = dev,
             .flags = {
@@ -138,8 +139,13 @@ int atapi_request(struct cdi_scsi_device* scsi,struct cdi_scsi_packet* packet)
         if (packet->direction==CDI_SCSI_READ) ata_protocol_pio_in(&rw_request);
         else if (packet->direction==CDI_SCSI_WRITE) ata_protocol_pio_in(&rw_request);
 
-        // Sense Key zurueck
-        return (ata_reg_inb(dev->controller,REG_ERROR)>>4);
+        // Bei Fehler den Sense Key zurueckgeben
+        status = ata_reg_inb(dev->controller, REG_STATUS);
+        if (status & STATUS_ERR) {
+            return (ata_reg_inb(dev->controller, REG_ERROR) >> 4);
+        } else {
+            return 0;
+        }
     }
 
     return 0xB;
-- 
1.6.0.2