libata: update libata LLDs to use devres
[powerpc.git] / drivers / ata / sata_uli.c
index 8fc6e80..22eed6d 100644 (file)
@@ -61,13 +61,13 @@ static u32 uli_scr_read (struct ata_port *ap, unsigned int sc_reg);
 static void uli_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val);
 
 static const struct pci_device_id uli_pci_tbl[] = {
-       { PCI_VENDOR_ID_AL, 0x5289, PCI_ANY_ID, PCI_ANY_ID, 0, 0, uli_5289 },
-       { PCI_VENDOR_ID_AL, 0x5287, PCI_ANY_ID, PCI_ANY_ID, 0, 0, uli_5287 },
-       { PCI_VENDOR_ID_AL, 0x5281, PCI_ANY_ID, PCI_ANY_ID, 0, 0, uli_5281 },
+       { PCI_VDEVICE(AL, 0x5289), uli_5289 },
+       { PCI_VDEVICE(AL, 0x5287), uli_5287 },
+       { PCI_VDEVICE(AL, 0x5281), uli_5281 },
+
        { }     /* terminate list */
 };
 
-
 static struct pci_driver uli_pci_driver = {
        .name                   = DRV_NAME,
        .id_table               = uli_pci_tbl,
@@ -122,13 +122,12 @@ static const struct ata_port_operations uli_ops = {
        .scr_write              = uli_scr_write,
 
        .port_start             = ata_port_start,
-       .port_stop              = ata_port_stop,
-       .host_stop              = ata_host_stop,
 };
 
 static struct ata_port_info uli_port_info = {
        .sht            = &uli_sht,
-       .flags          = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY,
+       .flags          = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
+                         ATA_FLAG_IGN_SIMPLEX,
        .pio_mask       = 0x1f,         /* pio0-4 */
        .udma_mask      = 0x7f,         /* udma0-6 */
        .port_ops       = &uli_ops,
@@ -185,44 +184,39 @@ static int uli_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
 {
        static int printed_version;
        struct ata_probe_ent *probe_ent;
-       struct ata_port_info *ppi;
+       struct ata_port_info *ppi[2];
        int rc;
        unsigned int board_idx = (unsigned int) ent->driver_data;
-       int pci_dev_busy = 0;
        struct uli_priv *hpriv;
 
        if (!printed_version++)
                dev_printk(KERN_INFO, &pdev->dev, "version " DRV_VERSION "\n");
 
-       rc = pci_enable_device(pdev);
+       rc = pcim_enable_device(pdev);
        if (rc)
                return rc;
 
        rc = pci_request_regions(pdev, DRV_NAME);
        if (rc) {
-               pci_dev_busy = 1;
-               goto err_out;
+               pcim_pin_device(pdev);
+               return rc;
        }
 
        rc = pci_set_dma_mask(pdev, ATA_DMA_MASK);
        if (rc)
-               goto err_out_regions;
+               return rc;
        rc = pci_set_consistent_dma_mask(pdev, ATA_DMA_MASK);
        if (rc)
-               goto err_out_regions;
+               return rc;
 
-       ppi = &uli_port_info;
-       probe_ent = ata_pci_init_native_mode(pdev, &ppi, ATA_PORT_PRIMARY | ATA_PORT_SECONDARY);
-       if (!probe_ent) {
-               rc = -ENOMEM;
-               goto err_out_regions;
-       }
+       ppi[0] = ppi[1] = &uli_port_info;
+       probe_ent = ata_pci_init_native_mode(pdev, ppi, ATA_PORT_PRIMARY | ATA_PORT_SECONDARY);
+       if (!probe_ent)
+               return -ENOMEM;
 
-       hpriv = kzalloc(sizeof(*hpriv), GFP_KERNEL);
-       if (!hpriv) {
-               rc = -ENOMEM;
-               goto err_out_probe_ent;
-       }
+       hpriv = devm_kzalloc(&pdev->dev, sizeof(*hpriv), GFP_KERNEL);
+       if (!hpriv)
+               return -ENOMEM;
 
        probe_ent->private_data = hpriv;
 
@@ -268,21 +262,11 @@ static int uli_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
        pci_set_master(pdev);
        pci_intx(pdev, 1);
 
-       /* FIXME: check ata_device_add return value */
-       ata_device_add(probe_ent);
-       kfree(probe_ent);
+       if (!ata_device_add(probe_ent))
+               return -ENODEV;
 
+       devm_kfree(&pdev->dev, probe_ent);
        return 0;
-
-err_out_probe_ent:
-       kfree(probe_ent);
-err_out_regions:
-       pci_release_regions(pdev);
-err_out:
-       if (!pci_dev_busy)
-               pci_disable_device(pdev);
-       return rc;
-
 }
 
 static int __init uli_init(void)