diff options
author | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2009-02-02 14:12:21 -0500 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2009-02-02 14:12:21 -0500 |
commit | 9a100f4b78c4c59fdd1cc38c5fa6a1ec66f23d9a (patch) | |
tree | c7444871700b74d3f26d3c15d7ee78b6a85eb201 | |
parent | e5461f38b43d5658087a598c8deb2a9928d6b92b (diff) |
ide: fix ide_register_port() failure handling
* Factor out port freeing from ide_host_free() to ide_free_port().
* Add ide_disable_port() and use it on ide_register_port() failure.
Cc: Ian Campbell <Ian.Campbell@citrix.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
-rw-r--r-- | drivers/ide/ide-probe.c | 40 |
1 files changed, 32 insertions, 8 deletions
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c index 0db1ed9f5fc2..6bab2ac1f5b9 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 | } |
1468 | EXPORT_SYMBOL_GPL(ide_host_alloc); | 1468 | EXPORT_SYMBOL_GPL(ide_host_alloc); |
1469 | 1469 | ||
1470 | static 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 | |||
1477 | static 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 | |||
1470 | int ide_host_register(struct ide_host *host, const struct ide_port_info *d, | 1494 | int 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); |
@@ -1660,12 +1688,8 @@ void ide_host_free(struct ide_host *host) | |||
1660 | int i; | 1688 | int i; |
1661 | 1689 | ||
1662 | ide_host_for_each_port(i, hwif, host) { | 1690 | ide_host_for_each_port(i, hwif, host) { |
1663 | if (hwif == NULL) | 1691 | if (hwif) |
1664 | continue; | 1692 | ide_port_free(hwif); |
1665 | |||
1666 | ide_port_free_devices(hwif); | ||
1667 | ide_free_port_slot(hwif->index); | ||
1668 | kfree(hwif); | ||
1669 | } | 1693 | } |
1670 | 1694 | ||
1671 | kfree(host); | 1695 | kfree(host); |