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>

+13 -14
+13 -14
drivers/ide/ide-probe.c
··· 613 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 618 int ret; 619 619 ··· 742 742 { 743 743 unsigned long flags; 744 744 unsigned int irqd; 745 - int unit; 745 + int unit, rc = -ENODEV; 746 + 747 + BUG_ON(hwif->present); 746 748 747 749 if (hwif->noprobe) 748 750 return -EACCES; ··· 769 767 ide_drive_t *drive = &hwif->drives[unit]; 770 768 drive->dn = (hwif->channel ? 2 : 0) + unit; 771 769 (void) probe_for_drive(drive); 772 - if (drive->present && !hwif->present) { 773 - hwif->present = 1; 774 - if (hwif->chipset != ide_4drives || 775 - !hwif->mate || 776 - !hwif->mate->present) { 777 - hwif_register(hwif); 778 - } 779 - } 770 + if (drive->present) 771 + rc = 0; 780 772 } 781 773 if (hwif->io_ports[IDE_CONTROL_OFFSET] && hwif->reset) { 782 774 printk(KERN_WARNING "%s: reset\n", hwif->name); ··· 787 791 if (irqd) 788 792 enable_irq(irqd); 789 793 790 - if (!hwif->present) 791 - return -ENODEV; 792 - 793 - return 0; 794 + return rc; 794 795 } 795 796 796 797 static void ide_port_tune_devices(ide_hwif_t *hwif) ··· 1311 1318 ide_hwif_release_regions(hwif); 1312 1319 continue; 1313 1320 } 1321 + 1322 + hwif->present = 1; 1323 + 1324 + if (hwif->chipset != ide_4drives || !hwif->mate || 1325 + !hwif->mate->present) 1326 + ide_register_port(hwif); 1314 1327 1315 1328 ide_port_tune_devices(hwif); 1316 1329 }