]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/ata/sata_sx4.c
Merge rsync://rsync.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
[linux-2.6-omap-h63xx.git] / drivers / ata / sata_sx4.c
index 0da83cba5c1244aaa2f20c3b8b0b7a2882f2136d..06e87a37738239d7b8b427673cf1ac005fa00f27 100644 (file)
@@ -42,7 +42,6 @@
 #include <scsi/scsi_host.h>
 #include <scsi/scsi_cmnd.h>
 #include <linux/libata.h>
-#include <asm/io.h>
 #include "sata_promise.h"
 
 #define DRV_NAME       "sata_sx4"
@@ -50,6 +49,9 @@
 
 
 enum {
+       PDC_MMIO_BAR            = 3,
+       PDC_DIMM_BAR            = 4,
+
        PDC_PRD_TBL             = 0x44, /* Direct command DMA table addr */
 
        PDC_PKT_SUBMIT          = 0x40, /* Command packet pointer addr */
@@ -138,8 +140,6 @@ struct pdc_port_priv {
 };
 
 struct pdc_host_priv {
-       void                    __iomem *dimm_mmio;
-
        unsigned int            doing_hdma;
        unsigned int            hdma_prod;
        unsigned int            hdma_cons;
@@ -152,15 +152,13 @@ struct pdc_host_priv {
 
 
 static int pdc_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *ent);
-static irqreturn_t pdc20621_interrupt (int irq, void *dev_instance, struct pt_regs *regs);
+static irqreturn_t pdc20621_interrupt (int irq, void *dev_instance);
 static void pdc_eng_timeout(struct ata_port *ap);
 static void pdc_20621_phy_reset (struct ata_port *ap);
 static int pdc_port_start(struct ata_port *ap);
-static void pdc_port_stop(struct ata_port *ap);
 static void pdc20621_qc_prep(struct ata_queued_cmd *qc);
 static void pdc_tf_load_mmio(struct ata_port *ap, const struct ata_taskfile *tf);
 static void pdc_exec_command_mmio(struct ata_port *ap, const struct ata_taskfile *tf);
-static void pdc20621_host_stop(struct ata_host_set *host_set);
 static unsigned int pdc20621_dimm_init(struct ata_probe_ent *pe);
 static int pdc20621_detect_dimm(struct ata_probe_ent *pe);
 static unsigned int pdc20621_i2c_read(struct ata_probe_ent *pe,
@@ -205,20 +203,20 @@ static const struct ata_port_operations pdc_20621_ops = {
        .phy_reset              = pdc_20621_phy_reset,
        .qc_prep                = pdc20621_qc_prep,
        .qc_issue               = pdc20621_qc_issue_prot,
-       .data_xfer              = ata_mmio_data_xfer,
+       .data_xfer              = ata_data_xfer,
        .eng_timeout            = pdc_eng_timeout,
        .irq_handler            = pdc20621_interrupt,
        .irq_clear              = pdc20621_irq_clear,
+       .irq_on                 = ata_irq_on,
+       .irq_ack                = ata_irq_ack,
        .port_start             = pdc_port_start,
-       .port_stop              = pdc_port_stop,
-       .host_stop              = pdc20621_host_stop,
 };
 
 static const struct ata_port_info pdc_port_info[] = {
        /* board_20621 */
        {
                .sht            = &pdc_sata_sht,
-               .host_flags     = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
+               .flags          = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
                                  ATA_FLAG_SRST | ATA_FLAG_MMIO |
                                  ATA_FLAG_NO_ATAPI | ATA_FLAG_PIO_POLLING,
                .pio_mask       = 0x1f, /* pio0-4 */
@@ -230,12 +228,11 @@ static const struct ata_port_info pdc_port_info[] = {
 };
 
 static const struct pci_device_id pdc_sata_pci_tbl[] = {
-       { PCI_VENDOR_ID_PROMISE, 0x6622, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
-         board_20621 },
+       { PCI_VDEVICE(PROMISE, 0x6622), board_20621 },
+
        { }     /* terminate list */
 };
 
-
 static struct pci_driver pdc_sata_pci_driver = {
        .name                   = DRV_NAME,
        .id_table               = pdc_sata_pci_tbl,
@@ -244,21 +241,9 @@ static struct pci_driver pdc_sata_pci_driver = {
 };
 
 
-static void pdc20621_host_stop(struct ata_host_set *host_set)
-{
-       struct pci_dev *pdev = to_pci_dev(host_set->dev);
-       struct pdc_host_priv *hpriv = host_set->private_data;
-       void __iomem *dimm_mmio = hpriv->dimm_mmio;
-
-       pci_iounmap(pdev, dimm_mmio);
-       kfree(hpriv);
-
-       pci_iounmap(pdev, host_set->mmio_base);
-}
-
 static int pdc_port_start(struct ata_port *ap)
 {
-       struct device *dev = ap->host_set->dev;
+       struct device *dev = ap->host->dev;
        struct pdc_port_priv *pp;
        int rc;
 
@@ -266,43 +251,19 @@ static int pdc_port_start(struct ata_port *ap)
        if (rc)
                return rc;
 
-       pp = kmalloc(sizeof(*pp), GFP_KERNEL);
-       if (!pp) {
-               rc = -ENOMEM;
-               goto err_out;
-       }
-       memset(pp, 0, sizeof(*pp));
+       pp = devm_kzalloc(dev, sizeof(*pp), GFP_KERNEL);
+       if (!pp)
+               return -ENOMEM;
 
-       pp->pkt = dma_alloc_coherent(dev, 128, &pp->pkt_dma, GFP_KERNEL);
-       if (!pp->pkt) {
-               rc = -ENOMEM;
-               goto err_out_kfree;
-       }
+       pp->pkt = dmam_alloc_coherent(dev, 128, &pp->pkt_dma, GFP_KERNEL);
+       if (!pp->pkt)
+               return -ENOMEM;
 
        ap->private_data = pp;
 
        return 0;
-
-err_out_kfree:
-       kfree(pp);
-err_out:
-       ata_port_stop(ap);
-       return rc;
-}
-
-
-static void pdc_port_stop(struct ata_port *ap)
-{
-       struct device *dev = ap->host_set->dev;
-       struct pdc_port_priv *pp = ap->private_data;
-
-       ap->private_data = NULL;
-       dma_free_coherent(dev, 128, pp->pkt, pp->pkt_dma);
-       kfree(pp);
-       ata_port_stop(ap);
 }
 
-
 static void pdc_20621_phy_reset (struct ata_port *ap)
 {
        VPRINTK("ENTER\n");
@@ -453,9 +414,8 @@ static void pdc20621_dma_prep(struct ata_queued_cmd *qc)
        struct scatterlist *sg;
        struct ata_port *ap = qc->ap;
        struct pdc_port_priv *pp = ap->private_data;
-       void __iomem *mmio = ap->host_set->mmio_base;
-       struct pdc_host_priv *hpriv = ap->host_set->private_data;
-       void __iomem *dimm_mmio = hpriv->dimm_mmio;
+       void __iomem *mmio = ap->host->iomap[PDC_MMIO_BAR];
+       void __iomem *dimm_mmio = ap->host->iomap[PDC_DIMM_BAR];
        unsigned int portno = ap->port_no;
        unsigned int i, idx, total_len = 0, sgt_len;
        u32 *buf = (u32 *) &pp->dimm_buf[PDC_DIMM_HEADER_SZ];
@@ -514,9 +474,8 @@ static void pdc20621_nodata_prep(struct ata_queued_cmd *qc)
 {
        struct ata_port *ap = qc->ap;
        struct pdc_port_priv *pp = ap->private_data;
-       void __iomem *mmio = ap->host_set->mmio_base;
-       struct pdc_host_priv *hpriv = ap->host_set->private_data;
-       void __iomem *dimm_mmio = hpriv->dimm_mmio;
+       void __iomem *mmio = ap->host->iomap[PDC_MMIO_BAR];
+       void __iomem *dimm_mmio = ap->host->iomap[PDC_DIMM_BAR];
        unsigned int portno = ap->port_no;
        unsigned int i;
 
@@ -565,8 +524,8 @@ static void __pdc20621_push_hdma(struct ata_queued_cmd *qc,
                                 u32 pkt_ofs)
 {
        struct ata_port *ap = qc->ap;
-       struct ata_host_set *host_set = ap->host_set;
-       void __iomem *mmio = host_set->mmio_base;
+       struct ata_host *host = ap->host;
+       void __iomem *mmio = host->iomap[PDC_MMIO_BAR];
 
        /* hard-code chip #0 */
        mmio += PDC_CHIP0_OFS;
@@ -583,7 +542,7 @@ static void pdc20621_push_hdma(struct ata_queued_cmd *qc,
                                u32 pkt_ofs)
 {
        struct ata_port *ap = qc->ap;
-       struct pdc_host_priv *pp = ap->host_set->private_data;
+       struct pdc_host_priv *pp = ap->host->private_data;
        unsigned int idx = pp->hdma_prod & PDC_HDMA_Q_MASK;
 
        if (!pp->doing_hdma) {
@@ -601,7 +560,7 @@ static void pdc20621_push_hdma(struct ata_queued_cmd *qc,
 static void pdc20621_pop_hdma(struct ata_queued_cmd *qc)
 {
        struct ata_port *ap = qc->ap;
-       struct pdc_host_priv *pp = ap->host_set->private_data;
+       struct pdc_host_priv *pp = ap->host->private_data;
        unsigned int idx = pp->hdma_cons & PDC_HDMA_Q_MASK;
 
        /* if nothing on queue, we're done */
@@ -620,8 +579,7 @@ static void pdc20621_dump_hdma(struct ata_queued_cmd *qc)
 {
        struct ata_port *ap = qc->ap;
        unsigned int port_no = ap->port_no;
-       struct pdc_host_priv *hpriv = ap->host_set->private_data;
-       void *dimm_mmio = hpriv->dimm_mmio;
+       void __iomem *dimm_mmio = ap->host->iomap[PDC_DIMM_BAR];
 
        dimm_mmio += (port_no * PDC_DIMM_WINDOW_STEP);
        dimm_mmio += PDC_DIMM_HOST_PKT;
@@ -638,9 +596,9 @@ static inline void pdc20621_dump_hdma(struct ata_queued_cmd *qc) { }
 static void pdc20621_packet_start(struct ata_queued_cmd *qc)
 {
        struct ata_port *ap = qc->ap;
-       struct ata_host_set *host_set = ap->host_set;
+       struct ata_host *host = ap->host;
        unsigned int port_no = ap->port_no;
-       void __iomem *mmio = host_set->mmio_base;
+       void __iomem *mmio = host->iomap[PDC_MMIO_BAR];
        unsigned int rw = (qc->tf.flags & ATA_TFLAG_WRITE);
        u8 seq = (u8) (port_no + 1);
        unsigned int port_ofs;
@@ -669,8 +627,8 @@ static void pdc20621_packet_start(struct ata_queued_cmd *qc)
                readl(mmio + PDC_20621_SEQCTL + (seq * 4));     /* flush */
 
                writel(port_ofs + PDC_DIMM_ATA_PKT,
-                      (void __iomem *) ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT);
-               readl((void __iomem *) ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT);
+                      ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT);
+               readl(ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT);
                VPRINTK("submitted ofs 0x%x (%u), seq %u\n",
                        port_ofs + PDC_DIMM_ATA_PKT,
                        port_ofs + PDC_DIMM_ATA_PKT,
@@ -748,8 +706,8 @@ static inline unsigned int pdc20621_host_intr( struct ata_port *ap,
                        writel(0x00000001, mmio + PDC_20621_SEQCTL + (seq * 4));
                        readl(mmio + PDC_20621_SEQCTL + (seq * 4));
                        writel(port_ofs + PDC_DIMM_ATA_PKT,
-                              (void __iomem *) ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT);
-                       readl((void __iomem *) ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT);
+                              ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT);
+                       readl(ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT);
                }
 
                /* step two - execute ATA command */
@@ -781,17 +739,17 @@ static inline unsigned int pdc20621_host_intr( struct ata_port *ap,
 
 static void pdc20621_irq_clear(struct ata_port *ap)
 {
-       struct ata_host_set *host_set = ap->host_set;
-       void __iomem *mmio = host_set->mmio_base;
+       struct ata_host *host = ap->host;
+       void __iomem *mmio = host->iomap[PDC_MMIO_BAR];
 
        mmio += PDC_CHIP0_OFS;
 
        readl(mmio + PDC_20621_SEQMASK);
 }
 
-static irqreturn_t pdc20621_interrupt (int irq, void *dev_instance, struct pt_regs *regs)
+static irqreturn_t pdc20621_interrupt (int irq, void *dev_instance)
 {
-       struct ata_host_set *host_set = dev_instance;
+       struct ata_host *host = dev_instance;
        struct ata_port *ap;
        u32 mask = 0;
        unsigned int i, tmp, port_no;
@@ -800,12 +758,12 @@ static irqreturn_t pdc20621_interrupt (int irq, void *dev_instance, struct pt_re
 
        VPRINTK("ENTER\n");
 
-       if (!host_set || !host_set->mmio_base) {
+       if (!host || !host->iomap[PDC_MMIO_BAR]) {
                VPRINTK("QUICK EXIT\n");
                return IRQ_NONE;
        }
 
-       mmio_base = host_set->mmio_base;
+       mmio_base = host->iomap[PDC_MMIO_BAR];
 
        /* reading should also clear interrupts */
        mmio_base += PDC_CHIP0_OFS;
@@ -822,16 +780,16 @@ static irqreturn_t pdc20621_interrupt (int irq, void *dev_instance, struct pt_re
                return IRQ_NONE;
        }
 
-        spin_lock(&host_set->lock);
+        spin_lock(&host->lock);
 
         for (i = 1; i < 9; i++) {
                port_no = i - 1;
                if (port_no > 3)
                        port_no -= 4;
-               if (port_no >= host_set->n_ports)
+               if (port_no >= host->n_ports)
                        ap = NULL;
                else
-                       ap = host_set->ports[port_no];
+                       ap = host->ports[port_no];
                tmp = mask & (1 << i);
                VPRINTK("seq %u, port_no %u, ap %p, tmp %x\n", i, port_no, ap, tmp);
                if (tmp && ap &&
@@ -845,7 +803,7 @@ static irqreturn_t pdc20621_interrupt (int irq, void *dev_instance, struct pt_re
                }
        }
 
-        spin_unlock(&host_set->lock);
+        spin_unlock(&host->lock);
 
        VPRINTK("mask == 0x%x\n", mask);
 
@@ -857,13 +815,13 @@ static irqreturn_t pdc20621_interrupt (int irq, void *dev_instance, struct pt_re
 static void pdc_eng_timeout(struct ata_port *ap)
 {
        u8 drv_stat;
-       struct ata_host_set *host_set = ap->host_set;
+       struct ata_host *host = ap->host;
        struct ata_queued_cmd *qc;
        unsigned long flags;
 
        DPRINTK("ENTER\n");
 
-       spin_lock_irqsave(&host_set->lock, flags);
+       spin_lock_irqsave(&host->lock, flags);
 
        qc = ata_qc_from_tag(ap, ap->active_tag);
 
@@ -885,7 +843,7 @@ static void pdc_eng_timeout(struct ata_port *ap)
                break;
        }
 
-       spin_unlock_irqrestore(&host_set->lock, flags);
+       spin_unlock_irqrestore(&host->lock, flags);
        ata_eh_qc_complete(qc);
        DPRINTK("EXIT\n");
 }
@@ -906,7 +864,7 @@ static void pdc_exec_command_mmio(struct ata_port *ap, const struct ata_taskfile
 }
 
 
-static void pdc_sata_setup_port(struct ata_ioports *port, unsigned long base)
+static void pdc_sata_setup_port(struct ata_ioports *port, void __iomem *base)
 {
        port->cmd_addr          = base;
        port->data_addr         = base;
@@ -932,9 +890,8 @@ static void pdc20621_get_from_dimm(struct ata_probe_ent *pe, void *psource,
        u16 idx;
        u8 page_mask;
        long dist;
-       void __iomem *mmio = pe->mmio_base;
-       struct pdc_host_priv *hpriv = pe->private_data;
-       void __iomem *dimm_mmio = hpriv->dimm_mmio;
+       void __iomem *mmio = pe->iomap[PDC_MMIO_BAR];
+       void __iomem *dimm_mmio = pe->iomap[PDC_DIMM_BAR];
 
        /* hard-code chip #0 */
        mmio += PDC_CHIP0_OFS;
@@ -988,9 +945,8 @@ static void pdc20621_put_to_dimm(struct ata_probe_ent *pe, void *psource,
        u16 idx;
        u8 page_mask;
        long dist;
-       void __iomem *mmio = pe->mmio_base;
-       struct pdc_host_priv *hpriv = pe->private_data;
-       void __iomem *dimm_mmio = hpriv->dimm_mmio;
+       void __iomem *mmio = pe->iomap[PDC_MMIO_BAR];
+       void __iomem *dimm_mmio = pe->iomap[PDC_DIMM_BAR];
 
        /* hard-code chip #0 */
        mmio += PDC_CHIP0_OFS;
@@ -1035,7 +991,7 @@ static void pdc20621_put_to_dimm(struct ata_probe_ent *pe, void *psource,
 static unsigned int pdc20621_i2c_read(struct ata_probe_ent *pe, u32 device,
                                      u32 subaddr, u32 *pdata)
 {
-       void __iomem *mmio = pe->mmio_base;
+       void __iomem *mmio = pe->iomap[PDC_MMIO_BAR];
        u32 i2creg  = 0;
        u32 status;
        u32 count =0;
@@ -1094,7 +1050,7 @@ static int pdc20621_prog_dimm0(struct ata_probe_ent *pe)
        u32 data = 0;
        int size, i;
        u8 bdimmsize;
-       void __iomem *mmio = pe->mmio_base;
+       void __iomem *mmio = pe->iomap[PDC_MMIO_BAR];
        static const struct {
                unsigned int reg;
                unsigned int ofs;
@@ -1156,8 +1112,8 @@ static int pdc20621_prog_dimm0(struct ata_probe_ent *pe)
 static unsigned int pdc20621_prog_dimm_global(struct ata_probe_ent *pe)
 {
        u32 data, spd0;
-       int error, i;
-       void __iomem *mmio = pe->mmio_base;
+       int error, i;
+       void __iomem *mmio = pe->iomap[PDC_MMIO_BAR];
 
        /* hard-code chip #0 */
        mmio += PDC_CHIP0_OFS;
@@ -1211,7 +1167,7 @@ static unsigned int pdc20621_dimm_init(struct ata_probe_ent *pe)
        u32 ticks=0;
        u32 clock=0;
        u32 fparam=0;
-       void __iomem *mmio = pe->mmio_base;
+       void __iomem *mmio = pe->iomap[PDC_MMIO_BAR];
 
        /* hard-code chip #0 */
        mmio += PDC_CHIP0_OFS;
@@ -1335,7 +1291,7 @@ static unsigned int pdc20621_dimm_init(struct ata_probe_ent *pe)
 static void pdc_20621_init(struct ata_probe_ent *pe)
 {
        u32 tmp;
-       void __iomem *mmio = pe->mmio_base;
+       void __iomem *mmio = pe->iomap[PDC_MMIO_BAR];
 
        /* hard-code chip #0 */
        mmio += PDC_CHIP0_OFS;
@@ -1366,70 +1322,46 @@ static void pdc_20621_init(struct ata_probe_ent *pe)
 static int pdc_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
 {
        static int printed_version;
-       struct ata_probe_ent *probe_ent = NULL;
-       unsigned long base;
-       void __iomem *mmio_base;
-       void __iomem *dimm_mmio = NULL;
-       struct pdc_host_priv *hpriv = NULL;
+       struct ata_probe_ent *probe_ent;
+       void __iomem *base;
+       struct pdc_host_priv *hpriv;
        unsigned int board_idx = (unsigned int) ent->driver_data;
-       int pci_dev_busy = 0;
        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) {
-               pci_dev_busy = 1;
-               goto err_out;
-       }
+       rc = pcim_iomap_regions(pdev, (1 << PDC_MMIO_BAR) | (1 << PDC_DIMM_BAR),
+                               DRV_NAME);
+       if (rc == -EBUSY)
+               pcim_pin_device(pdev);
+       if (rc)
+               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;
 
-       probe_ent = kmalloc(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;
 
-       memset(probe_ent, 0, sizeof(*probe_ent));
        probe_ent->dev = pci_dev_to_dev(pdev);
        INIT_LIST_HEAD(&probe_ent->node);
 
-       mmio_base = pci_iomap(pdev, 3, 0);
-       if (mmio_base == NULL) {
-               rc = -ENOMEM;
-               goto err_out_free_ent;
-       }
-       base = (unsigned long) mmio_base;
-
-       hpriv = kmalloc(sizeof(*hpriv), GFP_KERNEL);
-       if (!hpriv) {
-               rc = -ENOMEM;
-               goto err_out_iounmap;
-       }
-       memset(hpriv, 0, sizeof(*hpriv));
-
-       dimm_mmio = pci_iomap(pdev, 4, 0);
-       if (!dimm_mmio) {
-               kfree(hpriv);
-               rc = -ENOMEM;
-               goto err_out_iounmap;
-       }
-
-       hpriv->dimm_mmio = dimm_mmio;
+       hpriv = devm_kzalloc(&pdev->dev, sizeof(*hpriv), GFP_KERNEL);
+       if (!hpriv)
+               return -ENOMEM;
 
        probe_ent->sht          = pdc_port_info[board_idx].sht;
-       probe_ent->host_flags   = pdc_port_info[board_idx].host_flags;
+       probe_ent->port_flags   = pdc_port_info[board_idx].flags;
        probe_ent->pio_mask     = pdc_port_info[board_idx].pio_mask;
        probe_ent->mwdma_mask   = pdc_port_info[board_idx].mwdma_mask;
        probe_ent->udma_mask    = pdc_port_info[board_idx].udma_mask;
@@ -1437,10 +1369,10 @@ static int pdc_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *
 
                probe_ent->irq = pdev->irq;
                probe_ent->irq_flags = IRQF_SHARED;
-       probe_ent->mmio_base = mmio_base;
+       probe_ent->iomap = pcim_iomap_table(pdev);
 
        probe_ent->private_data = hpriv;
-       base += PDC_CHIP0_OFS;
+       base = probe_ent->iomap[PDC_MMIO_BAR] + PDC_CHIP0_OFS;
 
        probe_ent->n_ports = 4;
        pdc_sata_setup_port(&probe_ent->port[0], base + 0x200);
@@ -1452,31 +1384,15 @@ static int pdc_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *
 
        /* initialize adapter */
        /* initialize local dimm */
-       if (pdc20621_dimm_init(probe_ent)) {
-               rc = -ENOMEM;
-               goto err_out_iounmap_dimm;
-       }
+       if (pdc20621_dimm_init(probe_ent))
+               return -ENOMEM;
        pdc_20621_init(probe_ent);
 
-       /* 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_iounmap_dimm:          /* only get to this label if 20621 */
-       kfree(hpriv);
-       pci_iounmap(pdev, dimm_mmio);
-err_out_iounmap:
-       pci_iounmap(pdev, mmio_base);
-err_out_free_ent:
-       kfree(probe_ent);
-err_out_regions:
-       pci_release_regions(pdev);
-err_out:
-       if (!pci_dev_busy)
-               pci_disable_device(pdev);
-       return rc;
 }