ide: keep pointer to struct device instead of struct pci_dev in ide_hwif_t
[deliverable/linux.git] / drivers / ide / pci / sgiioc4.c
index de820aa58cd0e47057b9a8028d9fd3b8c1bfe515..85902074b1fc03e7751d9d66ee409603de618f2e 100644 (file)
@@ -159,6 +159,7 @@ sgiioc4_clearirq(ide_drive_t * drive)
                }
 
                if (intr_reg & 0x02) {
+                       struct pci_dev *dev = to_pci_dev(hwif->dev);
                        /* Error when transferring DMA data on PCI bus */
                        u32 pci_err_addr_low, pci_err_addr_high,
                            pci_stat_cmd_reg;
@@ -167,7 +168,7 @@ sgiioc4_clearirq(ide_drive_t * drive)
                                readl((void __iomem *)hwif->io_ports[IDE_IRQ_OFFSET]);
                        pci_err_addr_high =
                                readl((void __iomem *)(hwif->io_ports[IDE_IRQ_OFFSET] + 4));
-                       pci_read_config_dword(hwif->pci_dev, PCI_COMMAND,
+                       pci_read_config_dword(dev, PCI_COMMAND,
                                              &pci_stat_cmd_reg);
                        printk(KERN_ERR
                               "%s(%s) : PCI Bus Error when doing DMA:"
@@ -178,8 +179,7 @@ sgiioc4_clearirq(ide_drive_t * drive)
                               __FUNCTION__, drive->name,
                               pci_err_addr_high, pci_err_addr_low);
                        /* Clear the PCI Error indicator */
-                       pci_write_config_dword(hwif->pci_dev, PCI_COMMAND,
-                                              0x00000146);
+                       pci_write_config_dword(dev, PCI_COMMAND, 0x00000146);
                }
 
                /* Clear the Interrupt, Error bits on the IOC4 */
@@ -277,21 +277,6 @@ sgiioc4_ide_dma_end(ide_drive_t * drive)
        return dma_stat;
 }
 
-static int
-sgiioc4_ide_dma_on(ide_drive_t * drive)
-{
-       drive->using_dma = 1;
-
-       return 0;
-}
-
-static void sgiioc4_dma_off_quietly(ide_drive_t *drive)
-{
-       drive->using_dma = 0;
-
-       drive->hwif->dma_host_off(drive);
-}
-
 static void sgiioc4_set_dma_mode(ide_drive_t *drive, const u8 speed)
 {
 }
@@ -303,13 +288,10 @@ sgiioc4_ide_dma_test_irq(ide_drive_t * drive)
        return sgiioc4_checkirq(HWIF(drive));
 }
 
-static void sgiioc4_dma_host_on(ide_drive_t * drive)
-{
-}
-
-static void sgiioc4_dma_host_off(ide_drive_t * drive)
+static void sgiioc4_dma_host_set(ide_drive_t *drive, int on)
 {
-       sgiioc4_clearirq(drive);
+       if (!on)
+               sgiioc4_clearirq(drive);
 }
 
 static void
@@ -352,6 +334,7 @@ sgiioc4_INB(unsigned long port)
 static int __devinit
 ide_dma_sgiioc4(ide_hwif_t * hwif, unsigned long dma_base)
 {
+       struct pci_dev *dev = to_pci_dev(hwif->dev);
        void __iomem *virt_dma_base;
        int num_ports = sizeof (ioc4_dma_regs_t);
        void *pad;
@@ -377,7 +360,7 @@ ide_dma_sgiioc4(ide_hwif_t * hwif, unsigned long dma_base)
        }
        hwif->dma_base = (unsigned long) virt_dma_base;
 
