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.c50
1 files changed, 40 insertions, 10 deletions
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index 0db1ed9f5fc2..ee8e3e7cad51 100644
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -950,6 +950,7 @@ static int ide_port_setup_devices(ide_hwif_t *hwif)
950static int init_irq (ide_hwif_t *hwif) 950static int init_irq (ide_hwif_t *hwif)
951{ 951{
952 struct ide_io_ports *io_ports = &hwif->io_ports; 952 struct ide_io_ports *io_ports = &hwif->io_ports;
953 irq_handler_t irq_handler;
953 int sa = 0; 954 int sa = 0;
954 955
955 mutex_lock(&ide_cfg_mtx); 956 mutex_lock(&ide_cfg_mtx);
@@ -959,6 +960,10 @@ static int init_irq (ide_hwif_t *hwif)
959 hwif->timer.function = &ide_timer_expiry; 960 hwif->timer.function = &ide_timer_expiry;
960 hwif->timer.data = (unsigned long)hwif; 961 hwif->timer.data = (unsigned long)hwif;
961 962
963 irq_handler = hwif->host->irq_handler;
964 if (irq_handler == NULL)
965 irq_handler = ide_intr;
966
962#if defined(__mc68000__) 967#if defined(__mc68000__)
963 sa = IRQF_SHARED; 968 sa = IRQF_SHARED;
964#endif /* __mc68000__ */ 969#endif /* __mc68000__ */
@@ -969,7 +974,7 @@ static int init_irq (ide_hwif_t *hwif)
969 if (io_ports->ctl_addr) 974 if (io_ports->ctl_addr)
970 hwif->tp_ops->set_irq(hwif, 1); 975 hwif->tp_ops->set_irq(hwif, 1);
971 976
972 if (request_irq(hwif->irq, &ide_intr, sa, hwif->name, hwif)) 977 if (request_irq(hwif->irq, irq_handler, sa, hwif->name, hwif))
973 goto out_up; 978 goto out_up;
974 979
975 if (!hwif->rqsize) { 980 if (!hwif->rqsize) {
@@ -1467,6 +1472,30 @@ struct ide_host *ide_host_alloc(const struct ide_port_info *d, hw_regs_t **hws)
1467} 1472}
1468EXPORT_SYMBOL_GPL(ide_host_alloc); 1473EXPORT_SYMBOL_GPL(ide_host_alloc);
1469 1474
1475static void ide_port_free(ide_hwif_t *hwif)
1476{
1477 ide_port_free_devices(hwif);
1478 ide_free_port_slot(hwif->index);
1479 kfree(hwif);
1480}
1481
1482static void ide_disable_port(ide_hwif_t *hwif)
1483{
1484 struct ide_host *host = hwif->host;
1485 int i;
1486
1487 printk(KERN_INFO "%s: disabling port\n", hwif->name);
1488
1489 for (i = 0; i < MAX_HOST_PORTS; i++) {
1490 if (host->ports[i] == hwif) {
1491 host->ports[i] = NULL;
1492 host->n_ports--;
1493 }
1494 }
1495
1496 ide_port_free(hwif);
1497}
1498
1470int ide_host_register(struct ide_host *host, const struct ide_port_info *d, 1499int ide_host_register(struct ide_host *host, const struct ide_port_info *d,
1471 hw_regs_t **hws) 1500 hw_regs_t **hws)
1472{ 1501{
@@ -1507,8 +1536,12 @@ int ide_host_register(struct ide_host *host, const struct ide_port_info *d,
1507 hwif->present = 1; 1536 hwif->present = 1;
1508 1537
1509 if (hwif->chipset != ide_4drives || !hwif->mate || 1538 if (hwif->chipset != ide_4drives || !hwif->mate ||
1510 !hwif->mate->present) 1539 !hwif->mate->present) {
1511 ide_register_port(hwif); 1540 if (ide_register_port(hwif)) {
1541 ide_disable_port(hwif);
1542 continue;
1543 }
1544 }
1512 1545
1513 if (hwif->present) 1546 if (hwif->present)
1514 ide_port_tune_devices(hwif); 1547 ide_port_tune_devices(hwif);
@@ -1521,7 +1554,8 @@ int ide_host_register(struct ide_host *host, const struct ide_port_info *d,
1521 if (hwif_init(hwif) == 0) { 1554 if (hwif_init(hwif) == 0) {
1522 printk(KERN_INFO "%s: failed to initialize IDE " 1555 printk(KERN_INFO "%s: failed to initialize IDE "
1523 "interface\n", hwif->name); 1556 "interface\n", hwif->name);
1524 hwif->present = 0; 1557 device_unregister(&hwif->gendev);
1558 ide_disable_port(hwif);
1525 continue; 1559 continue;
1526 } 1560 }
1527 1561
@@ -1660,12 +1694,8 @@ void ide_host_free(struct ide_host *host)
1660 int i; 1694 int i;
1661 1695
1662 ide_host_for_each_port(i, hwif, host) { 1696 ide_host_for_each_port(i, hwif, host) {
1663 if (hwif == NULL) 1697 if (hwif)
1664 continue; 1698 ide_port_free(hwif);
1665
1666 ide_port_free_devices(hwif);
1667 ide_free_port_slot(hwif->index);
1668 kfree(hwif);
1669 } 1699 }
1670 1700
1671 kfree(host); 1701 kfree(host);