libata: update libata LLDs to use devres
[powerpc.git] / drivers / ata / pata_pdc2027x.c
index 56b8c1e..1c106b8 100644 (file)
 #include <scsi/scsi_host.h>
 #include <scsi/scsi_cmnd.h>
 #include <linux/libata.h>
-#include <asm/io.h>
 
 #define DRV_NAME       "pata_pdc2027x"
-#define DRV_VERSION    "0.74-ac3"
+#define DRV_VERSION    "0.74-ac5"
 #undef PDC_DEBUG
 
 #ifdef PDC_DEBUG
@@ -62,7 +61,6 @@ enum {
 };
 
 static int pdc2027x_init_one(struct pci_dev *pdev, const struct pci_device_id *ent);
-static void pdc2027x_remove_one(struct pci_dev *pdev);
 static void pdc2027x_error_handler(struct ata_port *ap);
 static void pdc2027x_set_piomode(struct ata_port *ap, struct ata_device *adev);
 static void pdc2027x_set_dmamode(struct ata_port *ap, struct ata_device *adev);
@@ -108,13 +106,14 @@ static struct pdc2027x_udma_timing {
 };
 
 static const struct pci_device_id pdc2027x_pci_tbl[] = {
-       { PCI_VENDOR_ID_PROMISE, PCI_DEVICE_ID_PROMISE_20268, PCI_ANY_ID, PCI_ANY_ID, 0, 0, PDC_UDMA_100 },
-       { PCI_VENDOR_ID_PROMISE, PCI_DEVICE_ID_PROMISE_20269, PCI_ANY_ID, PCI_ANY_ID, 0, 0, PDC_UDMA_133 },
-       { PCI_VENDOR_ID_PROMISE, PCI_DEVICE_ID_PROMISE_20270, PCI_ANY_ID, PCI_ANY_ID, 0, 0, PDC_UDMA_100 },
-       { PCI_VENDOR_ID_PROMISE, PCI_DEVICE_ID_PROMISE_20271, PCI_ANY_ID, PCI_ANY_ID, 0, 0, PDC_UDMA_133 },
-       { PCI_VENDOR_ID_PROMISE, PCI_DEVICE_ID_PROMISE_20275, PCI_ANY_ID, PCI_ANY_ID, 0, 0, PDC_UDMA_133 },
-       { PCI_VENDOR_ID_PROMISE, PCI_DEVICE_ID_PROMISE_20276, PCI_ANY_ID, PCI_ANY_ID, 0, 0, PDC_UDMA_133 },
-       { PCI_VENDOR_ID_PROMISE, PCI_DEVICE_ID_PROMISE_20277, PCI_ANY_ID, PCI_ANY_ID, 0, 0, PDC_UDMA_133 },
+       { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20268), PDC_UDMA_100 },
+       { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20269), PDC_UDMA_133 },
+       { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20270), PDC_UDMA_100 },
+       { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20271), PDC_UDMA_133 },
+       { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20275), PDC_UDMA_133 },
+       { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20276), PDC_UDMA_133 },
+       { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20277), PDC_UDMA_133 },
+
        { }     /* terminate list */
 };
 
