diff options
Diffstat (limited to 'drivers/ide/ide-probe.c')
-rw-r--r-- | drivers/ide/ide-probe.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c index 6a196c27b0aa..f81793f3f247 100644 --- a/drivers/ide/ide-probe.c +++ b/drivers/ide/ide-probe.c | |||
@@ -1444,6 +1444,52 @@ static int ide_sysfs_register_port(ide_hwif_t *hwif) | |||
1444 | return rc; | 1444 | return rc; |
1445 | } | 1445 | } |
1446 | 1446 | ||
1447 | /** | ||
1448 | * ide_find_port_slot - find free ide_hwifs[] slot | ||
1449 | * @d: IDE port info | ||
1450 | * | ||
1451 | * Return the new hwif. If we are out of free slots return NULL. | ||
1452 | */ | ||
1453 | |||
1454 | ide_hwif_t *ide_find_port_slot(const struct ide_port_info *d) | ||
1455 | { | ||
1456 | ide_hwif_t *hwif; | ||
1457 | int i; | ||
1458 | u8 bootable = (d && (d->host_flags & IDE_HFLAG_NON_BOOTABLE)) ? 0 : 1; | ||
1459 | |||
1460 | /* | ||
1461 | * Claim an unassigned slot. | ||
1462 | * | ||
1463 | * Give preference to claiming other slots before claiming ide0/ide1, | ||
1464 | * just in case there's another interface yet-to-be-scanned | ||
1465 | * which uses ports 0x1f0/0x170 (the ide0/ide1 defaults). | ||
1466 | * | ||
1467 | * Unless there is a bootable card that does not use the standard | ||
1468 | * ports 0x1f0/0x170 (the ide0/ide1 defaults). | ||
1469 | */ | ||
1470 | if (bootable) { | ||
1471 | for (i = 0; i < MAX_HWIFS; i++) { | ||
1472 | hwif = &ide_hwifs[i]; | ||
1473 | if (hwif->chipset == ide_unknown) | ||
1474 | return hwif; | ||
1475 | } | ||
1476 | } else { | ||
1477 | for (i = 2; i < MAX_HWIFS; i++) { | ||
1478 | hwif = &ide_hwifs[i]; | ||
1479 | if (hwif->chipset == ide_unknown) | ||
1480 | return hwif; | ||
1481 | } | ||
1482 | for (i = 0; i < 2 && i < MAX_HWIFS; i++) { | ||
1483 | hwif = &ide_hwifs[i]; | ||
1484 | if (hwif->chipset == ide_unknown) | ||
1485 | return hwif; | ||
1486 | } | ||
1487 | } | ||
1488 | |||
1489 | return NULL; | ||
1490 | } | ||
1491 | EXPORT_SYMBOL_GPL(ide_find_port_slot); | ||
1492 | |||
1447 | int ide_device_add_all(u8 *idx, const struct ide_port_info *d) | 1493 | int ide_device_add_all(u8 *idx, const struct ide_port_info *d) |
1448 | { | 1494 | { |
1449 | ide_hwif_t *hwif, *mate = NULL; | 1495 | ide_hwif_t *hwif, *mate = NULL; |