aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ppc
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-07-23 13:55:49 -0400
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-07-23 13:55:49 -0400
commitb36ba53218e164e49623e36fa3a2fec9f08cf70a (patch)
treee1c23d0bdc3a0140b7658a74573d102724fefbe2 /drivers/ide/ppc
parent07eb106f3a69400b628b7b6ca3464a1a8f847fa3 (diff)
ide-pmac: move ide_find_port() call to pmac_ide_setup_device() (take 2)
Move ide_find_port() call to pmac_ide_setup_device(). While at it: - fix return value (s/-ENODEV/-ENOENT/) - add DRV_NAME define and use it to set name field of pmac_port_info - use ide_find_port_slot() instead of ide_find_port() - remove superfluous error message (ide_find_port_slot() takes care of it) - drop IDE interface number from driver banner message (but include bus type) v2: * Build fix (thanks to Stephen Rothwell for noticing the issue). Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Stephen Rothwell <sfr@canb.auug.org.au> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/ppc')
-rw-r--r--drivers/ide/ppc/pmac.c42
1 files changed, 16 insertions, 26 deletions
diff --git a/drivers/ide/ppc/pmac.c b/drivers/ide/ppc/pmac.c
index 4530b49e7dd0..4e2944ee76d8 100644
--- a/drivers/ide/ppc/pmac.c
+++ b/drivers/ide/ppc/pmac.c
@@ -48,6 +48,8 @@
48#include <asm/mediabay.h> 48#include <asm/mediabay.h>
49#endif 49#endif
50 50
51#define DRV_NAME "ide-pmac"
52
51#undef IDE_PMAC_DEBUG 53#undef IDE_PMAC_DEBUG
52 54
53#define DMA_WAIT_TIMEOUT 50 55#define DMA_WAIT_TIMEOUT 50
@@ -984,6 +986,7 @@ static const struct ide_port_ops pmac_ide_port_ops = {
984static const struct ide_dma_ops pmac_dma_ops; 986static const struct ide_dma_ops pmac_dma_ops;
985 987
986static const struct ide_port_info pmac_port_info = { 988static const struct ide_port_info pmac_port_info = {
989 .name = DRV_NAME,
987 .init_dma = pmac_ide_init_dma, 990 .init_dma = pmac_ide_init_dma,
988 .chipset = ide_pmac, 991 .chipset = ide_pmac,
989#ifdef CONFIG_BLK_DEV_IDEDMA_PMAC 992#ifdef CONFIG_BLK_DEV_IDEDMA_PMAC
@@ -1002,11 +1005,11 @@ static const struct ide_port_info pmac_port_info = {
1002 * Setup, register & probe an IDE channel driven by this driver, this is 1005 * Setup, register & probe an IDE channel driven by this driver, this is
1003 * called by one of the 2 probe functions (macio or PCI). 1006 * called by one of the 2 probe functions (macio or PCI).
1004 */ 1007 */
1005static int __devinit 1008static int __devinit pmac_ide_setup_device(pmac_ide_hwif_t *pmif, hw_regs_t *hw)
1006pmac_ide_setup_device(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif, hw_regs_t *hw)
1007{ 1009{
1008 struct device_node *np = pmif->node; 1010 struct device_node *np = pmif->node;
1009 const int *bidp; 1011 const int *bidp;
1012 ide_hwif_t *hwif;
1010 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; 1013 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
1011 struct ide_port_info d = pmac_port_info; 1014 struct ide_port_info d = pmac_port_info;
1012 1015
@@ -1079,16 +1082,21 @@ pmac_ide_setup_device(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif, hw_regs_t *hw)
1079 msleep(jiffies_to_msecs(IDE_WAKEUP_DELAY)); 1082 msleep(jiffies_to_msecs(IDE_WAKEUP_DELAY));
1080 } 1083 }
1081 1084
1085 printk(KERN_INFO DRV_NAME ": Found Apple %s controller (%s), "
1086 "bus ID %d%s, irq %d\n", model_name[pmif->kind],
1087 pmif->mdev ? "macio" : "PCI", pmif->aapl_bus_id,
1088 pmif->mediabay ? " (mediabay)" : "", hw->irq);
1089
1090 hwif = ide_find_port_slot(&d);
1091 if (hwif == NULL)
1092 return -ENOENT;
1093
1082 /* Setup MMIO ops */ 1094 /* Setup MMIO ops */
1083 default_hwif_mmiops(hwif); 1095 default_hwif_mmiops(hwif);
1084 hwif->OUTBSYNC = pmac_outbsync; 1096 hwif->OUTBSYNC = pmac_outbsync;
1085 1097
1086 ide_init_port_hw(hwif, hw); 1098 ide_init_port_hw(hwif, hw);
1087 1099
1088 printk(KERN_INFO "ide%d: Found Apple %s controller, bus ID %d%s, irq %d\n",
1089 hwif->index, model_name[pmif->kind], pmif->aapl_bus_id,
1090 pmif->mediabay ? " (mediabay)" : "", hwif->irq);
1091
1092 idx[0] = hwif->index; 1100 idx[0] = hwif->index;
1093 1101
1094 ide_device_add(idx, &d); 1102 ide_device_add(idx, &d);
@@ -1114,7 +1122,6 @@ pmac_ide_macio_attach(struct macio_dev *mdev, const struct of_device_id *match)
1114{ 1122{
1115 void __iomem *base; 1123 void __iomem *base;
1116 unsigned long regbase; 1124 unsigned long regbase;
1117 ide_hwif_t *hwif;
1118 pmac_ide_hwif_t *pmif; 1125 pmac_ide_hwif_t *pmif;
1119 int irq, rc; 1126 int irq, rc;
1120 hw_regs_t hw; 1127 hw_regs_t hw;
@@ -1123,14 +1130,6 @@ pmac_ide_macio_attach(struct macio_dev *mdev, const struct of_device_id *match)
1123 if (pmif == NULL) 1130 if (pmif == NULL)
1124 return -ENOMEM; 1131 return -ENOMEM;
1125 1132
1126 hwif = ide_find_port();
1127 if (hwif == NULL) {
1128 printk(KERN_ERR "ide-pmac: MacIO interface attach with no slot\n");
1129 printk(KERN_ERR " %s\n", mdev->ofdev.node->full_name);
1130 rc = -ENODEV;
1131 goto out_free_pmif;
1132 }
1133
1134 if (macio_resource_count(mdev) == 0) { 1133 if (macio_resource_count(mdev) == 0) {
1135 printk(KERN_WARNING "ide-pmac: no address for %s\n", 1134 printk(KERN_WARNING "ide-pmac: no address for %s\n",
1136 mdev->ofdev.node->full_name); 1135 mdev->ofdev.node->full_name);
@@ -1185,7 +1184,7 @@ pmac_ide_macio_attach(struct macio_dev *mdev, const struct of_device_id *match)
1185 hw.dev = &mdev->bus->pdev->dev; 1184 hw.dev = &mdev->bus->pdev->dev;
1186 hw.parent = &mdev->ofdev.dev; 1185 hw.parent = &mdev->ofdev.dev;
1187 1186
1188 rc = pmac_ide_setup_device(pmif, hwif, &hw); 1187 rc = pmac_ide_setup_device(pmif, &hw);
1189 if (rc != 0) { 1188 if (rc != 0) {
1190 /* The inteface is released to the common IDE layer */ 1189 /* The inteface is released to the common IDE layer */
1191 dev_set_drvdata(&mdev->ofdev.dev, NULL); 1190 dev_set_drvdata(&mdev->ofdev.dev, NULL);
@@ -1244,7 +1243,6 @@ pmac_ide_macio_resume(struct macio_dev *mdev)
1244static int __devinit 1243static int __devinit
1245pmac_ide_pci_attach(struct pci_dev *pdev, const struct pci_device_id *id) 1244pmac_ide_pci_attach(struct pci_dev *pdev, const struct pci_device_id *id)
1246{ 1245{
1247 ide_hwif_t *hwif;
1248 struct device_node *np; 1246 struct device_node *np;
1249 pmac_ide_hwif_t *pmif; 1247 pmac_ide_hwif_t *pmif;
1250 void __iomem *base; 1248 void __iomem *base;
@@ -1262,14 +1260,6 @@ pmac_ide_pci_attach(struct pci_dev *pdev, const struct pci_device_id *id)
1262 if (pmif == NULL) 1260 if (pmif == NULL)
1263 return -ENOMEM; 1261 return -ENOMEM;
1264 1262
1265 hwif = ide_find_port();
1266 if (hwif == NULL) {
1267 printk(KERN_ERR "ide-pmac: PCI interface attach with no slot\n");
1268 printk(KERN_ERR " %s\n", np->full_name);
1269 rc = -ENODEV;
1270 goto out_free_pmif;
1271 }
1272
1273 if (pci_enable_device(pdev)) { 1263 if (pci_enable_device(pdev)) {
1274 printk(KERN_WARNING "ide-pmac: Can't enable PCI device for " 1264 printk(KERN_WARNING "ide-pmac: Can't enable PCI device for "
1275 "%s\n", np->full_name); 1265 "%s\n", np->full_name);
@@ -1306,7 +1296,7 @@ pmac_ide_pci_attach(struct pci_dev *pdev, const struct pci_device_id *id)
1306 hw.irq = pdev->irq; 1296 hw.irq = pdev->irq;
1307 hw.dev = &pdev->dev; 1297 hw.dev = &pdev->dev;
1308 1298
1309 rc = pmac_ide_setup_device(pmif, hwif, &hw); 1299 rc = pmac_ide_setup_device(pmif, &hw);
1310 if (rc != 0) { 1300 if (rc != 0) {
1311 /* The inteface is released to the common IDE layer */ 1301 /* The inteface is released to the common IDE layer */
1312 pci_set_drvdata(pdev, NULL); 1302 pci_set_drvdata(pdev, NULL);