ide: keep pointer to struct device instead of struct pci_dev in ide_hwif_t
[deliverable/linux.git] / drivers / ide / ide-dma.c
index 51c86bc241ac710fa0e0005ab33a3494f0ac609a..782e5da015782029a272dae16ad83ae4d21c30cb 100644 (file)
@@ -184,10 +184,9 @@ static int ide_dma_good_drive(ide_drive_t *drive)
 int ide_build_sglist(ide_drive_t *drive, struct request *rq)
 {
        ide_hwif_t *hwif = HWIF(drive);
+       struct pci_dev *pdev = to_pci_dev(hwif->dev);
        struct scatterlist *sg = hwif->sg_table;
 
-       BUG_ON((rq->cmd_type == REQ_TYPE_ATA_TASKFILE) && rq->nr_sectors > 256);
-
        ide_map_sg(drive, rq);
 
        if (rq_data_dir(rq) == READ)
@@ -195,7 +194,7 @@ int ide_build_sglist(ide_drive_t *drive, struct request *rq)
        else
                hwif->sg_dma_direction = PCI_DMA_TODEVICE;
 
-       return pci_map_sg(hwif->pci_dev, sg, hwif->sg_nents, hwif->sg_dma_direction);
+       return pci_map_sg(pdev, sg, hwif->sg_nents, hwif->sg_dma_direction);
 }
 
 EXPORT_SYMBOL_GPL(ide_build_sglist);
@@ -284,12 +283,12 @@ int ide_build_dmatable (ide_drive_t *drive, struct request *rq)
                        *--table |= cpu_to_le32(0x80000000);
                return count;
        }
+
        printk(KERN_ERR "%s: empty DMA table?\n", drive->name);
+
 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 */
 }
 
@@ -308,11 +307,11 @@ EXPORT_SYMBOL_GPL(ide_build_dmatable);
  
 void ide_destroy_dmatable (ide_drive_t *drive)
 {
-       struct pci_dev *dev = HWIF(drive)->pci_dev;
-       struct scatterlist *sg = HWIF(drive)->sg_table;
-       int nents = HWIF(drive)->sg_nents;
+       ide_hwif_t *hwif = drive->hwif;
+       struct pci_dev *pdev = to_pci_dev(hwif->dev);
 
-       pci_unmap_sg(dev, sg, nents, HWIF(drive)->sg_dma_direction);
+       pci_unmap_sg(pdev, hwif->sg_table, hwif->sg_nents,
+                    hwif->sg_dma_direction);
 }
 
 EXPORT_SYMBOL_GPL(ide_destroy_dmatable);
@@ -845,10 +844,10 @@ EXPORT_SYMBOL(ide_dma_timeout);
 static void ide_release_dma_engine(ide_hwif_t *hwif)
 {
        if (hwif->dmatable_cpu) {
-               pci_free_consistent(hwif->pci_dev,
-                                   PRD_ENTRIES * PRD_BYTES,
-                                   hwif->dmatable_cpu,
-                                   hwif->dmatable_dma);
+               struct pci_dev *pdev = to_pci_dev(hwif->dev);
+
+               pci_free_consistent(pdev, PRD_ENTRIES * PRD_BYTES,
+                                   hwif->dmatable_cpu, hwif->dmatable_dma);
                hwif->dmatable_cpu = NULL;
        }
 }
@@ -876,7 +875,9 @@ int ide_release_dma(ide_hwif_t *hwif)
 
 static int ide_allocate_dma_engine(ide_hwif_t *hwif)
 {
-       hwif->dmatable_cpu = pci_alloc_consistent(hwif->pci_dev,
+       struct pci_dev *pdev = to_pci_dev(hwif->dev);
+
+       hwif->dmatable_cpu = pci_alloc_consistent(pdev,
                                                  PRD_ENTRIES * PRD_BYTES,
                                                  &hwif->dmatable_dma);
 
This page took 0.049409 seconds and 5 git commands to generate.