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.c43
1 files changed, 34 insertions, 9 deletions
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index 0db1ed9f5fc2..ce0818a993f6 100644
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -1467,6 +1467,30 @@ struct ide_host *ide_host_alloc(const struct ide_port_info *d, hw_regs_t **hws)
1467} 1467}
1468EXPORT_SYMBOL_GPL(ide_host_alloc); 1468EXPORT_SYMBOL_GPL(ide_host_alloc);
1469 1469
1470static void ide_port_free(ide_hwif_t *hwif)
1471{
1472 ide_port_free_devices(hwif);
1473 ide_free_port_slot(hwif->index);
1474 kfree(hwif);
1475}
1476
1477static void ide_disable_port(ide_hwif_t *hwif)
1478{
1479 struct ide_host *host = hwif->host;
1480 int i;
1481
1482 printk(KERN_INFO "%s: disabling port\n", hwif->name);
1483
1484 for (i = 0; i < MAX_HOST_PORTS; i++) {
1485 if (host->ports[i] == hwif) {
1486 host->ports[i] = NULL;
1487 host->n_ports--;
1488 }
1489 }
1490
1491 ide_port_free(hwif);
1492}
1493
1470int ide_host_register(struct ide_host *host, const struct ide_port_info *d, 1494int ide_host_register(struct ide_host *host, const struct ide_port_info *d,
1471 hw_regs_t **hws) 1495 hw_regs_t **hws)
1472{ 1496{
@@ -1507,8 +1531,12 @@ int ide_host_register(struct ide_host *host, const struct ide_port_info *d,
1507 hwif->present = 1; 1531 hwif->present = 1;
1508 1532
1509 if (hwif->chipset != ide_4drives || !hwif->mate || 1533 if (hwif->chipset != ide_4drives || !hwif->mate ||
1510 !hwif->mate->present) 1534 !hwif->mate->present) {
1511 ide_register_port(hwif); 1535 if (ide_register_port(hwif)) {
1536 ide_disable_port(hwif);
1537 continue;
1538 }
1539 }
1512 1540
1513 if (hwif->present) 1541 if (hwif->present)
1514 ide_port_tune_devices(hwif); 1542 ide_port_tune_devices(hwif);
@@ -1521,7 +1549,8 @@ int ide_host_register(struct ide_host *host, const struct ide_port_info *d,
1521 if (hwif_init(hwif) == 0) { 1549 if (hwif_init(hwif) == 0) {
1522 printk(KERN_INFO "%s: failed to initialize IDE " 1550 printk(KERN_INFO "%s: failed to initialize IDE "
1523 "interface\n", hwif->name); 1551 "interface\n", hwif->name);
1524 hwif->present = 0; 1552 device_unregister(&hwif->gendev);
1553 ide_disable_port(hwif);
1525 continue; 1554 continue;
1526 } 1555 }
1527 1556
@@ -1660,12 +1689,8 @@ void ide_host_free(struct ide_host *host)
1660 int i; 1689 int i;
1661 1690
1662 ide_host_for_each_port(i, hwif, host) { 1691 ide_host_for_each_port(i, hwif, host) {
1663 if (hwif == NULL) 1692 if (hwif)
1664 continue; 1693 ide_port_free(hwif);
1665
1666 ide_port_free_devices(hwif);
1667 ide_free_port_slot(hwif->index);
1668 kfree(hwif);
1669 } 1694 }
1670 1695
1671 kfree(host); 1696 kfree(host);