aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide-probe.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ide/ide-probe.c')
-rw-r--r--drivers/ide/ide-probe.c87
1 files changed, 47 insertions, 40 deletions
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index e294c7415c27..d5146c57e5b3 100644
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -717,7 +717,7 @@ EXPORT_SYMBOL_GPL(ide_undecoded_slave);
717 * This routine only knows how to look for drive units 0 and 1 717 * This routine only knows how to look for drive units 0 and 1
718 * on an interface, so any setting of MAX_DRIVES > 2 won't work here. 718 * on an interface, so any setting of MAX_DRIVES > 2 won't work here.
719 */ 719 */
720static void probe_hwif(ide_hwif_t *hwif, void (*fixup)(ide_hwif_t *hwif)) 720static void probe_hwif(ide_hwif_t *hwif)
721{ 721{
722 unsigned long flags; 722 unsigned long flags;
723 unsigned int irqd; 723 unsigned int irqd;
@@ -819,8 +819,8 @@ static void probe_hwif(ide_hwif_t *hwif, void (*fixup)(ide_hwif_t *hwif))
819 return; 819 return;
820 } 820 }
821 821
822 if (fixup) 822 if (hwif->fixup)
823 fixup(hwif); 823 hwif->fixup(hwif);
824 824
825 for (unit = 0; unit < MAX_DRIVES; ++unit) { 825 for (unit = 0; unit < MAX_DRIVES; ++unit) {
826 ide_drive_t *drive = &hwif->drives[unit]; 826 ide_drive_t *drive = &hwif->drives[unit];
@@ -859,10 +859,11 @@ static void probe_hwif(ide_hwif_t *hwif, void (*fixup)(ide_hwif_t *hwif))
859} 859}
860 860
861static int hwif_init(ide_hwif_t *hwif); 861static int hwif_init(ide_hwif_t *hwif);
862static void hwif_register_devices(ide_hwif_t *hwif);
862 863
863int probe_hwif_init_with_fixup(ide_hwif_t *hwif, void (*fixup)(ide_hwif_t *hwif)) 864static int probe_hwif_init(ide_hwif_t *hwif)
864{ 865{
865 probe_hwif(hwif, fixup); 866 probe_hwif(hwif);
866 867
867 if (!hwif_init(hwif)) { 868 if (!hwif_init(hwif)) {
868 printk(KERN_INFO "%s: failed to initialize IDE interface\n", 869 printk(KERN_INFO "%s: failed to initialize IDE interface\n",
@@ -870,34 +871,12 @@ int probe_hwif_init_with_fixup(ide_hwif_t *hwif, void (*fixup)(ide_hwif_t *hwif)
870 return -1; 871 return -1;
871 } 872 }
872 873
873 if (hwif->present) { 874 if (hwif->present)
874 u16 unit = 0; 875 hwif_register_devices(hwif);
875 int ret;
876 876
877 for (unit = 0; unit < MAX_DRIVES; ++unit) {
878 ide_drive_t *drive = &hwif->drives[unit];
879 /* For now don't attach absent drives, we may
880 want them on default or a new "empty" class
881 for hotplug reprobing ? */
882 if (drive->present) {
883 ret = device_register(&drive->gendev);
884 if (ret < 0)
885 printk(KERN_WARNING "IDE: %s: "
886 "device_register error: %d\n",
887 __FUNCTION__, ret);
888 }
889 }
890 }
891 return 0; 877 return 0;
892} 878}
893 879
894int probe_hwif_init(ide_hwif_t *hwif)
895{
896 return probe_hwif_init_with_fixup(hwif, NULL);
897}
898
899EXPORT_SYMBOL(probe_hwif_init);
900
901#if MAX_HWIFS > 1 880#if MAX_HWIFS > 1
902/* 881/*
903 * save_match() is used to simplify logic in init_irq() below. 882 * save_match() is used to simplify logic in init_irq() below.
@@ -1379,6 +1358,24 @@ out:
1379 return 0; 1358 return 0;
1380} 1359}
1381 1360
1361static void hwif_register_devices(ide_hwif_t *hwif)
1362{
1363 unsigned int i;
1364
1365 for (i = 0; i < MAX_DRIVES; i++) {
1366 ide_drive_t *drive = &hwif->drives[i];
1367
1368 if (drive->present) {
1369 int ret = device_register(&drive->gendev);
1370
1371 if (ret < 0)
1372 printk(KERN_WARNING "IDE: %s: "
1373 "device_register error: %d\n",
1374 __FUNCTION__, ret);
1375 }
1376 }
1377}
1378
1382int ideprobe_init (void) 1379int ideprobe_init (void)
1383{ 1380{
1384 unsigned int index; 1381 unsigned int index;
@@ -1390,27 +1387,18 @@ int ideprobe_init (void)
1390 1387
1391 for (index = 0; index < MAX_HWIFS; ++index) 1388 for (index = 0; index < MAX_HWIFS; ++index)
1392 if (probe[index]) 1389 if (probe[index])
1393 probe_hwif(&ide_hwifs[index], NULL); 1390 probe_hwif(&ide_hwifs[index]);
1394 for (index = 0; index < MAX_HWIFS; ++index) 1391 for (index = 0; index < MAX_HWIFS; ++index)
1395 if (probe[index]) 1392 if (probe[index])
1396 hwif_init(&ide_hwifs[index]); 1393 hwif_init(&ide_hwifs[index]);
1397 for (index = 0; index < MAX_HWIFS; ++index) { 1394 for (index = 0; index < MAX_HWIFS; ++index) {
1398 if (probe[index]) { 1395 if (probe[index]) {
1399 ide_hwif_t *hwif = &ide_hwifs[index]; 1396 ide_hwif_t *hwif = &ide_hwifs[index];
1400 int unit;
1401 if (!hwif->present) 1397 if (!hwif->present)
1402 continue; 1398 continue;
1403 if (hwif->chipset == ide_unknown || hwif->chipset == ide_forced) 1399 if (hwif->chipset == ide_unknown || hwif->chipset == ide_forced)
1404 hwif->chipset = ide_generic; 1400 hwif->chipset = ide_generic;
1405 for (unit = 0; unit < MAX_DRIVES; ++unit) 1401 hwif_register_devices(hwif);
1406 if (hwif->drives[unit].present) {
1407 int ret = device_register(
1408 &hwif->drives[unit].gendev);
1409 if (ret < 0)
1410 printk(KERN_WARNING "IDE: %s: "
1411 "device_register error: %d\n",
1412 __FUNCTION__, ret);
1413 }
1414 } 1402 }
1415 } 1403 }
1416 for (index = 0; index < MAX_HWIFS; ++index) 1404 for (index = 0; index < MAX_HWIFS; ++index)
@@ -1420,3 +1408,22 @@ int ideprobe_init (void)
1420} 1408}
1421 1409
1422EXPORT_SYMBOL_GPL(ideprobe_init); 1410EXPORT_SYMBOL_GPL(ideprobe_init);
1411
1412int ide_device_add(u8 idx[4])
1413{
1414 int i, rc = 0;
1415
1416 for (i = 0; i < 4; i++) {
1417 if (idx[i] != 0xff)
1418 rc |= probe_hwif_init(&ide_hwifs[idx[i]]);
1419 }
1420
1421 for (i = 0; i < 4; i++) {
1422 if (idx[i] != 0xff)
1423 ide_proc_register_port(&ide_hwifs[idx[i]]);
1424 }
1425
1426 return rc;
1427}
1428
1429EXPORT_SYMBOL_GPL(ide_device_add);