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