aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-04-26 11:36:33 -0400
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-04-26 11:36:33 -0400
commit939b0f1d32c0d5fb68531ced559598df211bc323 (patch)
tree67fe00de5f641af09f63e63f23ddf2be3025e334 /drivers
parent5297a3e522ff77e01fd0e792acc5ff0517822708 (diff)
ide-pmac: use ide_find_port()
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/ide/ppc/pmac.c44
1 files changed, 19 insertions, 25 deletions
diff --git a/drivers/ide/ppc/pmac.c b/drivers/ide/ppc/pmac.c
index 2793e5fe137e..8f4080c73081 100644
--- a/drivers/ide/ppc/pmac.c
+++ b/drivers/ide/ppc/pmac.c
@@ -1086,38 +1086,34 @@ pmac_ide_macio_attach(struct macio_dev *mdev, const struct of_device_id *match)
1086{ 1086{
1087 void __iomem *base; 1087 void __iomem *base;
1088 unsigned long regbase; 1088 unsigned long regbase;
1089 int irq;
1090 ide_hwif_t *hwif; 1089 ide_hwif_t *hwif;
1091 pmac_ide_hwif_t *pmif; 1090 pmac_ide_hwif_t *pmif;
1092 int i, rc; 1091 int irq, rc;
1093 hw_regs_t hw; 1092 hw_regs_t hw;
1094 1093
1095 pmif = kzalloc(sizeof(*pmif), GFP_KERNEL); 1094 pmif = kzalloc(sizeof(*pmif), GFP_KERNEL);
1096 if (pmif == NULL) 1095 if (pmif == NULL)
1097 return -ENOMEM; 1096 return -ENOMEM;
1098 1097
1099 i = 0; 1098 hwif = ide_find_port();
1100 while (i < MAX_HWIFS && (ide_hwifs[i].io_ports[IDE_DATA_OFFSET] != 0)) 1099 if (hwif == NULL) {
1101 ++i;
1102 if (i >= MAX_HWIFS) {
1103 printk(KERN_ERR "ide-pmac: MacIO interface attach with no slot\n"); 1100 printk(KERN_ERR "ide-pmac: MacIO interface attach with no slot\n");
1104 printk(KERN_ERR " %s\n", mdev->ofdev.node->full_name); 1101 printk(KERN_ERR " %s\n", mdev->ofdev.node->full_name);
1105 rc = -ENODEV; 1102 rc = -ENODEV;
1106 goto out_free_pmif; 1103 goto out_free_pmif;
1107 } 1104 }
1108 1105
1109 hwif = &ide_hwifs[i];
1110
1111 if (macio_resource_count(mdev) == 0) { 1106 if (macio_resource_count(mdev) == 0) {
1112 printk(KERN_WARNING "ide%d: no address for %s\n", 1107 printk(KERN_WARNING "ide-pmac: no address for %s\n",
1113 i, mdev->ofdev.node->full_name); 1108 mdev->ofdev.node->full_name);
1114 rc = -ENXIO; 1109 rc = -ENXIO;
1115 goto out_free_pmif; 1110 goto out_free_pmif;
1116 } 1111 }
1117 1112
1118 /* Request memory resource for IO ports */ 1113 /* Request memory resource for IO ports */
1119 if (macio_request_resource(mdev, 0, "ide-pmac (ports)")) { 1114 if (macio_request_resource(mdev, 0, "ide-pmac (ports)")) {
1120 printk(KERN_ERR "ide%d: can't request mmio resource !\n", i); 1115 printk(KERN_ERR "ide-pmac: can't request MMIO resource for "
1116 "%s!\n", mdev->ofdev.node->full_name);
1121 rc = -EBUSY; 1117 rc = -EBUSY;
1122 goto out_free_pmif; 1118 goto out_free_pmif;
1123 } 1119 }
@@ -1128,8 +1124,8 @@ pmac_ide_macio_attach(struct macio_dev *mdev, const struct of_device_id *match)
1128 * where that happens though... 1124 * where that happens though...
1129 */ 1125 */
1130 if (macio_irq_count(mdev) == 0) { 1126 if (macio_irq_count(mdev) == 0) {
1131 printk(KERN_WARNING "ide%d: no intrs for device %s, using 13\n", 1127 printk(KERN_WARNING "ide-pmac: no intrs for device %s, using "
1132 i, mdev->ofdev.node->full_name); 1128 "13\n", mdev->ofdev.node->full_name);
1133 irq = irq_create_mapping(NULL, 13); 1129 irq = irq_create_mapping(NULL, 13);
1134 } else 1130 } else
1135 irq = macio_irq(mdev, 0); 1131 irq = macio_irq(mdev, 0);
@@ -1147,7 +1143,9 @@ pmac_ide_macio_attach(struct macio_dev *mdev, const struct of_device_id *match)
1147#ifdef CONFIG_BLK_DEV_IDEDMA_PMAC 1143#ifdef CONFIG_BLK_DEV_IDEDMA_PMAC
1148 if (macio_resource_count(mdev) >= 2) { 1144 if (macio_resource_count(mdev) >= 2) {
1149 if (macio_request_resource(mdev, 1, "ide-pmac (dma)")) 1145 if (macio_request_resource(mdev, 1, "ide-pmac (dma)"))
1150 printk(KERN_WARNING "ide%d: can't request DMA resource !\n", i); 1146 printk(KERN_WARNING "ide-pmac: can't request DMA "
1147 "resource for %s!\n",
1148 mdev->ofdev.node->full_name);
1151 else 1149 else
1152 pmif->dma_regs = ioremap(macio_resource_start(mdev, 1), 0x1000); 1150 pmif->dma_regs = ioremap(macio_resource_start(mdev, 1), 0x1000);
1153 } else 1151 } else
@@ -1222,7 +1220,7 @@ pmac_ide_pci_attach(struct pci_dev *pdev, const struct pci_device_id *id)
1222 pmac_ide_hwif_t *pmif; 1220 pmac_ide_hwif_t *pmif;
1223 void __iomem *base; 1221 void __iomem *base;
1224 unsigned long rbase, rlen; 1222 unsigned long rbase, rlen;
1225 int i, rc; 1223 int rc;
1226 hw_regs_t hw; 1224 hw_regs_t hw;
1227 1225
1228 np = pci_device_to_OF_node(pdev); 1226 np = pci_device_to_OF_node(pdev);
@@ -1235,29 +1233,25 @@ pmac_ide_pci_attach(struct pci_dev *pdev, const struct pci_device_id *id)
1235 if (pmif == NULL) 1233 if (pmif == NULL)
1236 return -ENOMEM; 1234 return -ENOMEM;
1237 1235
1238 i = 0; 1236 hwif = ide_find_port();
1239 while (i < MAX_HWIFS && (ide_hwifs[i].io_ports[IDE_DATA_OFFSET] != 0)) 1237 if (hwif == NULL) {
1240 ++i;
1241 if (i >= MAX_HWIFS) {
1242 printk(KERN_ERR "ide-pmac: PCI interface attach with no slot\n"); 1238 printk(KERN_ERR "ide-pmac: PCI interface attach with no slot\n");
1243 printk(KERN_ERR " %s\n", np->full_name); 1239 printk(KERN_ERR " %s\n", np->full_name);
1244 rc = -ENODEV; 1240 rc = -ENODEV;
1245 goto out_free_pmif; 1241 goto out_free_pmif;
1246 } 1242 }
1247 1243
1248 hwif = &ide_hwifs[i];
1249
1250 if (pci_enable_device(pdev)) { 1244 if (pci_enable_device(pdev)) {
1251 printk(KERN_WARNING "ide%i: Can't enable PCI device for %s\n", 1245 printk(KERN_WARNING "ide-pmac: Can't enable PCI device for "
1252 i, np->full_name); 1246 "%s\n", np->full_name);
1253 rc = -ENXIO; 1247 rc = -ENXIO;
1254 goto out_free_pmif; 1248 goto out_free_pmif;
1255 } 1249 }
1256 pci_set_master(pdev); 1250 pci_set_master(pdev);
1257 1251
1258 if (pci_request_regions(pdev, "Kauai ATA")) { 1252 if (pci_request_regions(pdev, "Kauai ATA")) {
1259 printk(KERN_ERR "ide%d: Cannot obtain PCI resources for %s\n", 1253 printk(KERN_ERR "ide-pmac: Cannot obtain PCI resources for "
1260 i, np->full_name); 1254 "%s\n", np->full_name);
1261 rc = -ENXIO; 1255 rc = -ENXIO;
1262 goto out_free_pmif; 1256 goto out_free_pmif;
1263 } 1257 }