Merge branch 'upstream-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jgarzi...
[sfrench/cifs-2.6.git] / drivers / ata / libahci.c
index 1984a6e89e84450b55c7798b83a7232f2f16e6a8..81e772a94d59857187fda27dbfe7702469fb590f 100644 (file)
@@ -324,6 +324,7 @@ static ssize_t ahci_store_em_buffer(struct device *dev,
        struct ahci_host_priv *hpriv = ap->host->private_data;
        void __iomem *mmio = hpriv->mmio;
        void __iomem *em_mmio = mmio + hpriv->em_loc;
+       const unsigned char *msg_buf = buf;
        u32 em_ctl, msg;
        unsigned long flags;
        int i;
@@ -343,8 +344,8 @@ static ssize_t ahci_store_em_buffer(struct device *dev,
        }
 
        for (i = 0; i < size; i += 4) {
-               msg = buf[i] | buf[i + 1] << 8 |
-                     buf[i + 2] << 16 | buf[i + 3] << 24;
+               msg = msg_buf[i] | msg_buf[i + 1] << 8 |
+                     msg_buf[i + 2] << 16 | msg_buf[i + 3] << 24;
                writel(msg, em_mmio + i);
        }
 
@@ -541,29 +542,11 @@ static int ahci_scr_write(struct ata_link *link, unsigned int sc_reg, u32 val)
        return -EINVAL;
 }
 
-static int ahci_is_device_present(void __iomem *port_mmio)
-{
-       u8 status = readl(port_mmio + PORT_TFDATA) & 0xff;
-
-       /* Make sure PxTFD.STS.BSY and PxTFD.STS.DRQ are 0 */
-       if (status & (ATA_BUSY | ATA_DRQ))
-               return 0;
-
-       /* Make sure PxSSTS.DET is 3h */
-       status = readl(port_mmio + PORT_SCR_STAT) & 0xf;
-       if (status != 3)
-               return 0;
-       return 1;
-}
-
 void ahci_start_engine(struct ata_port *ap)
 {
        void __iomem *port_mmio = ahci_port_base(ap);
        u32 tmp;
 
-       if (!ahci_is_device_present(port_mmio))
-               return;
-
        /* start DMA */
        tmp = readl(port_mmio + PORT_CMD);
        tmp |= PORT_CMD_START;
@@ -1892,6 +1875,9 @@ static void ahci_error_handler(struct ata_port *ap)
        }
 
        sata_pmp_error_handler(ap);
+
+       if (!ata_dev_enabled(ap->link.device))
+               ahci_stop_engine(ap);
 }
 
 static void ahci_post_internal_cmd(struct ata_queued_cmd *qc)