aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/pci/scc_pata.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ide/pci/scc_pata.c')
-rw-r--r--drivers/ide/pci/scc_pata.c31
1 files changed, 9 insertions, 22 deletions
diff --git a/drivers/ide/pci/scc_pata.c b/drivers/ide/pci/scc_pata.c
index c01e2da5c9e6..41a993f3ded2 100644
--- a/drivers/ide/pci/scc_pata.c
+++ b/drivers/ide/pci/scc_pata.c
@@ -483,7 +483,7 @@ static int setup_mmio_scc (struct pci_dev *dev, const char *name)
483 unsigned long dma_size = pci_resource_len(dev, 1); 483 unsigned long dma_size = pci_resource_len(dev, 1);
484 void __iomem *ctl_addr; 484 void __iomem *ctl_addr;
485 void __iomem *dma_addr; 485 void __iomem *dma_addr;
486 int i; 486 int i, ret;
487 487
488 for (i = 0; i < MAX_HWIFS; i++) { 488 for (i = 0; i < MAX_HWIFS; i++) {
489 if (scc_ports[i].ctl == 0) 489 if (scc_ports[i].ctl == 0)
@@ -492,21 +492,17 @@ static int setup_mmio_scc (struct pci_dev *dev, const char *name)
492 if (i >= MAX_HWIFS) 492 if (i >= MAX_HWIFS)
493 return -ENOMEM; 493 return -ENOMEM;
494 494
495 if (!request_mem_region(ctl_base, ctl_size, name)) { 495 ret = pci_request_selected_regions(dev, (1 << 2) - 1, name);
496 printk(KERN_WARNING "%s: IDE controller MMIO ports not available.\n", SCC_PATA_NAME); 496 if (ret < 0) {
497 goto fail_0; 497 printk(KERN_ERR "%s: can't reserve resources\n", name);
498 } 498 return ret;
499
500 if (!request_mem_region(dma_base, dma_size, name)) {
501 printk(KERN_WARNING "%s: IDE controller MMIO ports not available.\n", SCC_PATA_NAME);
502 goto fail_1;
503 } 499 }
504 500
505 if ((ctl_addr = ioremap(ctl_base, ctl_size)) == NULL) 501 if ((ctl_addr = ioremap(ctl_base, ctl_size)) == NULL)
506 goto fail_2; 502 goto fail_0;
507 503
508 if ((dma_addr = ioremap(dma_base, dma_size)) == NULL) 504 if ((dma_addr = ioremap(dma_base, dma_size)) == NULL)
509 goto fail_3; 505 goto fail_1;
510 506
511 pci_set_master(dev); 507 pci_set_master(dev);
512 scc_ports[i].ctl = (unsigned long)ctl_addr; 508 scc_ports[i].ctl = (unsigned long)ctl_addr;
@@ -515,12 +511,8 @@ static int setup_mmio_scc (struct pci_dev *dev, const char *name)
515 511
516 return 1; 512 return 1;
517 513
518 fail_3:
519 iounmap(ctl_addr);
520 fail_2:
521 release_mem_region(dma_base, dma_size);
522 fail_1: 514 fail_1:
523 release_mem_region(ctl_base, ctl_size); 515 iounmap(ctl_addr);
524 fail_0: 516 fail_0:
525 return -ENOMEM; 517 return -ENOMEM;
526} 518}
@@ -757,10 +749,6 @@ static void __devexit scc_remove(struct pci_dev *dev)
757{ 749{
758 struct scc_ports *ports = pci_get_drvdata(dev); 750 struct scc_ports *ports = pci_get_drvdata(dev);
759 ide_hwif_t *hwif = ports->hwif; 751 ide_hwif_t *hwif = ports->hwif;
760 unsigned long ctl_base = pci_resource_start(dev, 0);
761 unsigned long dma_base = pci_resource_start(dev, 1);
762 unsigned long ctl_size = pci_resource_len(dev, 0);
763 unsigned long dma_size = pci_resource_len(dev, 1);
764 752
765 if (hwif->dmatable_cpu) { 753 if (hwif->dmatable_cpu) {
766 pci_free_consistent(dev, PRD_ENTRIES * PRD_BYTES, 754 pci_free_consistent(dev, PRD_ENTRIES * PRD_BYTES,
@@ -773,8 +761,7 @@ static void __devexit scc_remove(struct pci_dev *dev)
773 hwif->chipset = ide_unknown; 761 hwif->chipset = ide_unknown;
774 iounmap((void*)ports->dma); 762 iounmap((void*)ports->dma);
775 iounmap((void*)ports->ctl); 763 iounmap((void*)ports->ctl);
776 release_mem_region(dma_base, dma_size); 764 pci_release_selected_regions(dev, (1 << 2) - 1);
777 release_mem_region(ctl_base, ctl_size);
778 memset(ports, 0, sizeof(*ports)); 765 memset(ports, 0, sizeof(*ports));
779} 766}
780 767