aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide-probe.c
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-07-23 13:55:59 -0400
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-07-23 13:55:59 -0400
commit8a69580e1ea9516caada5eed202afd39546e9809 (patch)
treefb300fb7d67e09470a2654811baaa7832fec2fae /drivers/ide/ide-probe.c
parent18de10170df31d34b342612f1c896a16a52f0a5c (diff)
ide: add ide_host_free() helper (take 2)
* Add ide_host_free() helper and convert ide_host_remove() to use it. * Fix handling of ide_host_register() failure in ide_host_add(), icside.c, ide-generic.c, falconide.c and sgiioc4.c. While at it: * Fix handling of ide_host_alloc_all() failure in ide-generic.c. * Fix handling of ide_host_alloc() failure in falconide.c (also return the correct error value if no device is found). v2: * falconide build fix. (From Stephen Rothwell) Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/ide-probe.c')
-rw-r--r--drivers/ide/ide-probe.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index 6d57b7cd5424..0ead4537fc63 100644
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -1729,12 +1729,17 @@ int ide_host_add(const struct ide_port_info *d, hw_regs_t **hws,
1729 struct ide_host **hostp) 1729 struct ide_host **hostp)
1730{ 1730{
1731 struct ide_host *host; 1731 struct ide_host *host;
1732 int rc;
1732 1733
1733 host = ide_host_alloc(d, hws); 1734 host = ide_host_alloc(d, hws);
1734 if (host == NULL) 1735 if (host == NULL)
1735 return -ENOMEM; 1736 return -ENOMEM;
1736 1737
1737 ide_host_register(host, d, hws); 1738 rc = ide_host_register(host, d, hws);
1739 if (rc) {
1740 ide_host_free(host);
1741 return rc;
1742 }
1738 1743
1739 if (hostp) 1744 if (hostp)
1740 *hostp = host; 1745 *hostp = host;
@@ -1743,7 +1748,7 @@ int ide_host_add(const struct ide_port_info *d, hw_regs_t **hws,
1743} 1748}
1744EXPORT_SYMBOL_GPL(ide_host_add); 1749EXPORT_SYMBOL_GPL(ide_host_add);
1745 1750
1746void ide_host_remove(struct ide_host *host) 1751void ide_host_free(struct ide_host *host)
1747{ 1752{
1748 ide_hwif_t *hwif; 1753 ide_hwif_t *hwif;
1749 int i; 1754 int i;
@@ -1754,13 +1759,25 @@ void ide_host_remove(struct ide_host *host)
1754 if (hwif == NULL) 1759 if (hwif == NULL)
1755 continue; 1760 continue;
1756 1761
1757 ide_unregister(hwif);
1758 ide_free_port_slot(hwif->index); 1762 ide_free_port_slot(hwif->index);
1759 kfree(hwif); 1763 kfree(hwif);
1760 } 1764 }
1761 1765
1762 kfree(host); 1766 kfree(host);
1763} 1767}
1768EXPORT_SYMBOL_GPL(ide_host_free);
1769
1770void ide_host_remove(struct ide_host *host)
1771{
1772 int i;
1773
1774 for (i = 0; i < MAX_HWIFS; i++) {
1775 if (host->ports[i])
1776 ide_unregister(host->ports[i]);
1777 }
1778
1779 ide_host_free(host);
1780}
1764EXPORT_SYMBOL_GPL(ide_host_remove); 1781EXPORT_SYMBOL_GPL(ide_host_remove);
1765 1782
1766void ide_port_scan(ide_hwif_t *hwif) 1783void ide_port_scan(ide_hwif_t *hwif)