aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide-probe.c
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2007-10-19 18:32:29 -0400
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2007-10-19 18:32:29 -0400
commit9601a607cceb3632cde6c66fe28a3673dcd20be5 (patch)
tree5767a9aa08df66f3873808cf82c4cbf558cbab0c /drivers/ide/ide-probe.c
parentb515da89c6f4d3c3c2a19358ce0304046c043ea1 (diff)
ide: add hwif_register_devices() helper
Add hwif_register_devices() helper to fix code duplication between probe_hwif_init_with_fixup() and ideprobe_init(). Also remove stale comment while at it. Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/ide-probe.c')
-rw-r--r--drivers/ide/ide-probe.c49
1 files changed, 22 insertions, 27 deletions
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index e294c7415c27..549174853381 100644
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -859,6 +859,7 @@ 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)) 864int probe_hwif_init_with_fixup(ide_hwif_t *hwif, void (*fixup)(ide_hwif_t *hwif))
864{ 865{
@@ -870,24 +871,9 @@ 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
@@ -1379,6 +1365,24 @@ out:
1379 return 0; 1365 return 0;
1380} 1366}
1381 1367
1368static void hwif_register_devices(ide_hwif_t *hwif)
1369{
1370 unsigned int i;
1371
1372 for (i = 0; i < MAX_DRIVES; i++) {
1373 ide_drive_t *drive = &hwif->drives[i];
1374
1375 if (drive->present) {
1376 int ret = device_register(&drive->gendev);
1377
1378 if (ret < 0)
1379 printk(KERN_WARNING "IDE: %s: "
1380 "device_register error: %d\n",
1381 __FUNCTION__, ret);
1382 }
1383 }
1384}
1385
1382int ideprobe_init (void) 1386int ideprobe_init (void)
1383{ 1387{
1384 unsigned int index; 1388 unsigned int index;
@@ -1397,20 +1401,11 @@ int ideprobe_init (void)
1397 for (index = 0; index < MAX_HWIFS; ++index) { 1401 for (index = 0; index < MAX_HWIFS; ++index) {
1398 if (probe[index]) { 1402 if (probe[index]) {
1399 ide_hwif_t *hwif = &ide_hwifs[index]; 1403 ide_hwif_t *hwif = &ide_hwifs[index];
1400 int unit;
1401 if (!hwif->present) 1404 if (!hwif->present)
1402 continue; 1405 continue;
1403 if (hwif->chipset == ide_unknown || hwif->chipset == ide_forced) 1406 if (hwif->chipset == ide_unknown || hwif->chipset == ide_forced)
1404 hwif->chipset = ide_generic; 1407 hwif->chipset = ide_generic;
1405 for (unit = 0; unit < MAX_DRIVES; ++unit) 1408 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 } 1409 }
1415 } 1410 }
1416 for (index = 0; index < MAX_HWIFS; ++index) 1411 for (index = 0; index < MAX_HWIFS; ++index)