aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/pci/delkin_cb.c
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-02-02 13:56:39 -0500
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-02-02 13:56:39 -0500
commit9e016a719209d95338e314b46c3012cc7feaaeec (patch)
treecc19b160cfb6210385fbf29890351f9ca2ba73df /drivers/ide/pci/delkin_cb.c
parentf82c2b171905b6d5af92395d8159546351ab602f (diff)
ide: add ide_deprecated_find_port() helper
* Factor out code for finding ide_hwifs[] slot from ide_register_hw() to ide_deprecated_find_port(). * Convert bast-ide, ide-cs and delkin_cb host drivers to use ide_device_add() instead of ide_register_hw() (while at it drop doing "ide_unregister()" loop which tries to unregister _all_ IDE interfaces if useable ide_hwifs[] slot cannot be find). This patch leaves us with only two ide_register_hw() users: - drivers/macintosh/mediabay.c - drivers/ide/ide.c Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/pci/delkin_cb.c')
-rw-r--r--drivers/ide/pci/delkin_cb.c33
1 files changed, 27 insertions, 6 deletions
diff --git a/drivers/ide/pci/delkin_cb.c b/drivers/ide/pci/delkin_cb.c
index 4e9ebaa79624..15670801a67f 100644
--- a/drivers/ide/pci/delkin_cb.c
+++ b/drivers/ide/pci/delkin_cb.c
@@ -51,6 +51,7 @@ delkin_cb_probe (struct pci_dev *dev, const struct pci_device_id *id)
51 ide_hwif_t *hwif = NULL; 51 ide_hwif_t *hwif = NULL;
52 ide_drive_t *drive; 52 ide_drive_t *drive;
53 int i, rc; 53 int i, rc;
54 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
54 55
55 rc = pci_enable_device(dev); 56 rc = pci_enable_device(dev);
56 if (rc) { 57 if (rc) {
@@ -77,12 +78,27 @@ delkin_cb_probe (struct pci_dev *dev, const struct pci_device_id *id)
77 hw.irq = dev->irq; 78 hw.irq = dev->irq;
78 hw.chipset = ide_pci; /* this enables IRQ sharing */ 79 hw.chipset = ide_pci; /* this enables IRQ sharing */
79 80
80 rc = ide_register_hw(&hw, &ide_undecoded_slave, &hwif); 81 hwif = ide_deprecated_find_port(hw.io_ports[IDE_DATA_OFFSET]);
81 if (rc < 0) { 82 if (hwif == NULL)
82 printk(KERN_ERR "delkin_cb: ide_register_hw failed (%d)\n", rc); 83 goto out_disable;
83 pci_disable_device(dev); 84
84 return -ENODEV; 85 i = hwif->index;
85 } 86
87 if (hwif->present)
88 ide_unregister(i, 0, 1);
89 else if (!hwif->hold)
90 ide_init_port_data(hwif, i);
91
92 ide_init_port_hw(hwif, &hw);
93 hwif->quirkproc = &ide_undecoded_slave;
94
95 idx[0] = i;
96
97 ide_device_add(idx, NULL);
98
99 if (!hwif->present)
100 goto out_disable;
101
86 pci_set_drvdata(dev, hwif); 102 pci_set_drvdata(dev, hwif);
87 hwif->dev = &dev->dev; 103 hwif->dev = &dev->dev;
88 drive = &hwif->drives[0]; 104 drive = &hwif->drives[0];
@@ -91,6 +107,11 @@ delkin_cb_probe (struct pci_dev *dev, const struct pci_device_id *id)
91 drive->unmask = 1; 107 drive->unmask = 1;
92 } 108 }
93 return 0; 109 return 0;
110
111out_disable:
112 printk(KERN_ERR "delkin_cb: no IDE devices found\n");
113 pci_disable_device(dev);
114 return -ENODEV;
94} 115}
95 116
96static void 117static void