libata: update libata core layer to use devres
[powerpc.git] / drivers / ata / ahci.c
index 48616c6..d725683 100644 (file)
@@ -431,7 +431,7 @@ static const struct pci_device_id ahci_pci_tbl[] = {
 
        /* Generic, PCI class code for AHCI */
        { PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
-         0x010601, 0xffffff, board_ahci },
+         PCI_CLASS_STORAGE_SATA_AHCI, 0xffffff, board_ahci },
 
        { }     /* terminate list */
 };
@@ -1173,7 +1173,7 @@ static void ahci_host_intr(struct ata_port *ap)
                 * dangerous, we need to know more about them.  Print
                 * more of it.
                 */
-               const u32 *f = pp->rx_fis + RX_FIS_SDB;
+               const __le32 *f = pp->rx_fis + RX_FIS_SDB;
 
                ata_port_printk(ap, KERN_INFO, "Spurious SDB FIS during NCQ "
                                "issue=0x%x SAct=0x%x FIS=%08x:%08x%s\n",
@@ -1397,7 +1397,9 @@ static int ahci_pci_device_resume(struct pci_dev *pdev)
        void __iomem *mmio = host->mmio_base;
        int rc;
 
-       ata_pci_device_do_resume(pdev);
+       rc = ata_pci_device_do_resume(pdev);
+       if (rc)
+               return rc;
 
        if (pdev->dev.power.power_state.event == PM_EVENT_SUSPEND) {
                rc = ahci_reset_controller(mmio, pdev);
@@ -1619,11 +1621,11 @@ static void ahci_print_info(struct ata_probe_ent *probe_ent)
                speed_s = "?";
 
        pci_read_config_word(pdev, 0x0a, &cc);
-       if (cc == 0x0101)
+       if (cc == PCI_CLASS_STORAGE_IDE)
                scc_s = "IDE";
-       else if (cc == 0x0106)
+       else if (cc == PCI_CLASS_STORAGE_SATA)
                scc_s = "SATA";
-       else if (cc == 0x0104)
+       else if (cc == PCI_CLASS_STORAGE_RAID)
                scc_s = "RAID";
        else
                scc_s = "unknown";
@@ -1685,13 +1687,9 @@ static int ahci_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
        if (!printed_version++)
                dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
 
-       /* JMicron-specific fixup: make sure we're in AHCI mode */
-       /* This is protected from races with ata_jmicron by the pci probe
-          locking */
        if (pdev->vendor == PCI_VENDOR_ID_JMICRON) {
-               /* AHCI enable, AHCI on function 0 */
-               pci_write_config_byte(pdev, 0x41, 0xa1);
-               /* Function 1 is the PATA controller */
+               /* Function 1 is the PATA controller except on the 368, where
+                  we are not AHCI anyway */
                if (PCI_FUNC(pdev->devfn))
                        return -ENODEV;
        }
@@ -1786,38 +1784,24 @@ err_out:
        return rc;
 }
 
-static void ahci_remove_one (struct pci_dev *pdev)
+static void ahci_remove_one(struct pci_dev *pdev)
 {
        struct device *dev = pci_dev_to_dev(pdev);
        struct ata_host *host = dev_get_drvdata(dev);
        struct ahci_host_priv *hpriv = host->private_data;
-       unsigned int i;
-       int have_msi;
-
-       for (i = 0; i < host->n_ports; i++)
-               ata_port_detach(host->ports[i]);
 
-       have_msi = hpriv->flags & AHCI_FLAG_MSI;
-       free_irq(host->irq, host);
+       ata_host_remove(host);
 
-       for (i = 0; i < host->n_ports; i++) {
-               struct ata_port *ap = host->ports[i];
-
-               ata_scsi_release(ap->scsi_host);
-               scsi_host_put(ap->scsi_host);
-       }
-
-       kfree(hpriv);
        pci_iounmap(pdev, host->mmio_base);
-       kfree(host);
 
-       if (have_msi)
+       if (hpriv->flags & AHCI_FLAG_MSI)
                pci_disable_msi(pdev);
        else
                pci_intx(pdev, 0);
        pci_release_regions(pdev);
        pci_disable_device(pdev);
        dev_set_drvdata(dev, NULL);
+       kfree(hpriv);
 }
 
 static int __init ahci_init(void)