-       hwif->dmatable_cpu = pci_alloc_consistent(hwif->pci_dev,
+       hwif->dmatable_cpu = pci_alloc_consistent(dev,
                                          IOC4_PRD_ENTRIES * IOC4_PRD_BYTES,
                                          &hwif->dmatable_dma);
 
@@ -386,7 +369,7 @@ ide_dma_sgiioc4(ide_hwif_t * hwif, unsigned long dma_base)
 
        hwif->sg_max_nents = IOC4_PRD_ENTRIES;
 
-       pad = pci_alloc_consistent(hwif->pci_dev, IOC4_IDE_CACHELINE_SIZE,
+       pad = pci_alloc_consistent(dev, IOC4_IDE_CACHELINE_SIZE,
                                   (dma_addr_t *) &(hwif->dma_status));
 
        if (pad) {
@@ -394,8 +377,7 @@ ide_dma_sgiioc4(ide_hwif_t * hwif, unsigned long dma_base)
                return 0;
        }
 
-       pci_free_consistent(hwif->pci_dev,
-                           IOC4_PRD_ENTRIES * IOC4_PRD_BYTES,
+       pci_free_consistent(dev, IOC4_PRD_ENTRIES * IOC4_PRD_BYTES,
                            hwif->dmatable_cpu, hwif->dmatable_dma);
        printk(KERN_INFO
               "%s() -- Error! Unable to allocate DMA Maps for drive %s\n",
@@ -535,8 +517,7 @@ sgiioc4_build_dma_table(ide_drive_t * drive, struct request *rq, int ddir)
        }
 
 use_pio_instead:
-       pci_unmap_sg(hwif->pci_dev, hwif->sg_table, hwif->sg_nents,
-                    hwif->sg_dma_direction);
+       ide_destroy_dmatable(drive);
 
        return 0;               /* revert to PIO for this request */
 }
@@ -582,7 +563,6 @@ ide_init_sgiioc4(ide_hwif_t * hwif)
        hwif->pre_reset = NULL; /* No HBA specific pre_set needed */
        hwif->resetproc = &sgiioc4_resetproc;/* Reset DMA engine,
                                                clear interrupts */
-       hwif->intrproc = NULL;  /* Enable or Disable interrupt from drive */
        hwif->maskproc = &sgiioc4_maskproc;     /* Mask on/off NIEN register */
        hwif->quirkproc = NULL;
        hwif->busproc = NULL;
@@ -594,14 +574,11 @@ ide_init_sgiioc4(ide_hwif_t * hwif)
 
        hwif->mwdma_mask = ATA_MWDMA2_ONLY;
 
+       hwif->dma_host_set = &sgiioc4_dma_host_set;
        hwif->dma_setup = &sgiioc4_ide_dma_setup;
        hwif->dma_start = &sgiioc4_ide_dma_start;
        hwif->ide_dma_end = &sgiioc4_ide_dma_end;
-       hwif->ide_dma_on = &sgiioc4_ide_dma_on;
-       hwif->dma_off_quietly = &sgiioc4_dma_off_quietly;
        hwif->ide_dma_test_irq = &sgiioc4_ide_dma_test_irq;
-       hwif->dma_host_on = &sgiioc4_dma_host_on;
-       hwif->dma_host_off = &sgiioc4_dma_host_off;
        hwif->dma_lost_irq = &sgiioc4_dma_lost_irq;
        hwif->dma_timeout = &ide_dma_timeout;
 }
@@ -615,6 +592,7 @@ sgiioc4_ide_setup_pci_device(struct pci_dev *dev)
        ide_hwif_t *hwif;
        int h;
        u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
+       hw_regs_t hw;
 
        /*
         * Find an empty HWIF; if none available, return -ENOMEM.
@@ -654,21 +632,16 @@ sgiioc4_ide_setup_pci_device(struct pci_dev *dev)
                return -ENOMEM;
        }
 
-       if (hwif->io_ports[IDE_DATA_OFFSET] != cmd_base) {
-               hw_regs_t hw;
-
-               /* Initialize the IO registers */
-               memset(&hw, 0, sizeof(hw));
-               sgiioc4_init_hwif_ports(&hw, cmd_base, ctl, irqport);
-               memcpy(hwif->io_ports, hw.io_ports, sizeof(hwif->io_ports));
-               hwif->noprobe = !hwif->io_ports[IDE_DATA_OFFSET];
-       }
+       /* Initialize the IO registers */
+       memset(&hw, 0, sizeof(hw));
+       sgiioc4_init_hwif_ports(&hw, cmd_base, ctl, irqport);
+       hw.irq = dev->irq;
+       hw.chipset = ide_pci;
+       hw.dev = &dev->dev;
+       ide_init_port_hw(hwif, &hw);
 
-       hwif->irq = dev->irq;
-       hwif->chipset = ide_pci;
-       hwif->pci_dev = dev;
+       hwif->dev = &dev->dev;
        hwif->channel = 0;      /* Single Channel chip */
-       hwif->gendev.parent = &dev->dev;/* setup proper ancestral information */
 
        /* The IOC4 uses MMIO rather than Port IO. */
        default_hwif_mmiops(hwif);
This page took 0.036266 seconds and 5 git commands to generate.