diff options
Diffstat (limited to 'drivers/ide/ppc/pmac.c')
-rw-r--r-- | drivers/ide/ppc/pmac.c | 39 |
1 files changed, 18 insertions, 21 deletions
diff --git a/drivers/ide/ppc/pmac.c b/drivers/ide/ppc/pmac.c index 736d12c8e68..23112ef68f6 100644 --- a/drivers/ide/ppc/pmac.c +++ b/drivers/ide/ppc/pmac.c @@ -1,7 +1,6 @@ /* - * linux/drivers/ide/ppc/pmac.c - * * Support for IDE interfaces on PowerMacs. + * * These IDE interfaces are memory-mapped and have a DBDMA channel * for doing DMA. * @@ -1011,7 +1010,7 @@ pmac_ide_do_resume(ide_hwif_t *hwif) * (it is kept in 2.4). This introduce an interface numbering change on some * rare machines unfortunately, but it's better this way. */ -static int +static int __devinit pmac_ide_setup_device(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif, hw_regs_t *hw) { struct device_node *np = pmif->node; @@ -1200,7 +1199,7 @@ pmac_ide_macio_attach(struct macio_dev *mdev, const struct of_device_id *match) base = ioremap(macio_resource_start(mdev, 0), 0x400); regbase = (unsigned long) base; - hwif->pci_dev = mdev->bus->pdev; + hwif->dev = &mdev->bus->pdev->dev; pmif->mdev = mdev; pmif->node = mdev->ofdev.node; @@ -1228,12 +1227,12 @@ pmac_ide_macio_attach(struct macio_dev *mdev, const struct of_device_id *match) /* The inteface is released to the common IDE layer */ dev_set_drvdata(&mdev->ofdev.dev, NULL); iounmap(base); - if (pmif->dma_regs) + if (pmif->dma_regs) { iounmap(pmif->dma_regs); + macio_release_resource(mdev, 1); + } memset(pmif, 0, sizeof(*pmif)); macio_release_resource(mdev, 0); - if (pmif->dma_regs) - macio_release_resource(mdev, 1); } return rc; @@ -1315,7 +1314,7 @@ pmac_ide_pci_attach(struct pci_dev *pdev, const struct pci_device_id *id) return -ENXIO; } - hwif->pci_dev = pdev; + hwif->dev = &pdev->dev; pmif->mdev = NULL; pmif->node = np; @@ -1535,11 +1534,10 @@ pmac_ide_build_dmatable(ide_drive_t *drive, struct request *rq) } printk(KERN_DEBUG "%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); + +use_pio_instead: + ide_destroy_dmatable(drive); + return 0; /* revert to PIO for this request */ } @@ -1548,12 +1546,9 @@ static void pmac_ide_destroy_dmatable (ide_drive_t *drive) { ide_hwif_t *hwif = drive->hwif; - struct pci_dev *dev = HWIF(drive)->pci_dev; - struct scatterlist *sg = hwif->sg_table; - int nents = hwif->sg_nents; - if (nents) { - pci_unmap_sg(dev, sg, nents, hwif->sg_dma_direction); + if (hwif->sg_nents) { + ide_destroy_dmatable(drive); hwif->sg_nents = 0; } } @@ -1726,13 +1721,15 @@ pmac_ide_dma_lost_irq (ide_drive_t *drive) * Allocate the data structures needed for using DMA with an interface * and fill the proper list of functions pointers */ -static void __init +static void __devinit pmac_ide_setup_dma(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif) { + struct pci_dev *dev = to_pci_dev(hwif->dev); + /* We won't need pci_dev if we switch to generic consistent * DMA routines ... */ - if (hwif->pci_dev == NULL) + if (dev == NULL) return; /* * Allocate space for the DBDMA commands. @@ -1740,7 +1737,7 @@ pmac_ide_setup_dma(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif) * aligning the start address to a multiple of 16 bytes. */ pmif->dma_table_cpu = (struct dbdma_cmd*)pci_alloc_consistent( - hwif->pci_dev, + dev, (MAX_DCMDS + 2) * sizeof(struct dbdma_cmd), &hwif->dmatable_dma); if (pmif->dma_table_cpu == NULL) { |