diff options
author | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-02-01 17:09:36 -0500 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-02-01 17:09:36 -0500 |
commit | a14dc57495899175a0827673fe23ed17b5653896 (patch) | |
tree | 230bee815285fa114e7bbead9194bac6eefcbe20 /drivers | |
parent | e84e7ea7c4d0a6d7fbaecab2d85df0298cd9e3b4 (diff) |
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')
-rw-r--r-- | drivers/ide/ide-probe.c | 27 |
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) | |||
613 | complete(&hwif->gendev_rel_comp); | 613 | complete(&hwif->gendev_rel_comp); |
614 | } | 614 | } |
615 | 615 | ||
616 | static void hwif_register (ide_hwif_t *hwif) | 616 | static void ide_register_port(ide_hwif_t *hwif) |
617 | { | 617 | { |
618 | int ret; | 618 | int ret; |
619 | 619 | ||
@@ -742,7 +742,9 @@ static int ide_probe_port(ide_hwif_t *hwif) | |||
742 | { | 742 | { |
743 | unsigned long flags; | 743 | unsigned long flags; |
744 | unsigned int irqd; | 744 | unsigned int irqd; |
745 | int unit; | 745 | int unit, rc = -ENODEV; |
746 | |||
747 | BUG_ON(hwif->present); | ||
746 | 748 | ||
747 | if (hwif->noprobe) | 749 | if (hwif->noprobe) |
748 | return -EACCES; | 750 | return -EACCES; |
@@ -767,14 +769,8 @@ static int ide_probe_port(ide_hwif_t *hwif) | |||
767 | ide_drive_t *drive = &hwif->drives[unit]; | 769 | ide_drive_t *drive = &hwif->drives[unit]; |
768 | drive->dn = (hwif->channel ? 2 : 0) + unit; | 770 | drive->dn = (hwif->channel ? 2 : 0) + unit; |
769 | (void) probe_for_drive(drive); | 771 | (void) probe_for_drive(drive); |
770 | if (drive->present && !hwif->present) { | 772 | if (drive->present) |
771 | hwif->present = 1; | 773 | rc = 0; |
772 | if (hwif->chipset != ide_4drives || | ||
773 | !hwif->mate || | ||
774 | !hwif->mate->present) { | ||
775 | hwif_register(hwif); | ||
776 | } | ||
777 | } | ||
778 | } | 774 | } |
779 | if (hwif->io_ports[IDE_CONTROL_OFFSET] && hwif->reset) { | 775 | if (hwif->io_ports[IDE_CONTROL_OFFSET] && hwif->reset) { |
780 | printk(KERN_WARNING "%s: reset\n", hwif->name); | 776 | printk(KERN_WARNING "%s: reset\n", hwif->name); |
@@ -791,10 +787,7 @@ static int ide_probe_port(ide_hwif_t *hwif) | |||
791 | if (irqd) | 787 | if (irqd) |
792 | enable_irq(irqd); | 788 | enable_irq(irqd); |
793 | 789 | ||
794 | if (!hwif->present) | 790 | return rc; |
795 | return -ENODEV; | ||
796 | |||
797 | return 0; | ||
798 | } | 791 | } |
799 | 792 | ||
800 | static void ide_port_tune_devices(ide_hwif_t *hwif) | 793 | static void ide_port_tune_devices(ide_hwif_t *hwif) |
@@ -1319,6 +1312,12 @@ int ide_device_add_all(u8 *idx) | |||
1319 | continue; | 1312 | continue; |
1320 | } | 1313 | } |
1321 | 1314 | ||
1315 | hwif->present = 1; | ||
1316 | |||
1317 | if (hwif->chipset != ide_4drives || !hwif->mate || | ||
1318 | !hwif->mate->present) | ||
1319 | ide_register_port(hwif); | ||
1320 | |||
1322 | ide_port_tune_devices(hwif); | 1321 | ide_port_tune_devices(hwif); |
1323 | } | 1322 | } |
1324 | 1323 | ||