Merge branch 'bugzilla-11715' into test
[sfrench/cifs-2.6.git] / drivers / ide / pci / sgiioc4.c
index 84cd986810cf187f2917152bdcc584b1219d4101..8af9b23499fdd59d481e1dc03d0d9c44a2525606 100644 (file)
@@ -101,18 +101,8 @@ sgiioc4_init_hwif_ports(hw_regs_t * hw, unsigned long data_port,
        for (i = 0; i <= 7; i++)
                hw->io_ports_array[i] = reg + i * 4;
 
-       if (ctrl_port)
-               hw->io_ports.ctl_addr = ctrl_port;
-
-       if (irq_port)
-               hw->io_ports.irq_addr = irq_port;
-}
-
-static void
-sgiioc4_maskproc(ide_drive_t * drive, int mask)
-{
-       writeb(ATA_DEVCTL_OBS | (mask ? 2 : 0),
-              (void __iomem *)drive->hwif->io_ports.ctl_addr);
+       hw->io_ports.ctl_addr = ctrl_port;
+       hw->io_ports.irq_addr = irq_port;
 }
 
 static int
@@ -310,16 +300,14 @@ static u8 sgiioc4_read_status(ide_hwif_t *hwif)
        unsigned long port = hwif->io_ports.status_addr;
        u8 reg = (u8) readb((void __iomem *) port);
 
-       if ((port & 0xFFF) == 0x11C) {  /* Status register of IOC4 */
-               if (!(reg & ATA_BUSY)) { /* Not busy... check for interrupt */
-                       unsigned long other_ir = port - 0x110;
-                       unsigned int intr_reg = (u32) readl((void __iomem *) other_ir);
+       if (!(reg & ATA_BUSY)) {        /* Not busy... check for interrupt */
+               unsigned long other_ir = port - 0x110;
+               unsigned int intr_reg = (u32) readl((void __iomem *) other_ir);
 
-                       /* Clear the Interrupt, Error bits on the IOC4 */
-                       if (intr_reg & 0x03) {
-                               writel(0x03, (void __iomem *) other_ir);
-                               intr_reg = (u32) readl((void __iomem *) other_ir);
-                       }
+               /* Clear the Interrupt, Error bits on the IOC4 */
+               if (intr_reg & 0x03) {
+                       writel(0x03, (void __iomem *) other_ir);
+                       intr_reg = (u32) readl((void __iomem *) other_ir);
                }
        }
 
@@ -332,13 +320,9 @@ ide_dma_sgiioc4(ide_hwif_t *hwif, const struct ide_port_info *d)
 {
        struct pci_dev *dev = to_pci_dev(hwif->dev);
        unsigned long dma_base = pci_resource_start(dev, 0) + IOC4_DMA_OFFSET;
-       void __iomem *virt_dma_base;
        int num_ports = sizeof (ioc4_dma_regs_t);
        void *pad;
 
-       if (dma_base == 0)
-               return -1;
-
        printk(KERN_INFO "    %s: MMIO-DMA\n", hwif->name);
 
        if (request_mem_region(dma_base, num_ports, hwif->name) == NULL) {
@@ -348,23 +332,16 @@ ide_dma_sgiioc4(ide_hwif_t *hwif, const struct ide_port_info *d)
                return -1;
        }
 
-       virt_dma_base = ioremap(dma_base, num_ports);
-       if (virt_dma_base == NULL) {
-               printk(KERN_ERR "%s(%s) -- ERROR: unable to map addresses "
-                      "0x%lx to 0x%lx\n", __func__, hwif->name,
-                      dma_base, dma_base + num_ports - 1);
-               goto dma_remap_failure;
-       }
-       hwif->dma_base = (unsigned long) virt_dma_base;
+       hwif->dma_base = (unsigned long)hwif->io_ports.irq_addr +
+                        IOC4_DMA_OFFSET;
 
-       hwif->dmatable_cpu = pci_alloc_consistent(dev,
-                                         IOC4_PRD_ENTRIES * IOC4_PRD_BYTES,
-                                         &hwif->dmatable_dma);
+       hwif->sg_max_nents = IOC4_PRD_ENTRIES;
 
-       if (!hwif->dmatable_cpu)
-               goto dma_pci_alloc_failure;
+       hwif->prd_max_nents = IOC4_PRD_ENTRIES;
+       hwif->prd_ent_size = IOC4_PRD_BYTES;
 
-       hwif->sg_max_nents = IOC4_PRD_ENTRIES;
+       if (ide_allocate_dma_engine(hwif))
+               goto dma_pci_alloc_failure;
 
        pad = pci_alloc_consistent(dev, IOC4_IDE_CACHELINE_SIZE,
                                   (dma_addr_t *)&hwif->extra_base);
@@ -373,16 +350,13 @@ ide_dma_sgiioc4(ide_hwif_t *hwif, const struct ide_port_info *d)
                return 0;
        }
 
-       pci_free_consistent(dev, IOC4_PRD_ENTRIES * IOC4_PRD_BYTES,
-                           hwif->dmatable_cpu, hwif->dmatable_dma);
+       ide_release_dma_engine(hwif);
+
        printk(KERN_ERR "%s(%s) -- ERROR: Unable to allocate DMA maps\n",
               __func__, hwif->name);
        printk(KERN_INFO "%s: changing from DMA to PIO mode", hwif->name);
 
 dma_pci_alloc_failure:
-       iounmap(virt_dma_base);
-
-dma_remap_failure:
        release_mem_region(dma_base, num_ports);
 
        return -1;
@@ -564,8 +538,6 @@ static const struct ide_port_ops sgiioc4_port_ops = {
        .set_dma_mode           = sgiioc4_set_dma_mode,
        /* reset DMA engine, clear IRQs */
        .resetproc              = sgiioc4_resetproc,
-       /* mask on/off NIEN register */
-       .maskproc               = sgiioc4_maskproc,
 };
 
 static const struct ide_dma_ops sgiioc4_dma_ops = {