@@ -122,7 +121,7 @@ static struct pci_driver pdc2027x_pci_driver = {
        .name                   = DRV_NAME,
        .id_table               = pdc2027x_pci_tbl,
        .probe                  = pdc2027x_init_one,
-       .remove                 = __devexit_p(pdc2027x_remove_one),
+       .remove                 = ata_pci_remove_one,
 };
 
 static struct scsi_host_template pdc2027x_sht = {
@@ -133,13 +132,13 @@ static struct scsi_host_template pdc2027x_sht = {
        .can_queue              = ATA_DEF_QUEUE,
        .this_id                = ATA_SHT_THIS_ID,
        .sg_tablesize           = LIBATA_MAX_PRD,
-       .max_sectors            = ATA_MAX_SECTORS,
        .cmd_per_lun            = ATA_SHT_CMD_PER_LUN,
        .emulated               = ATA_SHT_EMULATED,
        .use_clustering         = ATA_SHT_USE_CLUSTERING,
        .proc_name              = DRV_NAME,
        .dma_boundary           = ATA_DMA_BOUNDARY,
        .slave_configure        = ata_scsi_slave_config,
+       .slave_destroy          = ata_scsi_slave_destroy,
        .bios_param             = ata_std_bios_param,
 };
 
@@ -170,8 +169,6 @@ static struct ata_port_operations pdc2027x_pata100_ops = {
        .irq_clear              = ata_bmdma_irq_clear,
 
        .port_start             = ata_port_start,
-       .port_stop              = ata_port_stop,
-       .host_stop              = ata_pci_host_stop,
 };
 
 static struct ata_port_operations pdc2027x_pata133_ops = {
@@ -204,8 +201,6 @@ static struct ata_port_operations pdc2027x_pata133_ops = {
        .irq_clear              = ata_bmdma_irq_clear,
 
        .port_start             = ata_port_start,
-       .port_stop              = ata_port_stop,
-       .host_stop              = ata_pci_host_stop,
 };
 
 static struct ata_port_info pdc2027x_port_info[] = {
@@ -242,7 +237,7 @@ MODULE_DEVICE_TABLE(pci, pdc2027x_pci_tbl);
  *     @ap: Port
  *     @offset: offset from mmio base
  */
-static inline voidport_mmio(struct ata_port *ap, unsigned int offset)
+static inline void __iomem *port_mmio(struct ata_port *ap, unsigned int offset)
 {
        return ap->host->mmio_base + ap->port_no * 0x100 + offset;
 }
@@ -253,7 +248,7 @@ static inline void* port_mmio(struct ata_port *ap, unsigned int offset)
  *     @adev: device
  *     @offset: offset from mmio base
  */
-static inline voiddev_mmio(struct ata_port *ap, struct ata_device *adev, unsigned int offset)
+static inline void __iomem *dev_mmio(struct ata_port *ap, struct ata_device *adev, unsigned int offset)
 {
        u8 adj = (adev->devno) ? 0x08 : 0x00;
        return port_mmio(ap, offset) + adj;
@@ -311,10 +306,8 @@ static inline int pdc2027x_port_enabled(struct ata_port *ap)
 static int pdc2027x_prereset(struct ata_port *ap)
 {
        /* Check whether port enabled */
-       if (!pdc2027x_port_enabled(ap)) {
-               printk(KERN_INFO "ata%u: port disabled. ignoring.\n", ap->id);
-               return 0;
-       }
+       if (!pdc2027x_port_enabled(ap))
+               return -ENOENT;
        pdc2027x_cbl_detect(ap);
        return ata_std_prereset(ap);
 }
@@ -756,45 +749,41 @@ static int __devinit pdc2027x_init_one(struct pci_dev *pdev, const struct pci_de
        static int printed_version;
        unsigned int board_idx = (unsigned int) ent->driver_data;
 
-       struct ata_probe_ent *probe_ent = NULL;
+       struct ata_probe_ent *probe_ent;
        unsigned long base;
-       void *mmio_base;
+       void __iomem *mmio_base;
        int rc;
 
        if (!printed_version++)
                dev_printk(KERN_DEBUG, &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)
-               goto err_out;
+               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;
 
        /* Prepare the probe entry */
-       probe_ent = kzalloc(sizeof(*probe_ent), GFP_KERNEL);
-       if (probe_ent == NULL) {
-               rc = -ENOMEM;
-               goto err_out_regions;
-       }
+       probe_ent = devm_kzalloc(&pdev->dev, sizeof(*probe_ent), GFP_KERNEL);
+       if (probe_ent == NULL)
+               return -ENOMEM;
 
        probe_ent->dev = pci_dev_to_dev(pdev);
        INIT_LIST_HEAD(&probe_ent->node);
 
-       mmio_base = pci_iomap(pdev, 5, 0);
-       if (!mmio_base) {
-               rc = -ENOMEM;
-               goto err_out_free_ent;
-       }
+       mmio_base = pcim_iomap(pdev, 5, 0);
+       if (!mmio_base)
+               return -ENOMEM;
 
        base = (unsigned long) mmio_base;
 
@@ -821,32 +810,13 @@ static int __devinit pdc2027x_init_one(struct pci_dev *pdev, const struct pci_de
 
        /* initialize adapter */
        if (pdc_hardware_init(pdev, probe_ent, board_idx) != 0)
-               goto err_out_free_ent;
+               return -EIO;
 
-       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_free_ent:
-       kfree(probe_ent);
-err_out_regions:
-       pci_release_regions(pdev);
-err_out:
-       pci_disable_device(pdev);
-       return rc;
-}
-
-/**
- * pdc2027x_remove_one - Called to remove a single instance of the
- * adapter.
- *
- * @dev: The PCI device to remove.
- * FIXME: module load/unload not working yet
- */
-static void __devexit pdc2027x_remove_one(struct pci_dev *pdev)
-{
-       ata_pci_remove_one(pdev);
 }
 
 /**
@@ -854,7 +824,7 @@ static void __devexit pdc2027x_remove_one(struct pci_dev *pdev)
  */
 static int __init pdc2027x_init(void)
 {
-       return pci_module_init(&pdc2027x_pci_driver);
+       return pci_register_driver(&pdc2027x_pci_driver);
 }
 
 /**