summaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide-probe.c
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz2008-02-01 23:09:36 +0100
committerBartlomiej Zolnierkiewicz2008-02-01 23:09:36 +0100
commita14dc57495899175a0827673fe23ed17b5653896 (patch)
tree230bee815285fa114e7bbead9194bac6eefcbe20 /drivers/ide/ide-probe.c
parentide: factor out code for tuning devices from ide_probe_port() (diff)
downloadkernel-qcow2-linux-a14dc57495899175a0827673fe23ed17b5653896.tar.gz
kernel-qcow2-linux-a14dc57495899175a0827673fe23ed17b5653896.tar.xz
kernel-qcow2-linux-a14dc57495899175a0827673fe23ed17b5653896.zip
ide: move hwif_register() call out of ide_probe_port()
* Add BUG_ON(hwif->present) at the start of ide_probe_port(). * Move hwif_register() call (along with setting hwif->present) from ide_probe_port() to ide_device_add_all(). As a result the port will be registered with the device tree _after_: - probing both devices (if both are present) - port reset (if hwif->reset is set) - restoring local IRQs state and re-enabling port IRQ While at it: * Rename hwif_register() to ide_register_port(). Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/ide-probe.c')
-rw-r--r--drivers/ide/ide-probe.c27
1 files changed, 13 insertions, 14 deletions
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index 298f398d0fd4..98a8af44bf64 100644
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -613,7 +613,7 @@ static void hwif_release_dev (struct device *dev)
complete(&hwif->gendev_rel_comp);
}
-static void hwif_register (ide_hwif_t *hwif)
+static void ide_register_port(ide_hwif_t *hwif)
{
int ret;
@@ -742,7 +742,9 @@ static int ide_probe_port(ide_hwif_t *hwif)
{
unsigned long flags;
unsigned int irqd;
- int unit;
+ int unit, rc = -ENODEV;
+
+ BUG_ON(hwif->present);
if (hwif->noprobe)
return -EACCES;
@@ -767,14 +769,8 @@ static int ide_probe_port(ide_hwif_t *hwif)
ide_drive_t *drive = &hwif->drives[unit];
drive->dn = (hwif->channel ? 2 : 0) + unit;
(void) probe_for_drive(drive);
- if (drive->present && !hwif->present) {
- hwif->present = 1;
- if (hwif->chipset != ide_4drives ||
- !hwif->mate ||
- !hwif->mate->present) {
- hwif_register(hwif);
- }
- }
+ if (drive->present)
+ rc = 0;
}
if (hwif->io_ports[IDE_CONTROL_OFFSET] && hwif->reset) {
printk(KERN_WARNING "%s: reset\n", hwif->name);
@@ -791,10 +787,7 @@ static int ide_probe_port(ide_hwif_t *hwif)
if (irqd)
enable_irq(irqd);
- if (!hwif->present)
- return -ENODEV;
-
- return 0;
+ return rc;
}
static void ide_port_tune_devices(ide_hwif_t *hwif)
@@ -1319,6 +1312,12 @@ int ide_device_add_all(u8 *idx)
continue;
}
+ hwif->present = 1;
+
+ if (hwif->chipset != ide_4drives || !hwif->mate ||
+ !hwif->mate->present)
+ ide_register_port(hwif);
+
ide_port_tune_devices(hwif);
}