diff options
Diffstat (limited to 'drivers')
59 files changed, 355 insertions, 1245 deletions
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c index d72568392e6c..20ab3ffce559 100644 --- a/drivers/ata/ahci.c +++ b/drivers/ata/ahci.c | |||
@@ -45,7 +45,6 @@ | |||
45 | #include <scsi/scsi_host.h> | 45 | #include <scsi/scsi_host.h> |
46 | #include <scsi/scsi_cmnd.h> | 46 | #include <scsi/scsi_cmnd.h> |
47 | #include <linux/libata.h> | 47 | #include <linux/libata.h> |
48 | #include <asm/io.h> | ||
49 | 48 | ||
50 | #define DRV_NAME "ahci" | 49 | #define DRV_NAME "ahci" |
51 | #define DRV_VERSION "2.0" | 50 | #define DRV_VERSION "2.0" |
@@ -166,9 +165,6 @@ enum { | |||
166 | PORT_CMD_ICC_PARTIAL = (0x2 << 28), /* Put i/f in partial state */ | 165 | PORT_CMD_ICC_PARTIAL = (0x2 << 28), /* Put i/f in partial state */ |
167 | PORT_CMD_ICC_SLUMBER = (0x6 << 28), /* Put i/f in slumber state */ | 166 | PORT_CMD_ICC_SLUMBER = (0x6 << 28), /* Put i/f in slumber state */ |
168 | 167 | ||
169 | /* hpriv->flags bits */ | ||
170 | AHCI_FLAG_MSI = (1 << 0), | ||
171 | |||
172 | /* ap->flags bits */ | 168 | /* ap->flags bits */ |
173 | AHCI_FLAG_NO_NCQ = (1 << 24), | 169 | AHCI_FLAG_NO_NCQ = (1 << 24), |
174 | AHCI_FLAG_IGN_IRQ_IF_ERR = (1 << 25), /* ignore IRQ_IF_ERR */ | 170 | AHCI_FLAG_IGN_IRQ_IF_ERR = (1 << 25), /* ignore IRQ_IF_ERR */ |
@@ -191,7 +187,6 @@ struct ahci_sg { | |||
191 | }; | 187 | }; |
192 | 188 | ||
193 | struct ahci_host_priv { | 189 | struct ahci_host_priv { |
194 | unsigned long flags; | ||
195 | u32 cap; /* cache of HOST_CAP register */ | 190 | u32 cap; /* cache of HOST_CAP register */ |
196 | u32 port_map; /* cache of HOST_PORTS_IMPL reg */ | 191 | u32 port_map; /* cache of HOST_PORTS_IMPL reg */ |
197 | }; | 192 | }; |
@@ -229,7 +224,6 @@ static int ahci_port_suspend(struct ata_port *ap, pm_message_t mesg); | |||
229 | static int ahci_port_resume(struct ata_port *ap); | 224 | static int ahci_port_resume(struct ata_port *ap); |
230 | static int ahci_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg); | 225 | static int ahci_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg); |
231 | static int ahci_pci_device_resume(struct pci_dev *pdev); | 226 | static int ahci_pci_device_resume(struct pci_dev *pdev); |
232 | static void ahci_remove_one (struct pci_dev *pdev); | ||
233 | 227 | ||
234 | static struct scsi_host_template ahci_sht = { | 228 | static struct scsi_host_template ahci_sht = { |
235 | .module = THIS_MODULE, | 229 | .module = THIS_MODULE, |
@@ -441,9 +435,9 @@ static struct pci_driver ahci_pci_driver = { | |||
441 | .name = DRV_NAME, | 435 | .name = DRV_NAME, |
442 | .id_table = ahci_pci_tbl, | 436 | .id_table = ahci_pci_tbl, |
443 | .probe = ahci_init_one, | 437 | .probe = ahci_init_one, |
438 | .remove = ata_pci_remove_one, | ||
444 | .suspend = ahci_pci_device_suspend, | 439 | .suspend = ahci_pci_device_suspend, |
445 | .resume = ahci_pci_device_resume, | 440 | .resume = ahci_pci_device_resume, |
446 | .remove = ahci_remove_one, | ||
447 | }; | 441 | }; |
448 | 442 | ||
449 | 443 | ||
@@ -1426,23 +1420,18 @@ static int ahci_port_start(struct ata_port *ap) | |||
1426 | dma_addr_t mem_dma; | 1420 | dma_addr_t mem_dma; |
1427 | int rc; | 1421 | int rc; |
1428 | 1422 | ||
1429 | pp = kmalloc(sizeof(*pp), GFP_KERNEL); | 1423 | pp = devm_kzalloc(dev, sizeof(*pp), GFP_KERNEL); |
1430 | if (!pp) | 1424 | if (!pp) |
1431 | return -ENOMEM; | 1425 | return -ENOMEM; |
1432 | memset(pp, 0, sizeof(*pp)); | ||
1433 | 1426 | ||
1434 | rc = ata_pad_alloc(ap, dev); | 1427 | rc = ata_pad_alloc(ap, dev); |
1435 | if (rc) { | 1428 | if (rc) |
1436 | kfree(pp); | ||
1437 | return rc; | 1429 | return rc; |
1438 | } | ||
1439 | 1430 | ||
1440 | mem = dma_alloc_coherent(dev, AHCI_PORT_PRIV_DMA_SZ, &mem_dma, GFP_KERNEL); | 1431 | mem = dmam_alloc_coherent(dev, AHCI_PORT_PRIV_DMA_SZ, &mem_dma, |
1441 | if (!mem) { | 1432 | GFP_KERNEL); |
1442 | ata_pad_free(ap, dev); | 1433 | if (!mem) |
1443 | kfree(pp); | ||
1444 | return -ENOMEM; | 1434 | return -ENOMEM; |
1445 | } | ||
1446 | memset(mem, 0, AHCI_PORT_PRIV_DMA_SZ); | 1435 | memset(mem, 0, AHCI_PORT_PRIV_DMA_SZ); |
1447 | 1436 | ||
1448 | /* | 1437 | /* |
@@ -1484,9 +1473,7 @@ static int ahci_port_start(struct ata_port *ap) | |||
1484 | 1473 | ||
1485 | static void ahci_port_stop(struct ata_port *ap) | 1474 | static void ahci_port_stop(struct ata_port *ap) |
1486 | { | 1475 | { |
1487 | struct device *dev = ap->host->dev; | ||
1488 | struct ahci_host_priv *hpriv = ap->host->private_data; | 1476 | struct ahci_host_priv *hpriv = ap->host->private_data; |
1489 | struct ahci_port_priv *pp = ap->private_data; | ||
1490 | void __iomem *mmio = ap->host->mmio_base; | 1477 | void __iomem *mmio = ap->host->mmio_base; |
1491 | void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no); | 1478 | void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no); |
1492 | const char *emsg = NULL; | 1479 | const char *emsg = NULL; |
@@ -1496,12 +1483,6 @@ static void ahci_port_stop(struct ata_port *ap) | |||
1496 | rc = ahci_deinit_port(port_mmio, hpriv->cap, &emsg); | 1483 | rc = ahci_deinit_port(port_mmio, hpriv->cap, &emsg); |
1497 | if (rc) | 1484 | if (rc) |
1498 | ata_port_printk(ap, KERN_WARNING, "%s (%d)\n", emsg, rc); | 1485 | ata_port_printk(ap, KERN_WARNING, "%s (%d)\n", emsg, rc); |
1499 | |||
1500 | ap->private_data = NULL; | ||
1501 | dma_free_coherent(dev, AHCI_PORT_PRIV_DMA_SZ, | ||
1502 | pp->cmd_slot, pp->cmd_slot_dma); | ||
1503 | ata_pad_free(ap, dev); | ||
1504 | kfree(pp); | ||
1505 | } | 1486 | } |
1506 | 1487 | ||
1507 | static void ahci_setup_port(struct ata_ioports *port, unsigned long base, | 1488 | static void ahci_setup_port(struct ata_ioports *port, unsigned long base, |
@@ -1669,15 +1650,15 @@ static void ahci_print_info(struct ata_probe_ent *probe_ent) | |||
1669 | ); | 1650 | ); |
1670 | } | 1651 | } |
1671 | 1652 | ||
1672 | static int ahci_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | 1653 | static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) |
1673 | { | 1654 | { |
1674 | static int printed_version; | 1655 | static int printed_version; |
1675 | struct ata_probe_ent *probe_ent = NULL; | 1656 | unsigned int board_idx = (unsigned int) ent->driver_data; |
1657 | struct device *dev = &pdev->dev; | ||
1658 | struct ata_probe_ent *probe_ent; | ||
1676 | struct ahci_host_priv *hpriv; | 1659 | struct ahci_host_priv *hpriv; |
1677 | unsigned long base; | 1660 | unsigned long base; |
1678 | void __iomem *mmio_base; | 1661 | void __iomem *mmio_base; |
1679 | unsigned int board_idx = (unsigned int) ent->driver_data; | ||
1680 | int have_msi, pci_dev_busy = 0; | ||
1681 | int rc; | 1662 | int rc; |
1682 | 1663 | ||
1683 | VPRINTK("ENTER\n"); | 1664 | VPRINTK("ENTER\n"); |
@@ -1694,46 +1675,34 @@ static int ahci_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
1694 | return -ENODEV; | 1675 | return -ENODEV; |
1695 | } | 1676 | } |
1696 | 1677 | ||
1697 | rc = pci_enable_device(pdev); | 1678 | rc = pcim_enable_device(pdev); |
1698 | if (rc) | 1679 | if (rc) |
1699 | return rc; | 1680 | return rc; |
1700 | 1681 | ||
1701 | rc = pci_request_regions(pdev, DRV_NAME); | 1682 | rc = pci_request_regions(pdev, DRV_NAME); |
1702 | if (rc) { | 1683 | if (rc) { |
1703 | pci_dev_busy = 1; | 1684 | pcim_pin_device(pdev); |
1704 | goto err_out; | 1685 | return rc; |
1705 | } | 1686 | } |
1706 | 1687 | ||
1707 | if (pci_enable_msi(pdev) == 0) | 1688 | if (pci_enable_msi(pdev)) |
1708 | have_msi = 1; | ||
1709 | else { | ||
1710 | pci_intx(pdev, 1); | 1689 | pci_intx(pdev, 1); |
1711 | have_msi = 0; | ||
1712 | } | ||
1713 | 1690 | ||
1714 | probe_ent = kmalloc(sizeof(*probe_ent), GFP_KERNEL); | 1691 | probe_ent = devm_kzalloc(dev, sizeof(*probe_ent), GFP_KERNEL); |
1715 | if (probe_ent == NULL) { | 1692 | if (probe_ent == NULL) |
1716 | rc = -ENOMEM; | 1693 | return -ENOMEM; |
1717 | goto err_out_msi; | ||
1718 | } | ||
1719 | 1694 | ||
1720 | memset(probe_ent, 0, sizeof(*probe_ent)); | ||
1721 | probe_ent->dev = pci_dev_to_dev(pdev); | 1695 | probe_ent->dev = pci_dev_to_dev(pdev); |
1722 | INIT_LIST_HEAD(&probe_ent->node); | 1696 | INIT_LIST_HEAD(&probe_ent->node); |
1723 | 1697 | ||
1724 | mmio_base = pci_iomap(pdev, AHCI_PCI_BAR, 0); | 1698 | mmio_base = pcim_iomap(pdev, AHCI_PCI_BAR, 0); |
1725 | if (mmio_base == NULL) { | 1699 | if (mmio_base == NULL) |
1726 | rc = -ENOMEM; | 1700 | return -ENOMEM; |
1727 | goto err_out_free_ent; | ||
1728 | } | ||
1729 | base = (unsigned long) mmio_base; | 1701 | base = (unsigned long) mmio_base; |
1730 | 1702 | ||
1731 | hpriv = kmalloc(sizeof(*hpriv), GFP_KERNEL); | 1703 | hpriv = devm_kzalloc(dev, sizeof(*hpriv), GFP_KERNEL); |
1732 | if (!hpriv) { | 1704 | if (!hpriv) |
1733 | rc = -ENOMEM; | 1705 | return -ENOMEM; |
1734 | goto err_out_iounmap; | ||
1735 | } | ||
1736 | memset(hpriv, 0, sizeof(*hpriv)); | ||
1737 | 1706 | ||
1738 | probe_ent->sht = ahci_port_info[board_idx].sht; | 1707 | probe_ent->sht = ahci_port_info[board_idx].sht; |
1739 | probe_ent->port_flags = ahci_port_info[board_idx].flags; | 1708 | probe_ent->port_flags = ahci_port_info[board_idx].flags; |
@@ -1746,13 +1715,10 @@ static int ahci_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
1746 | probe_ent->mmio_base = mmio_base; | 1715 | probe_ent->mmio_base = mmio_base; |
1747 | probe_ent->private_data = hpriv; | 1716 | probe_ent->private_data = hpriv; |
1748 | 1717 | ||
1749 | if (have_msi) | ||
1750 | hpriv->flags |= AHCI_FLAG_MSI; | ||
1751 | |||
1752 | /* initialize adapter */ | 1718 | /* initialize adapter */ |
1753 | rc = ahci_host_init(probe_ent); | 1719 | rc = ahci_host_init(probe_ent); |
1754 | if (rc) | 1720 | if (rc) |
1755 | goto err_out_hpriv; | 1721 | return rc; |
1756 | 1722 | ||
1757 | if (!(probe_ent->port_flags & AHCI_FLAG_NO_NCQ) && | 1723 | if (!(probe_ent->port_flags & AHCI_FLAG_NO_NCQ) && |
1758 | (hpriv->cap & HOST_CAP_NCQ)) | 1724 | (hpriv->cap & HOST_CAP_NCQ)) |
@@ -1760,48 +1726,11 @@ static int ahci_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
1760 | 1726 | ||
1761 | ahci_print_info(probe_ent); | 1727 | ahci_print_info(probe_ent); |
1762 | 1728 | ||
1763 | /* FIXME: check ata_device_add return value */ | 1729 | if (!ata_device_add(probe_ent)) |
1764 | ata_device_add(probe_ent); | 1730 | return -ENODEV; |
1765 | kfree(probe_ent); | ||
1766 | 1731 | ||
1732 | devm_kfree(dev, probe_ent); | ||
1767 | return 0; | 1733 | return 0; |
1768 | |||
1769 | err_out_hpriv: | ||
1770 | kfree(hpriv); | ||
1771 | err_out_iounmap: | ||
1772 | pci_iounmap(pdev, mmio_base); | ||
1773 | err_out_free_ent: | ||
1774 | kfree(probe_ent); | ||
1775 | err_out_msi: | ||
1776 | if (have_msi) | ||
1777 | pci_disable_msi(pdev); | ||
1778 | else | ||
1779 | pci_intx(pdev, 0); | ||
1780 | pci_release_regions(pdev); | ||
1781 | err_out: | ||
1782 | if (!pci_dev_busy) | ||
1783 | pci_disable_device(pdev); | ||
1784 | return rc; | ||
1785 | } | ||
1786 | |||
1787 | static void ahci_remove_one(struct pci_dev *pdev) | ||
1788 | { | ||
1789 | struct device *dev = pci_dev_to_dev(pdev); | ||
1790 | struct ata_host *host = dev_get_drvdata(dev); | ||
1791 | struct ahci_host_priv *hpriv = host->private_data; | ||
1792 | |||
1793 | ata_host_remove(host); | ||
1794 | |||
1795 | pci_iounmap(pdev, host->mmio_base); | ||
1796 | |||
1797 | if (hpriv->flags & AHCI_FLAG_MSI) | ||
1798 | pci_disable_msi(pdev); | ||
1799 | else | ||
1800 | pci_intx(pdev, 0); | ||
1801 | pci_release_regions(pdev); | ||
1802 | pci_disable_device(pdev); | ||
1803 | dev_set_drvdata(dev, NULL); | ||
1804 | kfree(hpriv); | ||
1805 | } | 1734 | } |
1806 | 1735 | ||
1807 | static int __init ahci_init(void) | 1736 | static int __init ahci_init(void) |
diff --git a/drivers/ata/ata_generic.c b/drivers/ata/ata_generic.c index 24af56081b5d..a25cbd653b0c 100644 --- a/drivers/ata/ata_generic.c +++ b/drivers/ata/ata_generic.c | |||
@@ -152,8 +152,6 @@ static struct ata_port_operations generic_port_ops = { | |||
152 | .irq_clear = ata_bmdma_irq_clear, | 152 | .irq_clear = ata_bmdma_irq_clear, |
153 | 153 | ||
154 | .port_start = ata_port_start, | 154 | .port_start = ata_port_start, |
155 | .port_stop = ata_port_stop, | ||
156 | .host_stop = ata_host_stop | ||
157 | }; | 155 | }; |
158 | 156 | ||
159 | static int all_generic_ide; /* Set to claim all devices */ | 157 | static int all_generic_ide; /* Set to claim all devices */ |
diff --git a/drivers/ata/ata_piix.c b/drivers/ata/ata_piix.c index f15ef88ba00c..c6bf1a338d1a 100644 --- a/drivers/ata/ata_piix.c +++ b/drivers/ata/ata_piix.c | |||
@@ -154,7 +154,6 @@ struct piix_host_priv { | |||
154 | 154 | ||
155 | static int piix_init_one (struct pci_dev *pdev, | 155 | static int piix_init_one (struct pci_dev *pdev, |
156 | const struct pci_device_id *ent); | 156 | const struct pci_device_id *ent); |
157 | static void piix_host_stop(struct ata_host *host); | ||
158 | static void piix_pata_error_handler(struct ata_port *ap); | 157 | static void piix_pata_error_handler(struct ata_port *ap); |
159 | static void ich_pata_error_handler(struct ata_port *ap); | 158 | static void ich_pata_error_handler(struct ata_port *ap); |
160 | static void piix_sata_error_handler(struct ata_port *ap); | 159 | static void piix_sata_error_handler(struct ata_port *ap); |
@@ -311,8 +310,6 @@ static const struct ata_port_operations piix_pata_ops = { | |||
311 | .irq_clear = ata_bmdma_irq_clear, | 310 | .irq_clear = ata_bmdma_irq_clear, |
312 | 311 | ||
313 | .port_start = ata_port_start, | 312 | .port_start = ata_port_start, |
314 | .port_stop = ata_port_stop, | ||
315 | .host_stop = piix_host_stop, | ||
316 | }; | 313 | }; |
317 | 314 | ||
318 | static const struct ata_port_operations ich_pata_ops = { | 315 | static const struct ata_port_operations ich_pata_ops = { |
@@ -344,8 +341,6 @@ static const struct ata_port_operations ich_pata_ops = { | |||
344 | .irq_clear = ata_bmdma_irq_clear, | 341 | .irq_clear = ata_bmdma_irq_clear, |
345 | 342 | ||
346 | .port_start = ata_port_start, | 343 | .port_start = ata_port_start, |
347 | .port_stop = ata_port_stop, | ||
348 | .host_stop = piix_host_stop, | ||
349 | }; | 344 | }; |
350 | 345 | ||
351 | static const struct ata_port_operations piix_sata_ops = { | 346 | static const struct ata_port_operations piix_sata_ops = { |
@@ -374,8 +369,6 @@ static const struct ata_port_operations piix_sata_ops = { | |||
374 | .irq_clear = ata_bmdma_irq_clear, | 369 | .irq_clear = ata_bmdma_irq_clear, |
375 | 370 | ||
376 | .port_start = ata_port_start, | 371 | .port_start = ata_port_start, |
377 | .port_stop = ata_port_stop, | ||
378 | .host_stop = piix_host_stop, | ||
379 | }; | 372 | }; |
380 | 373 | ||
381 | static const struct piix_map_db ich5_map_db = { | 374 | static const struct piix_map_db ich5_map_db = { |
@@ -1072,6 +1065,7 @@ static void __devinit piix_init_sata_map(struct pci_dev *pdev, | |||
1072 | static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | 1065 | static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) |
1073 | { | 1066 | { |
1074 | static int printed_version; | 1067 | static int printed_version; |
1068 | struct device *dev = &pdev->dev; | ||
1075 | struct ata_port_info port_info[2]; | 1069 | struct ata_port_info port_info[2]; |
1076 | struct ata_port_info *ppinfo[2] = { &port_info[0], &port_info[1] }; | 1070 | struct ata_port_info *ppinfo[2] = { &port_info[0], &port_info[1] }; |
1077 | struct piix_host_priv *hpriv; | 1071 | struct piix_host_priv *hpriv; |
@@ -1085,7 +1079,7 @@ static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
1085 | if (!in_module_init) | 1079 | if (!in_module_init) |
1086 | return -ENODEV; | 1080 | return -ENODEV; |
1087 | 1081 | ||
1088 | hpriv = kzalloc(sizeof(*hpriv), GFP_KERNEL); | 1082 | hpriv = devm_kzalloc(dev, sizeof(*hpriv), GFP_KERNEL); |
1089 | if (!hpriv) | 1083 | if (!hpriv) |
1090 | return -ENOMEM; | 1084 | return -ENOMEM; |
1091 | 1085 | ||
@@ -1135,15 +1129,6 @@ static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
1135 | return ata_pci_init_one(pdev, ppinfo, 2); | 1129 | return ata_pci_init_one(pdev, ppinfo, 2); |
1136 | } | 1130 | } |
1137 | 1131 | ||
1138 | static void piix_host_stop(struct ata_host *host) | ||
1139 | { | ||
1140 | struct piix_host_priv *hpriv = host->private_data; | ||
1141 | |||
1142 | ata_host_stop(host); | ||
1143 | |||
1144 | kfree(hpriv); | ||
1145 | } | ||
1146 | |||
1147 | static int __init piix_init(void) | 1132 | static int __init piix_init(void) |
1148 | { | 1133 | { |
1149 | int rc; | 1134 | int rc; |
diff --git a/drivers/ata/pata_ali.c b/drivers/ata/pata_ali.c index fde5ce9f7eae..f4fdb10211e3 100644 --- a/drivers/ata/pata_ali.c +++ b/drivers/ata/pata_ali.c | |||
@@ -376,8 +376,6 @@ static struct ata_port_operations ali_early_port_ops = { | |||
376 | .irq_clear = ata_bmdma_irq_clear, | 376 | .irq_clear = ata_bmdma_irq_clear, |
377 | 377 | ||
378 | .port_start = ata_port_start, | 378 | .port_start = ata_port_start, |
379 | .port_stop = ata_port_stop, | ||
380 | .host_stop = ata_host_stop | ||
381 | }; | 379 | }; |
382 | 380 | ||
383 | /* | 381 | /* |
@@ -417,8 +415,6 @@ static struct ata_port_operations ali_20_port_ops = { | |||
417 | .irq_clear = ata_bmdma_irq_clear, | 415 | .irq_clear = ata_bmdma_irq_clear, |
418 | 416 | ||
419 | .port_start = ata_port_start, | 417 | .port_start = ata_port_start, |
420 | .port_stop = ata_port_stop, | ||
421 | .host_stop = ata_host_stop | ||
422 | }; | 418 | }; |
423 | 419 | ||
424 | /* | 420 | /* |
@@ -455,8 +451,6 @@ static struct ata_port_operations ali_c2_port_ops = { | |||
455 | .irq_clear = ata_bmdma_irq_clear, | 451 | .irq_clear = ata_bmdma_irq_clear, |
456 | 452 | ||
457 | .port_start = ata_port_start, | 453 | .port_start = ata_port_start, |
458 | .port_stop = ata_port_stop, | ||
459 | .host_stop = ata_host_stop | ||
460 | }; | 454 | }; |
461 | 455 | ||
462 | /* | 456 | /* |
@@ -492,8 +486,6 @@ static struct ata_port_operations ali_c5_port_ops = { | |||
492 | .irq_clear = ata_bmdma_irq_clear, | 486 | .irq_clear = ata_bmdma_irq_clear, |
493 | 487 | ||
494 | .port_start = ata_port_start, | 488 | .port_start = ata_port_start, |
495 | .port_stop = ata_port_stop, | ||
496 | .host_stop = ata_host_stop | ||
497 | }; | 489 | }; |
498 | 490 | ||
499 | 491 | ||
diff --git a/drivers/ata/pata_amd.c b/drivers/ata/pata_amd.c index a6b330089f22..7ee0c83c657a 100644 --- a/drivers/ata/pata_amd.c +++ b/drivers/ata/pata_amd.c | |||
@@ -368,8 +368,6 @@ static struct ata_port_operations amd33_port_ops = { | |||
368 | .irq_clear = ata_bmdma_irq_clear, | 368 | .irq_clear = ata_bmdma_irq_clear, |
369 | 369 | ||
370 | .port_start = ata_port_start, | 370 | .port_start = ata_port_start, |
371 | .port_stop = ata_port_stop, | ||
372 | .host_stop = ata_host_stop | ||
373 | }; | 371 | }; |
374 | 372 | ||
375 | static struct ata_port_operations amd66_port_ops = { | 373 | static struct ata_port_operations amd66_port_ops = { |
@@ -402,8 +400,6 @@ static struct ata_port_operations amd66_port_ops = { | |||
402 | .irq_clear = ata_bmdma_irq_clear, | 400 | .irq_clear = ata_bmdma_irq_clear, |
403 | 401 | ||
404 | .port_start = ata_port_start, | 402 | .port_start = ata_port_start, |
405 | .port_stop = ata_port_stop, | ||
406 | .host_stop = ata_host_stop | ||
407 | }; | 403 | }; |
408 | 404 | ||
409 | static struct ata_port_operations amd100_port_ops = { | 405 | static struct ata_port_operations amd100_port_ops = { |
@@ -436,8 +432,6 @@ static struct ata_port_operations amd100_port_ops = { | |||
436 | .irq_clear = ata_bmdma_irq_clear, | 432 | .irq_clear = ata_bmdma_irq_clear, |
437 | 433 | ||
438 | .port_start = ata_port_start, | 434 | .port_start = ata_port_start, |
439 | .port_stop = ata_port_stop, | ||
440 | .host_stop = ata_host_stop | ||
441 | }; | 435 | }; |
442 | 436 | ||
443 | static struct ata_port_operations amd133_port_ops = { | 437 | static struct ata_port_operations amd133_port_ops = { |
@@ -470,8 +464,6 @@ static struct ata_port_operations amd133_port_ops = { | |||
470 | .irq_clear = ata_bmdma_irq_clear, | 464 | .irq_clear = ata_bmdma_irq_clear, |
471 | 465 | ||
472 | .port_start = ata_port_start, | 466 | .port_start = ata_port_start, |
473 | .port_stop = ata_port_stop, | ||
474 | .host_stop = ata_host_stop | ||
475 | }; | 467 | }; |
476 | 468 | ||
477 | static struct ata_port_operations nv100_port_ops = { | 469 | static struct ata_port_operations nv100_port_ops = { |
@@ -504,8 +496,6 @@ static struct ata_port_operations nv100_port_ops = { | |||
504 | .irq_clear = ata_bmdma_irq_clear, | 496 | .irq_clear = ata_bmdma_irq_clear, |
505 | 497 | ||
506 | .port_start = ata_port_start, | 498 | .port_start = ata_port_start, |
507 | .port_stop = ata_port_stop, | ||
508 | .host_stop = ata_host_stop | ||
509 | }; | 499 | }; |
510 | 500 | ||
511 | static struct ata_port_operations nv133_port_ops = { | 501 | static struct ata_port_operations nv133_port_ops = { |
@@ -538,8 +528,6 @@ static struct ata_port_operations nv133_port_ops = { | |||
538 | .irq_clear = ata_bmdma_irq_clear, | 528 | .irq_clear = ata_bmdma_irq_clear, |
539 | 529 | ||
540 | .port_start = ata_port_start, | 530 | .port_start = ata_port_start, |
541 | .port_stop = ata_port_stop, | ||
542 | .host_stop = ata_host_stop | ||
543 | }; | 531 | }; |
544 | 532 | ||
545 | static int amd_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | 533 | static int amd_init_one(struct pci_dev *pdev, const struct pci_device_id *id) |
diff --git a/drivers/ata/pata_artop.c b/drivers/ata/pata_artop.c index 37bc1323bda7..5baea1222227 100644 --- a/drivers/ata/pata_artop.c +++ b/drivers/ata/pata_artop.c | |||
@@ -347,8 +347,6 @@ static const struct ata_port_operations artop6210_ops = { | |||
347 | .irq_clear = ata_bmdma_irq_clear, | 347 | .irq_clear = ata_bmdma_irq_clear, |
348 | 348 | ||
349 | .port_start = ata_port_start, | 349 | .port_start = ata_port_start, |
350 | .port_stop = ata_port_stop, | ||
351 | .host_stop = ata_host_stop, | ||
352 | }; | 350 | }; |
353 | 351 | ||
354 | static const struct ata_port_operations artop6260_ops = { | 352 | static const struct ata_port_operations artop6260_ops = { |
@@ -379,8 +377,6 @@ static const struct ata_port_operations artop6260_ops = { | |||
379 | .irq_clear = ata_bmdma_irq_clear, | 377 | .irq_clear = ata_bmdma_irq_clear, |
380 | 378 | ||
381 | .port_start = ata_port_start, | 379 | .port_start = ata_port_start, |
382 | .port_stop = ata_port_stop, | ||
383 | .host_stop = ata_host_stop, | ||
384 | }; | 380 | }; |
385 | 381 | ||
386 | 382 | ||
diff --git a/drivers/ata/pata_atiixp.c b/drivers/ata/pata_atiixp.c index 504e1dbfffd7..2bfb99493a72 100644 --- a/drivers/ata/pata_atiixp.c +++ b/drivers/ata/pata_atiixp.c | |||
@@ -258,8 +258,6 @@ static struct ata_port_operations atiixp_port_ops = { | |||
258 | .irq_clear = ata_bmdma_irq_clear, | 258 | .irq_clear = ata_bmdma_irq_clear, |
259 | 259 | ||
260 | .port_start = ata_port_start, | 260 | .port_start = ata_port_start, |
261 | .port_stop = ata_port_stop, | ||
262 | .host_stop = ata_host_stop | ||
263 | }; | 261 | }; |
264 | 262 | ||
265 | static int atiixp_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 263 | static int atiixp_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
diff --git a/drivers/ata/pata_cmd64x.c b/drivers/ata/pata_cmd64x.c index 449162cbf93e..d97aa9bb0500 100644 --- a/drivers/ata/pata_cmd64x.c +++ b/drivers/ata/pata_cmd64x.c | |||
@@ -319,8 +319,6 @@ static struct ata_port_operations cmd64x_port_ops = { | |||
319 | .irq_clear = ata_bmdma_irq_clear, | 319 | .irq_clear = ata_bmdma_irq_clear, |
320 | 320 | ||
321 | .port_start = ata_port_start, | 321 | .port_start = ata_port_start, |
322 | .port_stop = ata_port_stop, | ||
323 | .host_stop = ata_host_stop | ||
324 | }; | 322 | }; |
325 | 323 | ||
326 | static struct ata_port_operations cmd646r1_port_ops = { | 324 | static struct ata_port_operations cmd646r1_port_ops = { |
@@ -353,8 +351,6 @@ static struct ata_port_operations cmd646r1_port_ops = { | |||
353 | .irq_clear = ata_bmdma_irq_clear, | 351 | .irq_clear = ata_bmdma_irq_clear, |
354 | 352 | ||
355 | .port_start = ata_port_start, | 353 | .port_start = ata_port_start, |
356 | .port_stop = ata_port_stop, | ||
357 | .host_stop = ata_host_stop | ||
358 | }; | 354 | }; |
359 | 355 | ||
360 | static struct ata_port_operations cmd648_port_ops = { | 356 | static struct ata_port_operations cmd648_port_ops = { |
@@ -387,8 +383,6 @@ static struct ata_port_operations cmd648_port_ops = { | |||
387 | .irq_clear = ata_bmdma_irq_clear, | 383 | .irq_clear = ata_bmdma_irq_clear, |
388 | 384 | ||
389 | .port_start = ata_port_start, | 385 | .port_start = ata_port_start, |
390 | .port_stop = ata_port_stop, | ||
391 | .host_stop = ata_host_stop | ||
392 | }; | 386 | }; |
393 | 387 | ||
394 | static int cmd64x_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | 388 | static int cmd64x_init_one(struct pci_dev *pdev, const struct pci_device_id *id) |
diff --git a/drivers/ata/pata_cs5520.c b/drivers/ata/pata_cs5520.c index 476b87963f5d..63bdcbe45583 100644 --- a/drivers/ata/pata_cs5520.c +++ b/drivers/ata/pata_cs5520.c | |||
@@ -199,8 +199,6 @@ static struct ata_port_operations cs5520_port_ops = { | |||
199 | .irq_clear = ata_bmdma_irq_clear, | 199 | .irq_clear = ata_bmdma_irq_clear, |
200 | 200 | ||
201 | .port_start = ata_port_start, | 201 | .port_start = ata_port_start, |
202 | .port_stop = ata_port_stop, | ||
203 | .host_stop = ata_host_stop, | ||
204 | }; | 202 | }; |
205 | 203 | ||
206 | static int __devinit cs5520_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 204 | static int __devinit cs5520_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
@@ -294,7 +292,7 @@ static void __devexit cs5520_remove_one(struct pci_dev *pdev) | |||
294 | struct device *dev = pci_dev_to_dev(pdev); | 292 | struct device *dev = pci_dev_to_dev(pdev); |
295 | struct ata_host *host = dev_get_drvdata(dev); | 293 | struct ata_host *host = dev_get_drvdata(dev); |
296 | 294 | ||
297 | ata_host_remove(host); | 295 | ata_host_detach(host); |
298 | dev_set_drvdata(dev, NULL); | 296 | dev_set_drvdata(dev, NULL); |
299 | } | 297 | } |
300 | 298 | ||
diff --git a/drivers/ata/pata_cs5530.c b/drivers/ata/pata_cs5530.c index 611d90f0d3bc..29d459be19be 100644 --- a/drivers/ata/pata_cs5530.c +++ b/drivers/ata/pata_cs5530.c | |||
@@ -216,8 +216,6 @@ static struct ata_port_operations cs5530_port_ops = { | |||
216 | .irq_clear = ata_bmdma_irq_clear, | 216 | .irq_clear = ata_bmdma_irq_clear, |
217 | 217 | ||
218 | .port_start = ata_port_start, | 218 | .port_start = ata_port_start, |
219 | .port_stop = ata_port_stop, | ||
220 | .host_stop = ata_host_stop | ||
221 | }; | 219 | }; |
222 | 220 | ||
223 | static struct dmi_system_id palmax_dmi_table[] = { | 221 | static struct dmi_system_id palmax_dmi_table[] = { |
diff --git a/drivers/ata/pata_cs5535.c b/drivers/ata/pata_cs5535.c index e3efec4ffc79..dd3958d2cff9 100644 --- a/drivers/ata/pata_cs5535.c +++ b/drivers/ata/pata_cs5535.c | |||
@@ -220,8 +220,6 @@ static struct ata_port_operations cs5535_port_ops = { | |||
220 | .irq_clear = ata_bmdma_irq_clear, | 220 | .irq_clear = ata_bmdma_irq_clear, |
221 | 221 | ||
222 | .port_start = ata_port_start, | 222 | .port_start = ata_port_start, |
223 | .port_stop = ata_port_stop, | ||
224 | .host_stop = ata_host_stop | ||
225 | }; | 223 | }; |
226 | 224 | ||
227 | /** | 225 | /** |
diff --git a/drivers/ata/pata_cypress.c b/drivers/ata/pata_cypress.c index e2a95699bae7..8479186a2373 100644 --- a/drivers/ata/pata_cypress.c +++ b/drivers/ata/pata_cypress.c | |||
@@ -171,8 +171,6 @@ static struct ata_port_operations cy82c693_port_ops = { | |||
171 | .irq_clear = ata_bmdma_irq_clear, | 171 | .irq_clear = ata_bmdma_irq_clear, |
172 | 172 | ||
173 | .port_start = ata_port_start, | 173 | .port_start = ata_port_start, |
174 | .port_stop = ata_port_stop, | ||
175 | .host_stop = ata_host_stop | ||
176 | }; | 174 | }; |
177 | 175 | ||
178 | static int cy82c693_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | 176 | static int cy82c693_init_one(struct pci_dev *pdev, const struct pci_device_id *id) |
diff --git a/drivers/ata/pata_efar.c b/drivers/ata/pata_efar.c index edf8a63f50af..66814ee64d05 100644 --- a/drivers/ata/pata_efar.c +++ b/drivers/ata/pata_efar.c | |||
@@ -267,8 +267,6 @@ static const struct ata_port_operations efar_ops = { | |||
267 | .irq_clear = ata_bmdma_irq_clear, | 267 | .irq_clear = ata_bmdma_irq_clear, |
268 | 268 | ||
269 | .port_start = ata_port_start, | 269 | .port_start = ata_port_start, |
270 | .port_stop = ata_port_stop, | ||
271 | .host_stop = ata_host_stop, | ||
272 | }; | 270 | }; |
273 | 271 | ||
274 | 272 | ||
diff --git a/drivers/ata/pata_hpt366.c b/drivers/ata/pata_hpt366.c index 2202c7ec16e3..8b826102dbd9 100644 --- a/drivers/ata/pata_hpt366.c +++ b/drivers/ata/pata_hpt366.c | |||
@@ -367,8 +367,6 @@ static struct ata_port_operations hpt366_port_ops = { | |||
367 | .irq_clear = ata_bmdma_irq_clear, | 367 | .irq_clear = ata_bmdma_irq_clear, |
368 | 368 | ||
369 | .port_start = ata_port_start, | 369 | .port_start = ata_port_start, |
370 | .port_stop = ata_port_stop, | ||
371 | .host_stop = ata_host_stop | ||
372 | }; | 370 | }; |
373 | 371 | ||
374 | /** | 372 | /** |
diff --git a/drivers/ata/pata_hpt37x.c b/drivers/ata/pata_hpt37x.c index 9e1eb473c0a1..09e8be56ba36 100644 --- a/drivers/ata/pata_hpt37x.c +++ b/drivers/ata/pata_hpt37x.c | |||
@@ -802,8 +802,6 @@ static struct ata_port_operations hpt370_port_ops = { | |||
802 | .irq_clear = ata_bmdma_irq_clear, | 802 | .irq_clear = ata_bmdma_irq_clear, |
803 | 803 | ||
804 | .port_start = ata_port_start, | 804 | .port_start = ata_port_start, |
805 | .port_stop = ata_port_stop, | ||
806 | .host_stop = ata_host_stop | ||
807 | }; | 805 | }; |
808 | 806 | ||
809 | /* | 807 | /* |
@@ -841,8 +839,6 @@ static struct ata_port_operations hpt370a_port_ops = { | |||
841 | .irq_clear = ata_bmdma_irq_clear, | 839 | .irq_clear = ata_bmdma_irq_clear, |
842 | 840 | ||
843 | .port_start = ata_port_start, | 841 | .port_start = ata_port_start, |
844 | .port_stop = ata_port_stop, | ||
845 | .host_stop = ata_host_stop | ||
846 | }; | 842 | }; |
847 | 843 | ||
848 | /* | 844 | /* |
@@ -881,8 +877,6 @@ static struct ata_port_operations hpt372_port_ops = { | |||
881 | .irq_clear = ata_bmdma_irq_clear, | 877 | .irq_clear = ata_bmdma_irq_clear, |
882 | 878 | ||
883 | .port_start = ata_port_start, | 879 | .port_start = ata_port_start, |
884 | .port_stop = ata_port_stop, | ||
885 | .host_stop = ata_host_stop | ||
886 | }; | 880 | }; |
887 | 881 | ||
888 | /* | 882 | /* |
@@ -921,8 +915,6 @@ static struct ata_port_operations hpt374_port_ops = { | |||
921 | .irq_clear = ata_bmdma_irq_clear, | 915 | .irq_clear = ata_bmdma_irq_clear, |
922 | 916 | ||
923 | .port_start = ata_port_start, | 917 | .port_start = ata_port_start, |
924 | .port_stop = ata_port_stop, | ||
925 | .host_stop = ata_host_stop | ||
926 | }; | 918 | }; |
927 | 919 | ||
928 | /** | 920 | /** |
diff --git a/drivers/ata/pata_hpt3x2n.c b/drivers/ata/pata_hpt3x2n.c index 886fab9aa62c..9f8ec576317c 100644 --- a/drivers/ata/pata_hpt3x2n.c +++ b/drivers/ata/pata_hpt3x2n.c | |||
@@ -379,8 +379,6 @@ static struct ata_port_operations hpt3x2n_port_ops = { | |||
379 | .irq_clear = ata_bmdma_irq_clear, | 379 | .irq_clear = ata_bmdma_irq_clear, |
380 | 380 | ||
381 | .port_start = ata_port_start, | 381 | .port_start = ata_port_start, |
382 | .port_stop = ata_port_stop, | ||
383 | .host_stop = ata_host_stop | ||
384 | }; | 382 | }; |
385 | 383 | ||
386 | /** | 384 | /** |
diff --git a/drivers/ata/pata_hpt3x3.c b/drivers/ata/pata_hpt3x3.c index 5caf167e26de..faa2db44ba7f 100644 --- a/drivers/ata/pata_hpt3x3.c +++ b/drivers/ata/pata_hpt3x3.c | |||
@@ -154,8 +154,6 @@ static struct ata_port_operations hpt3x3_port_ops = { | |||
154 | .irq_clear = ata_bmdma_irq_clear, | 154 | .irq_clear = ata_bmdma_irq_clear, |
155 | 155 | ||
156 | .port_start = ata_port_start, | 156 | .port_start = ata_port_start, |
157 | .port_stop = ata_port_stop, | ||
158 | .host_stop = ata_host_stop | ||
159 | }; | 157 | }; |
160 | 158 | ||
161 | /** | 159 | /** |
diff --git a/drivers/ata/pata_isapnp.c b/drivers/ata/pata_isapnp.c index a97d55ae95c9..38a42eae598e 100644 --- a/drivers/ata/pata_isapnp.c +++ b/drivers/ata/pata_isapnp.c | |||
@@ -59,8 +59,6 @@ static struct ata_port_operations isapnp_port_ops = { | |||
59 | .irq_clear = ata_bmdma_irq_clear, | 59 | .irq_clear = ata_bmdma_irq_clear, |
60 | 60 | ||
61 | .port_start = ata_port_start, | 61 | .port_start = ata_port_start, |
62 | .port_stop = ata_port_stop, | ||
63 | .host_stop = ata_host_stop | ||
64 | }; | 62 | }; |
65 | 63 | ||
66 | /** | 64 | /** |
@@ -120,7 +118,7 @@ static void isapnp_remove_one(struct pnp_dev *idev) | |||
120 | struct device *dev = &idev->dev; | 118 | struct device *dev = &idev->dev; |
121 | struct ata_host *host = dev_get_drvdata(dev); | 119 | struct ata_host *host = dev_get_drvdata(dev); |
122 | 120 | ||
123 | ata_host_remove(host); | 121 | ata_host_detach(host); |
124 | dev_set_drvdata(dev, NULL); | 122 | dev_set_drvdata(dev, NULL); |
125 | } | 123 | } |
126 | 124 | ||
diff --git a/drivers/ata/pata_it8213.c b/drivers/ata/pata_it8213.c index 7e9a41630e59..383a611b662e 100644 --- a/drivers/ata/pata_it8213.c +++ b/drivers/ata/pata_it8213.c | |||
@@ -279,8 +279,6 @@ static const struct ata_port_operations it8213_ops = { | |||
279 | .irq_clear = ata_bmdma_irq_clear, | 279 | .irq_clear = ata_bmdma_irq_clear, |
280 | 280 | ||
281 | .port_start = ata_port_start, | 281 | .port_start = ata_port_start, |
282 | .port_stop = ata_port_stop, | ||
283 | .host_stop = ata_host_stop, | ||
284 | }; | 282 | }; |
285 | 283 | ||
286 | 284 | ||
diff --git a/drivers/ata/pata_it821x.c b/drivers/ata/pata_it821x.c index 171fbd206bd5..f23365b92c0f 100644 --- a/drivers/ata/pata_it821x.c +++ b/drivers/ata/pata_it821x.c | |||
@@ -594,14 +594,10 @@ static int it821x_port_start(struct ata_port *ap) | |||
594 | if (ret < 0) | 594 | if (ret < 0) |
595 | return ret; | 595 | return ret; |
596 | 596 | ||
597 | ap->private_data = kmalloc(sizeof(struct it821x_dev), GFP_KERNEL); | 597 | itdev = devm_kzalloc(&pdev->dev, sizeof(struct it821x_dev), GFP_KERNEL); |
598 | if (ap->private_data == NULL) { | 598 | if (itdev == NULL) |
599 | ata_port_stop(ap); | ||
600 | return -ENOMEM; | 599 | return -ENOMEM; |
601 | } | 600 | ap->private_data = itdev; |
602 | |||
603 | itdev = ap->private_data; | ||
604 | memset(itdev, 0, sizeof(struct it821x_dev)); | ||
605 | 601 | ||
606 | pci_read_config_byte(pdev, 0x50, &conf); | 602 | pci_read_config_byte(pdev, 0x50, &conf); |
607 | 603 | ||
@@ -632,20 +628,6 @@ static int it821x_port_start(struct ata_port *ap) | |||
632 | return 0; | 628 | return 0; |
633 | } | 629 | } |
634 | 630 | ||
635 | /** | ||
636 | * it821x_port_stop - port shutdown | ||
637 | * @ap: ATA port being removed | ||
638 | * | ||
639 | * Release the private objects we added in it821x_port_start | ||
640 | */ | ||
641 | |||
642 | static void it821x_port_stop(struct ata_port *ap) { | ||
643 | kfree(ap->private_data); | ||
644 | ap->private_data = NULL; /* We want an OOPS if we reuse this | ||
645 | too late! */ | ||
646 | ata_port_stop(ap); | ||
647 | } | ||
648 | |||
649 | static struct scsi_host_template it821x_sht = { | 631 | static struct scsi_host_template it821x_sht = { |
650 | .module = THIS_MODULE, | 632 | .module = THIS_MODULE, |
651 | .name = DRV_NAME, | 633 | .name = DRV_NAME, |
@@ -698,8 +680,6 @@ static struct ata_port_operations it821x_smart_port_ops = { | |||
698 | .irq_clear = ata_bmdma_irq_clear, | 680 | .irq_clear = ata_bmdma_irq_clear, |
699 | 681 | ||
700 | .port_start = it821x_port_start, | 682 | .port_start = it821x_port_start, |
701 | .port_stop = it821x_port_stop, | ||
702 | .host_stop = ata_host_stop | ||
703 | }; | 683 | }; |
704 | 684 | ||
705 | static struct ata_port_operations it821x_passthru_port_ops = { | 685 | static struct ata_port_operations it821x_passthru_port_ops = { |
@@ -734,8 +714,6 @@ static struct ata_port_operations it821x_passthru_port_ops = { | |||
734 | .irq_handler = ata_interrupt, | 714 | .irq_handler = ata_interrupt, |
735 | 715 | ||
736 | .port_start = it821x_port_start, | 716 | .port_start = it821x_port_start, |
737 | .port_stop = it821x_port_stop, | ||
738 | .host_stop = ata_host_stop | ||
739 | }; | 717 | }; |
740 | 718 | ||
741 | static void __devinit it821x_disable_raid(struct pci_dev *pdev) | 719 | static void __devinit it821x_disable_raid(struct pci_dev *pdev) |
diff --git a/drivers/ata/pata_ixp4xx_cf.c b/drivers/ata/pata_ixp4xx_cf.c index 23b8aab3ebd8..230067d281e3 100644 --- a/drivers/ata/pata_ixp4xx_cf.c +++ b/drivers/ata/pata_ixp4xx_cf.c | |||
@@ -95,14 +95,6 @@ static void ixp4xx_irq_clear(struct ata_port *ap) | |||
95 | { | 95 | { |
96 | } | 96 | } |
97 | 97 | ||
98 | static void ixp4xx_host_stop (struct ata_host *host) | ||
99 | { | ||
100 | struct ixp4xx_pata_data *data = host->dev->platform_data; | ||
101 | |||
102 | iounmap(data->cs0); | ||
103 | iounmap(data->cs1); | ||
104 | } | ||
105 | |||
106 | static struct scsi_host_template ixp4xx_sht = { | 98 | static struct scsi_host_template ixp4xx_sht = { |
107 | .module = THIS_MODULE, | 99 | .module = THIS_MODULE, |
108 | .name = DRV_NAME, | 100 | .name = DRV_NAME, |
@@ -141,8 +133,6 @@ static struct ata_port_operations ixp4xx_port_ops = { | |||
141 | .irq_clear = ixp4xx_irq_clear, | 133 | .irq_clear = ixp4xx_irq_clear, |
142 | 134 | ||
143 | .port_start = ata_port_start, | 135 | .port_start = ata_port_start, |
144 | .port_stop = ata_port_stop, | ||
145 | .host_stop = ixp4xx_host_stop, | ||
146 | 136 | ||
147 | .phy_reset = ixp4xx_phy_reset, | 137 | .phy_reset = ixp4xx_phy_reset, |
148 | }; | 138 | }; |
@@ -195,8 +185,8 @@ static __devinit int ixp4xx_pata_probe(struct platform_device *pdev) | |||
195 | 185 | ||
196 | pdev->dev.coherent_dma_mask = DMA_32BIT_MASK; | 186 | pdev->dev.coherent_dma_mask = DMA_32BIT_MASK; |
197 | 187 | ||
198 | data->cs0 = ioremap(cs0->start, 0x1000); | 188 | data->cs0 = devm_ioremap(&pdev->dev, cs0->start, 0x1000); |
199 | data->cs1 = ioremap(cs1->start, 0x1000); | 189 | data->cs1 = devm_ioremap(&pdev->dev, cs1->start, 0x1000); |
200 | 190 | ||
201 | irq = platform_get_irq(pdev, 0); | 191 | irq = platform_get_irq(pdev, 0); |
202 | if (irq) | 192 | if (irq) |
@@ -238,7 +228,7 @@ static __devexit int ixp4xx_pata_remove(struct platform_device *dev) | |||
238 | { | 228 | { |
239 | struct ata_host *host = platform_get_drvdata(dev); | 229 | struct ata_host *host = platform_get_drvdata(dev); |
240 | 230 | ||
241 | ata_host_remove(host); | 231 | ata_host_detach(host); |
242 | platform_set_drvdata(dev, NULL); | 232 | platform_set_drvdata(dev, NULL); |
243 | 233 | ||
244 | return 0; | 234 | return 0; |
diff --git a/drivers/ata/pata_jmicron.c b/drivers/ata/pata_jmicron.c index aaf6787f5342..128a30958210 100644 --- a/drivers/ata/pata_jmicron.c +++ b/drivers/ata/pata_jmicron.c | |||
@@ -169,8 +169,6 @@ static const struct ata_port_operations jmicron_ops = { | |||
169 | 169 | ||
170 | /* Generic PATA PCI ATA helpers */ | 170 | /* Generic PATA PCI ATA helpers */ |
171 | .port_start = ata_port_start, | 171 | .port_start = ata_port_start, |
172 | .port_stop = ata_port_stop, | ||
173 | .host_stop = ata_host_stop, | ||
174 | }; | 172 | }; |
175 | 173 | ||
176 | 174 | ||
diff --git a/drivers/ata/pata_legacy.c b/drivers/ata/pata_legacy.c index 581cb33c6f45..9532b9bb6d2f 100644 --- a/drivers/ata/pata_legacy.c +++ b/drivers/ata/pata_legacy.c | |||
@@ -170,8 +170,6 @@ static struct ata_port_operations simple_port_ops = { | |||
170 | .irq_clear = ata_bmdma_irq_clear, | 170 | .irq_clear = ata_bmdma_irq_clear, |
171 | 171 | ||
172 | .port_start = ata_port_start, | 172 | .port_start = ata_port_start, |
173 | .port_stop = ata_port_stop, | ||
174 | .host_stop = ata_host_stop | ||
175 | }; | 173 | }; |
176 | 174 | ||
177 | static struct ata_port_operations legacy_port_ops = { | 175 | static struct ata_port_operations legacy_port_ops = { |
@@ -195,8 +193,6 @@ static struct ata_port_operations legacy_port_ops = { | |||
195 | .irq_clear = ata_bmdma_irq_clear, | 193 | .irq_clear = ata_bmdma_irq_clear, |
196 | 194 | ||
197 | .port_start = ata_port_start, | 195 | .port_start = ata_port_start, |
198 | .port_stop = ata_port_stop, | ||
199 | .host_stop = ata_host_stop | ||
200 | }; | 196 | }; |
201 | 197 | ||
202 | /* | 198 | /* |
@@ -305,8 +301,6 @@ static struct ata_port_operations pdc20230_port_ops = { | |||
305 | .irq_clear = ata_bmdma_irq_clear, | 301 | .irq_clear = ata_bmdma_irq_clear, |
306 | 302 | ||
307 | .port_start = ata_port_start, | 303 | .port_start = ata_port_start, |
308 | .port_stop = ata_port_stop, | ||
309 | .host_stop = ata_host_stop | ||
310 | }; | 304 | }; |
311 | 305 | ||
312 | /* | 306 | /* |
@@ -357,8 +351,6 @@ static struct ata_port_operations ht6560a_port_ops = { | |||
357 | .irq_clear = ata_bmdma_irq_clear, | 351 | .irq_clear = ata_bmdma_irq_clear, |
358 | 352 | ||
359 | .port_start = ata_port_start, | 353 | .port_start = ata_port_start, |
360 | .port_stop = ata_port_stop, | ||
361 | .host_stop = ata_host_stop | ||
362 | }; | 354 | }; |
363 | 355 | ||
364 | /* | 356 | /* |
@@ -420,8 +412,6 @@ static struct ata_port_operations ht6560b_port_ops = { | |||
420 | .irq_clear = ata_bmdma_irq_clear, | 412 | .irq_clear = ata_bmdma_irq_clear, |
421 | 413 | ||
422 | .port_start = ata_port_start, | 414 | .port_start = ata_port_start, |
423 | .port_stop = ata_port_stop, | ||
424 | .host_stop = ata_host_stop | ||
425 | }; | 415 | }; |
426 | 416 | ||
427 | /* | 417 | /* |
@@ -538,8 +528,6 @@ static struct ata_port_operations opti82c611a_port_ops = { | |||
538 | .irq_clear = ata_bmdma_irq_clear, | 528 | .irq_clear = ata_bmdma_irq_clear, |
539 | 529 | ||
540 | .port_start = ata_port_start, | 530 | .port_start = ata_port_start, |
541 | .port_stop = ata_port_stop, | ||
542 | .host_stop = ata_host_stop | ||
543 | }; | 531 | }; |
544 | 532 | ||
545 | /* | 533 | /* |
@@ -668,8 +656,6 @@ static struct ata_port_operations opti82c46x_port_ops = { | |||
668 | .irq_clear = ata_bmdma_irq_clear, | 656 | .irq_clear = ata_bmdma_irq_clear, |
669 | 657 | ||
670 | .port_start = ata_port_start, | 658 | .port_start = ata_port_start, |
671 | .port_stop = ata_port_stop, | ||
672 | .host_stop = ata_host_stop | ||
673 | }; | 659 | }; |
674 | 660 | ||
675 | 661 | ||
@@ -689,21 +675,19 @@ static __init int legacy_init_one(int port, unsigned long io, unsigned long ctrl | |||
689 | struct legacy_data *ld = &legacy_data[nr_legacy_host]; | 675 | struct legacy_data *ld = &legacy_data[nr_legacy_host]; |
690 | struct ata_probe_ent ae; | 676 | struct ata_probe_ent ae; |
691 | struct platform_device *pdev; | 677 | struct platform_device *pdev; |
692 | int ret = -EBUSY; | ||
693 | struct ata_port_operations *ops = &legacy_port_ops; | 678 | struct ata_port_operations *ops = &legacy_port_ops; |
694 | int pio_modes = pio_mask; | 679 | int pio_modes = pio_mask; |
695 | u32 mask = (1 << port); | 680 | u32 mask = (1 << port); |
696 | 681 | int ret; | |
697 | if (request_region(io, 8, "pata_legacy") == NULL) | ||
698 | return -EBUSY; | ||
699 | if (request_region(ctrl, 1, "pata_legacy") == NULL) | ||
700 | goto fail_io; | ||
701 | 682 | ||
702 | pdev = platform_device_register_simple(DRV_NAME, nr_legacy_host, NULL, 0); | 683 | pdev = platform_device_register_simple(DRV_NAME, nr_legacy_host, NULL, 0); |
703 | if (IS_ERR(pdev)) { | 684 | if (IS_ERR(pdev)) |
704 | ret = PTR_ERR(pdev); | 685 | return PTR_ERR(pdev); |
705 | goto fail_dev; | 686 | |
706 | } | 687 | ret = -EBUSY; |
688 | if (devm_request_region(&pdev->dev, io, 8, "pata_legacy") == NULL || | ||
689 | devm_request_region(&pdev->dev, ctrl, 1, "pata_legacy") == NULL) | ||
690 | goto fail; | ||
707 | 691 | ||
708 | if (ht6560a & mask) { | 692 | if (ht6560a & mask) { |
709 | ops = &ht6560a_port_ops; | 693 | ops = &ht6560a_port_ops; |
@@ -776,21 +760,16 @@ static __init int legacy_init_one(int port, unsigned long io, unsigned long ctrl | |||
776 | ata_std_ports(&ae.port[0]); | 760 | ata_std_ports(&ae.port[0]); |
777 | ae.private_data = ld; | 761 | ae.private_data = ld; |
778 | 762 | ||
779 | ret = ata_device_add(&ae); | 763 | ret = -ENODEV; |
780 | if (ret == 0) { | 764 | if (!ata_device_add(&ae)) |
781 | ret = -ENODEV; | ||
782 | goto fail; | 765 | goto fail; |
783 | } | 766 | |
784 | legacy_host[nr_legacy_host++] = dev_get_drvdata(&pdev->dev); | 767 | legacy_host[nr_legacy_host++] = dev_get_drvdata(&pdev->dev); |
785 | ld->platform_dev = pdev; | 768 | ld->platform_dev = pdev; |
786 | return 0; | 769 | return 0; |
787 | 770 | ||
788 | fail: | 771 | fail: |
789 | platform_device_unregister(pdev); | 772 | platform_device_unregister(pdev); |
790 | fail_dev: | ||
791 | release_region(ctrl, 1); | ||
792 | fail_io: | ||
793 | release_region(io, 8); | ||
794 | return ret; | 773 | return ret; |
795 | } | 774 | } |
796 | 775 | ||
@@ -923,15 +902,11 @@ static __exit void legacy_exit(void) | |||
923 | 902 | ||
924 | for (i = 0; i < nr_legacy_host; i++) { | 903 | for (i = 0; i < nr_legacy_host; i++) { |
925 | struct legacy_data *ld = &legacy_data[i]; | 904 | struct legacy_data *ld = &legacy_data[i]; |
926 | struct ata_port *ap =legacy_host[i]->ports[0]; | 905 | |
927 | unsigned long io = ap->ioaddr.cmd_addr; | 906 | ata_host_detach(legacy_host[i]); |
928 | unsigned long ctrl = ap->ioaddr.ctl_addr; | ||
929 | ata_host_remove(legacy_host[i]); | ||
930 | platform_device_unregister(ld->platform_dev); | 907 | platform_device_unregister(ld->platform_dev); |
931 | if (ld->timing) | 908 | if (ld->timing) |
932 | release_region(ld->timing, 2); | 909 | release_region(ld->timing, 2); |
933 | release_region(io, 8); | ||
934 | release_region(ctrl, 1); | ||
935 | } | 910 | } |
936 | } | 911 | } |
937 | 912 | ||
diff --git a/drivers/ata/pata_marvell.c b/drivers/ata/pata_marvell.c index af93533551ac..0a4409546a02 100644 --- a/drivers/ata/pata_marvell.c +++ b/drivers/ata/pata_marvell.c | |||
@@ -137,8 +137,6 @@ static const struct ata_port_operations marvell_ops = { | |||
137 | 137 | ||
138 | /* Generic PATA PCI ATA helpers */ | 138 | /* Generic PATA PCI ATA helpers */ |
139 | .port_start = ata_port_start, | 139 | .port_start = ata_port_start, |
140 | .port_stop = ata_port_stop, | ||
141 | .host_stop = ata_host_stop, | ||
142 | }; | 140 | }; |
143 | 141 | ||
144 | 142 | ||
diff --git a/drivers/ata/pata_mpc52xx.c b/drivers/ata/pata_mpc52xx.c index 8b7019a2f190..5320ea854365 100644 --- a/drivers/ata/pata_mpc52xx.c +++ b/drivers/ata/pata_mpc52xx.c | |||
@@ -17,7 +17,6 @@ | |||
17 | #include <linux/delay.h> | 17 | #include <linux/delay.h> |
18 | #include <linux/libata.h> | 18 | #include <linux/libata.h> |
19 | 19 | ||
20 | #include <asm/io.h> | ||
21 | #include <asm/types.h> | 20 | #include <asm/types.h> |
22 | #include <asm/prom.h> | 21 | #include <asm/prom.h> |
23 | #include <asm/of_platform.h> | 22 | #include <asm/of_platform.h> |
@@ -300,8 +299,6 @@ static struct ata_port_operations mpc52xx_ata_port_ops = { | |||
300 | .irq_handler = ata_interrupt, | 299 | .irq_handler = ata_interrupt, |
301 | .irq_clear = ata_bmdma_irq_clear, | 300 | .irq_clear = ata_bmdma_irq_clear, |
302 | .port_start = ata_port_start, | 301 | .port_start = ata_port_start, |
303 | .port_stop = ata_port_stop, | ||
304 | .host_stop = ata_host_stop, | ||
305 | }; | 302 | }; |
306 | 303 | ||
307 | static struct ata_probe_ent mpc52xx_ata_probe_ent = { | 304 | static struct ata_probe_ent mpc52xx_ata_probe_ent = { |
@@ -353,7 +350,7 @@ mpc52xx_ata_remove_one(struct device *dev) | |||
353 | struct ata_host *host = dev_get_drvdata(dev); | 350 | struct ata_host *host = dev_get_drvdata(dev); |
354 | struct mpc52xx_ata_priv *priv = host->private_data; | 351 | struct mpc52xx_ata_priv *priv = host->private_data; |
355 | 352 | ||
356 | ata_host_remove(host); | 353 | ata_host_detach(host); |
357 | 354 | ||
358 | return priv; | 355 | return priv; |
359 | } | 356 | } |
@@ -369,8 +366,8 @@ mpc52xx_ata_probe(struct of_device *op, const struct of_device_id *match) | |||
369 | unsigned int ipb_freq; | 366 | unsigned int ipb_freq; |
370 | struct resource res_mem; | 367 | struct resource res_mem; |
371 | int ata_irq = NO_IRQ; | 368 | int ata_irq = NO_IRQ; |
372 | struct mpc52xx_ata __iomem *ata_regs = NULL; | 369 | struct mpc52xx_ata __iomem *ata_regs; |
373 | struct mpc52xx_ata_priv *priv = NULL; | 370 | struct mpc52xx_ata_priv *priv; |
374 | int rv; | 371 | int rv; |
375 | 372 | ||
376 | /* Get ipb frequency */ | 373 | /* Get ipb frequency */ |
@@ -397,16 +394,17 @@ mpc52xx_ata_probe(struct of_device *op, const struct of_device_id *match) | |||
397 | } | 394 | } |
398 | 395 | ||
399 | /* Request mem region */ | 396 | /* Request mem region */ |
400 | if (!request_mem_region(res_mem.start, | 397 | if (!devm_request_mem_region(&op->dev, res_mem.start, |
401 | sizeof(struct mpc52xx_ata), DRV_NAME)) { | 398 | sizeof(struct mpc52xx_ata), DRV_NAME)) { |
402 | printk(KERN_ERR DRV_NAME ": " | 399 | printk(KERN_ERR DRV_NAME ": " |
403 | "Error while requesting mem region\n"); | 400 | "Error while requesting mem region\n"); |
404 | irq_dispose_mapping(ata_irq); | 401 | rv = -EBUSY; |
405 | return -EBUSY; | 402 | goto err; |
406 | } | 403 | } |
407 | 404 | ||
408 | /* Remap registers */ | 405 | /* Remap registers */ |
409 | ata_regs = ioremap(res_mem.start, sizeof(struct mpc52xx_ata)); | 406 | ata_regs = devm_ioremap(&op->dev, res_mem.start, |
407 | sizeof(struct mpc52xx_ata)); | ||
410 | if (!ata_regs) { | 408 | if (!ata_regs) { |
411 | printk(KERN_ERR DRV_NAME ": " | 409 | printk(KERN_ERR DRV_NAME ": " |
412 | "Error while mapping register set\n"); | 410 | "Error while mapping register set\n"); |
@@ -415,7 +413,8 @@ mpc52xx_ata_probe(struct of_device *op, const struct of_device_id *match) | |||
415 | } | 413 | } |
416 | 414 | ||
417 | /* Prepare our private structure */ | 415 | /* Prepare our private structure */ |
418 | priv = kmalloc(sizeof(struct mpc52xx_ata_priv), GFP_ATOMIC); | 416 | priv = devm_kzalloc(&op->dev, sizeof(struct mpc52xx_ata_priv), |
417 | GFP_ATOMIC); | ||
419 | if (!priv) { | 418 | if (!priv) { |
420 | printk(KERN_ERR DRV_NAME ": " | 419 | printk(KERN_ERR DRV_NAME ": " |
421 | "Error while allocating private structure\n"); | 420 | "Error while allocating private structure\n"); |
@@ -448,15 +447,7 @@ mpc52xx_ata_probe(struct of_device *op, const struct of_device_id *match) | |||
448 | 447 | ||
449 | /* Error path */ | 448 | /* Error path */ |
450 | err: | 449 | err: |
451 | kfree(priv); | ||
452 | |||
453 | if (ata_regs) | ||
454 | iounmap(ata_regs); | ||
455 | |||
456 | release_mem_region(res_mem.start, sizeof(struct mpc52xx_ata)); | ||
457 | |||
458 | irq_dispose_mapping(ata_irq); | 450 | irq_dispose_mapping(ata_irq); |
459 | |||
460 | return rv; | 451 | return rv; |
461 | } | 452 | } |
462 | 453 | ||
@@ -464,28 +455,10 @@ static int | |||
464 | mpc52xx_ata_remove(struct of_device *op) | 455 | mpc52xx_ata_remove(struct of_device *op) |
465 | { | 456 | { |
466 | struct mpc52xx_ata_priv *priv; | 457 | struct mpc52xx_ata_priv *priv; |
467 | struct resource res_mem; | ||
468 | int rv; | ||
469 | 458 | ||
470 | /* Unregister */ | ||
471 | priv = mpc52xx_ata_remove_one(&op->dev); | 459 | priv = mpc52xx_ata_remove_one(&op->dev); |
472 | |||
473 | /* Free everything */ | ||
474 | iounmap(priv->ata_regs); | ||
475 | |||
476 | rv = of_address_to_resource(op->node, 0, &res_mem); | ||
477 | if (rv) { | ||
478 | printk(KERN_ERR DRV_NAME ": " | ||
479 | "Error while parsing device node resource\n"); | ||
480 | printk(KERN_ERR DRV_NAME ": " | ||
481 | "Zone may not be properly released\n"); | ||
482 | } else | ||
483 | release_mem_region(res_mem.start, sizeof(struct mpc52xx_ata)); | ||
484 | |||
485 | irq_dispose_mapping(priv->ata_irq); | 460 | irq_dispose_mapping(priv->ata_irq); |
486 | 461 | ||
487 | kfree(priv); | ||
488 | |||
489 | return 0; | 462 | return 0; |
490 | } | 463 | } |
491 | 464 | ||
diff --git a/drivers/ata/pata_mpiix.c b/drivers/ata/pata_mpiix.c index 4ccca938675e..c4a1b10f3bca 100644 --- a/drivers/ata/pata_mpiix.c +++ b/drivers/ata/pata_mpiix.c | |||
@@ -194,8 +194,6 @@ static struct ata_port_operations mpiix_port_ops = { | |||
194 | .irq_clear = ata_bmdma_irq_clear, | 194 | .irq_clear = ata_bmdma_irq_clear, |
195 | 195 | ||
196 | .port_start = ata_port_start, | 196 | .port_start = ata_port_start, |
197 | .port_stop = ata_port_stop, | ||
198 | .host_stop = ata_host_stop | ||
199 | }; | 197 | }; |
200 | 198 | ||
201 | static int mpiix_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 199 | static int mpiix_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
@@ -258,24 +256,6 @@ static int mpiix_init_one(struct pci_dev *dev, const struct pci_device_id *id) | |||
258 | return -ENODEV; | 256 | return -ENODEV; |
259 | } | 257 | } |
260 | 258 | ||
261 | /** | ||
262 | * mpiix_remove_one - device unload | ||
263 | * @pdev: PCI device being removed | ||
264 | * | ||
265 | * Handle an unplug/unload event for a PCI device. Unload the | ||
266 | * PCI driver but do not use the default handler as we *MUST NOT* | ||
267 | * disable the device as it has other functions. | ||
268 | */ | ||
269 | |||
270 | static void __devexit mpiix_remove_one(struct pci_dev *pdev) | ||
271 | { | ||
272 | struct device *dev = pci_dev_to_dev(pdev); | ||
273 | struct ata_host *host = dev_get_drvdata(dev); | ||
274 | |||
275 | ata_host_remove(host); | ||
276 | dev_set_drvdata(dev, NULL); | ||
277 | } | ||
278 | |||
279 | static const struct pci_device_id mpiix[] = { | 259 | static const struct pci_device_id mpiix[] = { |
280 | { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82371MX), }, | 260 | { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82371MX), }, |
281 | 261 | ||
@@ -286,7 +266,7 @@ static struct pci_driver mpiix_pci_driver = { | |||
286 | .name = DRV_NAME, | 266 | .name = DRV_NAME, |
287 | .id_table = mpiix, | 267 | .id_table = mpiix, |
288 | .probe = mpiix_init_one, | 268 | .probe = mpiix_init_one, |
289 | .remove = mpiix_remove_one, | 269 | .remove = ata_pci_remove_one, |
290 | .suspend = ata_pci_device_suspend, | 270 | .suspend = ata_pci_device_suspend, |
291 | .resume = ata_pci_device_resume, | 271 | .resume = ata_pci_device_resume, |
292 | }; | 272 | }; |
diff --git a/drivers/ata/pata_netcell.c b/drivers/ata/pata_netcell.c index cf7fe037471c..2a2f8df70582 100644 --- a/drivers/ata/pata_netcell.c +++ b/drivers/ata/pata_netcell.c | |||
@@ -97,8 +97,6 @@ static const struct ata_port_operations netcell_ops = { | |||
97 | 97 | ||
98 | /* Generic PATA PCI ATA helpers */ | 98 | /* Generic PATA PCI ATA helpers */ |
99 | .port_start = ata_port_start, | 99 | .port_start = ata_port_start, |
100 | .port_stop = ata_port_stop, | ||
101 | .host_stop = ata_host_stop, | ||
102 | }; | 100 | }; |
103 | 101 | ||
104 | 102 | ||
diff --git a/drivers/ata/pata_ns87410.c b/drivers/ata/pata_ns87410.c index c3032eb9010d..fdafd92c92a9 100644 --- a/drivers/ata/pata_ns87410.c +++ b/drivers/ata/pata_ns87410.c | |||
@@ -185,8 +185,6 @@ static struct ata_port_operations ns87410_port_ops = { | |||
185 | .irq_clear = ata_bmdma_irq_clear, | 185 | .irq_clear = ata_bmdma_irq_clear, |
186 | 186 | ||
187 | .port_start = ata_port_start, | 187 | .port_start = ata_port_start, |
188 | .port_stop = ata_port_stop, | ||
189 | .host_stop = ata_host_stop | ||
190 | }; | 188 | }; |
191 | 189 | ||
192 | static int ns87410_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 190 | static int ns87410_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
diff --git a/drivers/ata/pata_oldpiix.c b/drivers/ata/pata_oldpiix.c index 10ac3cc10181..df9f7fd4b4e5 100644 --- a/drivers/ata/pata_oldpiix.c +++ b/drivers/ata/pata_oldpiix.c | |||
@@ -265,8 +265,6 @@ static const struct ata_port_operations oldpiix_pata_ops = { | |||
265 | .irq_clear = ata_bmdma_irq_clear, | 265 | .irq_clear = ata_bmdma_irq_clear, |
266 | 266 | ||
267 | .port_start = ata_port_start, | 267 | .port_start = ata_port_start, |
268 | .port_stop = ata_port_stop, | ||
269 | .host_stop = ata_host_stop, | ||
270 | }; | 268 | }; |
271 | 269 | ||
272 | 270 | ||
diff --git a/drivers/ata/pata_opti.c b/drivers/ata/pata_opti.c index c2988b0aa8ea..58951ccd1e4d 100644 --- a/drivers/ata/pata_opti.c +++ b/drivers/ata/pata_opti.c | |||
@@ -211,8 +211,6 @@ static struct ata_port_operations opti_port_ops = { | |||
211 | .irq_clear = ata_bmdma_irq_clear, | 211 | .irq_clear = ata_bmdma_irq_clear, |
212 | 212 | ||
213 | .port_start = ata_port_start, | 213 | .port_start = ata_port_start, |
214 | .port_stop = ata_port_stop, | ||
215 | .host_stop = ata_host_stop | ||
216 | }; | 214 | }; |
217 | 215 | ||
218 | static int opti_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 216 | static int opti_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
diff --git a/drivers/ata/pata_optidma.c b/drivers/ata/pata_optidma.c index 80d111c569dc..74d2e7a28da0 100644 --- a/drivers/ata/pata_optidma.c +++ b/drivers/ata/pata_optidma.c | |||
@@ -395,8 +395,6 @@ static struct ata_port_operations optidma_port_ops = { | |||
395 | .irq_clear = ata_bmdma_irq_clear, | 395 | .irq_clear = ata_bmdma_irq_clear, |
396 | 396 | ||
397 | .port_start = ata_port_start, | 397 | .port_start = ata_port_start, |
398 | .port_stop = ata_port_stop, | ||
399 | .host_stop = ata_host_stop | ||
400 | }; | 398 | }; |
401 | 399 | ||
402 | static struct ata_port_operations optiplus_port_ops = { | 400 | static struct ata_port_operations optiplus_port_ops = { |
@@ -430,8 +428,6 @@ static struct ata_port_operations optiplus_port_ops = { | |||
430 | .irq_clear = ata_bmdma_irq_clear, | 428 | .irq_clear = ata_bmdma_irq_clear, |
431 | 429 | ||
432 | .port_start = ata_port_start, | 430 | .port_start = ata_port_start, |
433 | .port_stop = ata_port_stop, | ||
434 | .host_stop = ata_host_stop | ||
435 | }; | 431 | }; |
436 | 432 | ||
437 | /** | 433 | /** |
diff --git a/drivers/ata/pata_pcmcia.c b/drivers/ata/pata_pcmcia.c index 9ed7f58424a3..5a9b24950f99 100644 --- a/drivers/ata/pata_pcmcia.c +++ b/drivers/ata/pata_pcmcia.c | |||
@@ -94,8 +94,6 @@ static struct ata_port_operations pcmcia_port_ops = { | |||
94 | .irq_clear = ata_bmdma_irq_clear, | 94 | .irq_clear = ata_bmdma_irq_clear, |
95 | 95 | ||
96 | .port_start = ata_port_start, | 96 | .port_start = ata_port_start, |
97 | .port_stop = ata_port_stop, | ||
98 | .host_stop = ata_host_stop | ||
99 | }; | 97 | }; |
100 | 98 | ||
101 | #define CS_CHECK(fn, ret) \ | 99 | #define CS_CHECK(fn, ret) \ |
@@ -298,7 +296,7 @@ static void pcmcia_remove_one(struct pcmcia_device *pdev) | |||
298 | /* If we have attached the device to the ATA layer, detach it */ | 296 | /* If we have attached the device to the ATA layer, detach it */ |
299 | if (info->ndev) { | 297 | if (info->ndev) { |
300 | struct ata_host *host = dev_get_drvdata(dev); | 298 | struct ata_host *host = dev_get_drvdata(dev); |
301 | ata_host_remove(host); | 299 | ata_host_detach(host); |
302 | dev_set_drvdata(dev, NULL); | 300 | dev_set_drvdata(dev, NULL); |
303 | } | 301 | } |
304 | info->ndev = 0; | 302 | info->ndev = 0; |
diff --git a/drivers/ata/pata_pdc2027x.c b/drivers/ata/pata_pdc2027x.c index 76dd1c935dbd..1c106b866c79 100644 --- a/drivers/ata/pata_pdc2027x.c +++ b/drivers/ata/pata_pdc2027x.c | |||
@@ -33,7 +33,6 @@ | |||
33 | #include <scsi/scsi_host.h> | 33 | #include <scsi/scsi_host.h> |
34 | #include <scsi/scsi_cmnd.h> | 34 | #include <scsi/scsi_cmnd.h> |
35 | #include <linux/libata.h> | 35 | #include <linux/libata.h> |
36 | #include <asm/io.h> | ||
37 | 36 | ||
38 | #define DRV_NAME "pata_pdc2027x" | 37 | #define DRV_NAME "pata_pdc2027x" |
39 | #define DRV_VERSION "0.74-ac5" | 38 | #define DRV_VERSION "0.74-ac5" |
@@ -62,7 +61,6 @@ enum { | |||
62 | }; | 61 | }; |
63 | 62 | ||
64 | static int pdc2027x_init_one(struct pci_dev *pdev, const struct pci_device_id *ent); | 63 | static int pdc2027x_init_one(struct pci_dev *pdev, const struct pci_device_id *ent); |
65 | static void pdc2027x_remove_one(struct pci_dev *pdev); | ||
66 | static void pdc2027x_error_handler(struct ata_port *ap); | 64 | static void pdc2027x_error_handler(struct ata_port *ap); |
67 | static void pdc2027x_set_piomode(struct ata_port *ap, struct ata_device *adev); | 65 | static void pdc2027x_set_piomode(struct ata_port *ap, struct ata_device *adev); |
68 | static void pdc2027x_set_dmamode(struct ata_port *ap, struct ata_device *adev); | 66 | static void pdc2027x_set_dmamode(struct ata_port *ap, struct ata_device *adev); |
@@ -123,7 +121,7 @@ static struct pci_driver pdc2027x_pci_driver = { | |||
123 | .name = DRV_NAME, | 121 | .name = DRV_NAME, |
124 | .id_table = pdc2027x_pci_tbl, | 122 | .id_table = pdc2027x_pci_tbl, |
125 | .probe = pdc2027x_init_one, | 123 | .probe = pdc2027x_init_one, |
126 | .remove = __devexit_p(pdc2027x_remove_one), | 124 | .remove = ata_pci_remove_one, |
127 | }; | 125 | }; |
128 | 126 | ||
129 | static struct scsi_host_template pdc2027x_sht = { | 127 | static struct scsi_host_template pdc2027x_sht = { |
@@ -171,8 +169,6 @@ static struct ata_port_operations pdc2027x_pata100_ops = { | |||
171 | .irq_clear = ata_bmdma_irq_clear, | 169 | .irq_clear = ata_bmdma_irq_clear, |
172 | 170 | ||
173 | .port_start = ata_port_start, | 171 | .port_start = ata_port_start, |
174 | .port_stop = ata_port_stop, | ||
175 | .host_stop = ata_pci_host_stop, | ||
176 | }; | 172 | }; |
177 | 173 | ||
178 | static struct ata_port_operations pdc2027x_pata133_ops = { | 174 | static struct ata_port_operations pdc2027x_pata133_ops = { |
@@ -205,8 +201,6 @@ static struct ata_port_operations pdc2027x_pata133_ops = { | |||
205 | .irq_clear = ata_bmdma_irq_clear, | 201 | .irq_clear = ata_bmdma_irq_clear, |
206 | 202 | ||
207 | .port_start = ata_port_start, | 203 | .port_start = ata_port_start, |
208 | .port_stop = ata_port_stop, | ||
209 | .host_stop = ata_pci_host_stop, | ||
210 | }; | 204 | }; |
211 | 205 | ||
212 | static struct ata_port_info pdc2027x_port_info[] = { | 206 | static struct ata_port_info pdc2027x_port_info[] = { |
@@ -755,7 +749,7 @@ static int __devinit pdc2027x_init_one(struct pci_dev *pdev, const struct pci_de | |||
755 | static int printed_version; | 749 | static int printed_version; |
756 | unsigned int board_idx = (unsigned int) ent->driver_data; | 750 | unsigned int board_idx = (unsigned int) ent->driver_data; |
757 | 751 | ||
758 | struct ata_probe_ent *probe_ent = NULL; | 752 | struct ata_probe_ent *probe_ent; |
759 | unsigned long base; | 753 | unsigned long base; |
760 | void __iomem *mmio_base; | 754 | void __iomem *mmio_base; |
761 | int rc; | 755 | int rc; |
@@ -763,37 +757,33 @@ static int __devinit pdc2027x_init_one(struct pci_dev *pdev, const struct pci_de | |||
763 | if (!printed_version++) | 757 | if (!printed_version++) |
764 | dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); | 758 | dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); |
765 | 759 | ||
766 | rc = pci_enable_device(pdev); | 760 | rc = pcim_enable_device(pdev); |
767 | if (rc) | 761 | if (rc) |
768 | return rc; | 762 | return rc; |
769 | 763 | ||
770 | rc = pci_request_regions(pdev, DRV_NAME); | 764 | rc = pci_request_regions(pdev, DRV_NAME); |
771 | if (rc) | 765 | if (rc) |
772 | goto err_out; | 766 | return rc; |
773 | 767 | ||
774 | rc = pci_set_dma_mask(pdev, ATA_DMA_MASK); | 768 | rc = pci_set_dma_mask(pdev, ATA_DMA_MASK); |
775 | if (rc) | 769 | if (rc) |
776 | goto err_out_regions; | 770 | return rc; |
777 | 771 | ||
778 | rc = pci_set_consistent_dma_mask(pdev, ATA_DMA_MASK); | 772 | rc = pci_set_consistent_dma_mask(pdev, ATA_DMA_MASK); |
779 | if (rc) | 773 | if (rc) |
780 | goto err_out_regions; | 774 | return rc; |
781 | 775 | ||
782 | /* Prepare the probe entry */ | 776 | /* Prepare the probe entry */ |
783 | probe_ent = kzalloc(sizeof(*probe_ent), GFP_KERNEL); | 777 | probe_ent = devm_kzalloc(&pdev->dev, sizeof(*probe_ent), GFP_KERNEL); |
784 | if (probe_ent == NULL) { | 778 | if (probe_ent == NULL) |
785 | rc = -ENOMEM; | 779 | return -ENOMEM; |
786 | goto err_out_regions; | ||
787 | } | ||
788 | 780 | ||
789 | probe_ent->dev = pci_dev_to_dev(pdev); | 781 | probe_ent->dev = pci_dev_to_dev(pdev); |
790 | INIT_LIST_HEAD(&probe_ent->node); | 782 | INIT_LIST_HEAD(&probe_ent->node); |
791 | 783 | ||
792 | mmio_base = pci_iomap(pdev, 5, 0); | 784 | mmio_base = pcim_iomap(pdev, 5, 0); |
793 | if (!mmio_base) { | 785 | if (!mmio_base) |
794 | rc = -ENOMEM; | 786 | return -ENOMEM; |
795 | goto err_out_free_ent; | ||
796 | } | ||
797 | 787 | ||
798 | base = (unsigned long) mmio_base; | 788 | base = (unsigned long) mmio_base; |
799 | 789 | ||
@@ -820,32 +810,13 @@ static int __devinit pdc2027x_init_one(struct pci_dev *pdev, const struct pci_de | |||
820 | 810 | ||
821 | /* initialize adapter */ | 811 | /* initialize adapter */ |
822 | if (pdc_hardware_init(pdev, probe_ent, board_idx) != 0) | 812 | if (pdc_hardware_init(pdev, probe_ent, board_idx) != 0) |
823 | goto err_out_free_ent; | 813 | return -EIO; |
824 | 814 | ||
825 | ata_device_add(probe_ent); | 815 | if (!ata_device_add(probe_ent)) |
826 | kfree(probe_ent); | 816 | return -ENODEV; |
827 | 817 | ||
818 | devm_kfree(&pdev->dev, probe_ent); | ||
828 | return 0; | 819 | return 0; |
829 | |||
830 | err_out_free_ent: | ||
831 | kfree(probe_ent); | ||
832 | err_out_regions: | ||
833 | pci_release_regions(pdev); | ||
834 | err_out: | ||
835 | pci_disable_device(pdev); | ||
836 | return rc; | ||
837 | } | ||
838 | |||
839 | /** | ||
840 | * pdc2027x_remove_one - Called to remove a single instance of the | ||
841 | * adapter. | ||
842 | * | ||
843 | * @dev: The PCI device to remove. | ||
844 | * FIXME: module load/unload not working yet | ||
845 | */ | ||
846 | static void __devexit pdc2027x_remove_one(struct pci_dev *pdev) | ||
847 | { | ||
848 | ata_pci_remove_one(pdev); | ||
849 | } | 820 | } |
850 | 821 | ||
851 | /** | 822 | /** |
diff --git a/drivers/ata/pata_pdc202xx_old.c b/drivers/ata/pata_pdc202xx_old.c index ba982ba68ad5..c52e1e8aa2d2 100644 --- a/drivers/ata/pata_pdc202xx_old.c +++ b/drivers/ata/pata_pdc202xx_old.c | |||
@@ -300,8 +300,6 @@ static struct ata_port_operations pdc2024x_port_ops = { | |||
300 | .irq_clear = ata_bmdma_irq_clear, | 300 | .irq_clear = ata_bmdma_irq_clear, |
301 | 301 | ||
302 | .port_start = ata_port_start, | 302 | .port_start = ata_port_start, |
303 | .port_stop = ata_port_stop, | ||
304 | .host_stop = ata_host_stop | ||
305 | }; | 303 | }; |
306 | 304 | ||
307 | static struct ata_port_operations pdc2026x_port_ops = { | 305 | static struct ata_port_operations pdc2026x_port_ops = { |
@@ -334,8 +332,6 @@ static struct ata_port_operations pdc2026x_port_ops = { | |||
334 | .irq_clear = ata_bmdma_irq_clear, | 332 | .irq_clear = ata_bmdma_irq_clear, |
335 | 333 | ||
336 | .port_start = ata_port_start, | 334 | .port_start = ata_port_start, |
337 | .port_stop = ata_port_stop, | ||
338 | .host_stop = ata_host_stop | ||
339 | }; | 335 | }; |
340 | 336 | ||
341 | static int pdc202xx_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 337 | static int pdc202xx_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
diff --git a/drivers/ata/pata_qdi.c b/drivers/ata/pata_qdi.c index afc0d990e7d6..4413960042a9 100644 --- a/drivers/ata/pata_qdi.c +++ b/drivers/ata/pata_qdi.c | |||
@@ -191,8 +191,6 @@ static struct ata_port_operations qdi6500_port_ops = { | |||
191 | .irq_clear = ata_bmdma_irq_clear, | 191 | .irq_clear = ata_bmdma_irq_clear, |
192 | 192 | ||
193 | .port_start = ata_port_start, | 193 | .port_start = ata_port_start, |
194 | .port_stop = ata_port_stop, | ||
195 | .host_stop = ata_host_stop | ||
196 | }; | 194 | }; |
197 | 195 | ||
198 | static struct ata_port_operations qdi6580_port_ops = { | 196 | static struct ata_port_operations qdi6580_port_ops = { |
@@ -219,8 +217,6 @@ static struct ata_port_operations qdi6580_port_ops = { | |||
219 | .irq_clear = ata_bmdma_irq_clear, | 217 | .irq_clear = ata_bmdma_irq_clear, |
220 | 218 | ||
221 | .port_start = ata_port_start, | 219 | .port_start = ata_port_start, |
222 | .port_stop = ata_port_stop, | ||
223 | .host_stop = ata_host_stop | ||
224 | }; | 220 | }; |
225 | 221 | ||
226 | /** | 222 | /** |
@@ -382,7 +378,7 @@ static __exit void qdi_exit(void) | |||
382 | int i; | 378 | int i; |
383 | 379 | ||
384 | for (i = 0; i < nr_qdi_host; i++) { | 380 | for (i = 0; i < nr_qdi_host; i++) { |
385 | ata_host_remove(qdi_host[i]); | 381 | ata_host_detach(qdi_host[i]); |
386 | /* Free the control resource. The 6580 dual channel has the resources | 382 | /* Free the control resource. The 6580 dual channel has the resources |
387 | * claimed as a pair of 2 byte resources so we need no special cases... | 383 | * claimed as a pair of 2 byte resources so we need no special cases... |
388 | */ | 384 | */ |
diff --git a/drivers/ata/pata_radisys.c b/drivers/ata/pata_radisys.c index 065541d034ad..ca9c97056c1b 100644 --- a/drivers/ata/pata_radisys.c +++ b/drivers/ata/pata_radisys.c | |||
@@ -261,8 +261,6 @@ static const struct ata_port_operations radisys_pata_ops = { | |||
261 | .irq_clear = ata_bmdma_irq_clear, | 261 | .irq_clear = ata_bmdma_irq_clear, |
262 | 262 | ||
263 | .port_start = ata_port_start, | 263 | .port_start = ata_port_start, |
264 | .port_stop = ata_port_stop, | ||
265 | .host_stop = ata_host_stop, | ||
266 | }; | 264 | }; |
267 | 265 | ||
268 | 266 | ||
diff --git a/drivers/ata/pata_rz1000.c b/drivers/ata/pata_rz1000.c index cec0729225e1..c99331bbbdd9 100644 --- a/drivers/ata/pata_rz1000.c +++ b/drivers/ata/pata_rz1000.c | |||
@@ -126,8 +126,6 @@ static struct ata_port_operations rz1000_port_ops = { | |||
126 | .irq_clear = ata_bmdma_irq_clear, | 126 | .irq_clear = ata_bmdma_irq_clear, |
127 | 127 | ||
128 | .port_start = ata_port_start, | 128 | .port_start = ata_port_start, |
129 | .port_stop = ata_port_stop, | ||
130 | .host_stop = ata_host_stop | ||
131 | }; | 129 | }; |
132 | 130 | ||
133 | static int rz1000_fifo_disable(struct pci_dev *pdev) | 131 | static int rz1000_fifo_disable(struct pci_dev *pdev) |
diff --git a/drivers/ata/pata_sc1200.c b/drivers/ata/pata_sc1200.c index a3b35bc50394..75638ccc0183 100644 --- a/drivers/ata/pata_sc1200.c +++ b/drivers/ata/pata_sc1200.c | |||
@@ -226,8 +226,6 @@ static struct ata_port_operations sc1200_port_ops = { | |||
226 | .irq_clear = ata_bmdma_irq_clear, | 226 | .irq_clear = ata_bmdma_irq_clear, |
227 | 227 | ||
228 | .port_start = ata_port_start, | 228 | .port_start = ata_port_start, |
229 | .port_stop = ata_port_stop, | ||
230 | .host_stop = ata_host_stop | ||
231 | }; | 229 | }; |
232 | 230 | ||
233 | /** | 231 | /** |
diff --git a/drivers/ata/pata_serverworks.c b/drivers/ata/pata_serverworks.c index 4b8c2352cdca..46ea1e8af4f4 100644 --- a/drivers/ata/pata_serverworks.c +++ b/drivers/ata/pata_serverworks.c | |||
@@ -354,8 +354,6 @@ static struct ata_port_operations serverworks_osb4_port_ops = { | |||
354 | .irq_clear = ata_bmdma_irq_clear, | 354 | .irq_clear = ata_bmdma_irq_clear, |
355 | 355 | ||
356 | .port_start = ata_port_start, | 356 | .port_start = ata_port_start, |
357 | .port_stop = ata_port_stop, | ||
358 | .host_stop = ata_host_stop | ||
359 | }; | 357 | }; |
360 | 358 | ||
361 | static struct ata_port_operations serverworks_csb_port_ops = { | 359 | static struct ata_port_operations serverworks_csb_port_ops = { |
@@ -389,8 +387,6 @@ static struct ata_port_operations serverworks_csb_port_ops = { | |||
389 | .irq_clear = ata_bmdma_irq_clear, | 387 | .irq_clear = ata_bmdma_irq_clear, |
390 | 388 | ||
391 | .port_start = ata_port_start, | 389 | .port_start = ata_port_start, |
392 | .port_stop = ata_port_stop, | ||
393 | .host_stop = ata_host_stop | ||
394 | }; | 390 | }; |
395 | 391 | ||
396 | static int serverworks_fixup_osb4(struct pci_dev *pdev) | 392 | static int serverworks_fixup_osb4(struct pci_dev *pdev) |
diff --git a/drivers/ata/pata_sil680.c b/drivers/ata/pata_sil680.c index 11da1f5271d5..955c1d3a5739 100644 --- a/drivers/ata/pata_sil680.c +++ b/drivers/ata/pata_sil680.c | |||
@@ -258,8 +258,6 @@ static struct ata_port_operations sil680_port_ops = { | |||
258 | .irq_clear = ata_bmdma_irq_clear, | 258 | .irq_clear = ata_bmdma_irq_clear, |
259 | 259 | ||
260 | .port_start = ata_port_start, | 260 | .port_start = ata_port_start, |
261 | .port_stop = ata_port_stop, | ||
262 | .host_stop = ata_host_stop | ||
263 | }; | 261 | }; |
264 | 262 | ||
265 | /** | 263 | /** |
diff --git a/drivers/ata/pata_sis.c b/drivers/ata/pata_sis.c index 5e616d3cc870..1c5219f3ffde 100644 --- a/drivers/ata/pata_sis.c +++ b/drivers/ata/pata_sis.c | |||
@@ -608,8 +608,6 @@ static const struct ata_port_operations sis_133_ops = { | |||
608 | .irq_clear = ata_bmdma_irq_clear, | 608 | .irq_clear = ata_bmdma_irq_clear, |
609 | 609 | ||
610 | .port_start = ata_port_start, | 610 | .port_start = ata_port_start, |
611 | .port_stop = ata_port_stop, | ||
612 | .host_stop = ata_host_stop, | ||
613 | }; | 611 | }; |
614 | 612 | ||
615 | static const struct ata_port_operations sis_133_early_ops = { | 613 | static const struct ata_port_operations sis_133_early_ops = { |
@@ -641,8 +639,6 @@ static const struct ata_port_operations sis_133_early_ops = { | |||
641 | .irq_clear = ata_bmdma_irq_clear, | 639 | .irq_clear = ata_bmdma_irq_clear, |
642 | 640 | ||
643 | .port_start = ata_port_start, | 641 | .port_start = ata_port_start, |
644 | .port_stop = ata_port_stop, | ||
645 | .host_stop = ata_host_stop, | ||
646 | }; | 642 | }; |
647 | 643 | ||
648 | static const struct ata_port_operations sis_100_ops = { | 644 | static const struct ata_port_operations sis_100_ops = { |
@@ -675,8 +671,6 @@ static const struct ata_port_operations sis_100_ops = { | |||
675 | .irq_clear = ata_bmdma_irq_clear, | 671 | .irq_clear = ata_bmdma_irq_clear, |
676 | 672 | ||
677 | .port_start = ata_port_start, | 673 | .port_start = ata_port_start, |
678 | .port_stop = ata_port_stop, | ||
679 | .host_stop = ata_host_stop, | ||
680 | }; | 674 | }; |
681 | 675 | ||
682 | static const struct ata_port_operations sis_66_ops = { | 676 | static const struct ata_port_operations sis_66_ops = { |
@@ -708,8 +702,6 @@ static const struct ata_port_operations sis_66_ops = { | |||
708 | .irq_clear = ata_bmdma_irq_clear, | 702 | .irq_clear = ata_bmdma_irq_clear, |
709 | 703 | ||
710 | .port_start = ata_port_start, | 704 | .port_start = ata_port_start, |
711 | .port_stop = ata_port_stop, | ||
712 | .host_stop = ata_host_stop, | ||
713 | }; | 705 | }; |
714 | 706 | ||
715 | static const struct ata_port_operations sis_old_ops = { | 707 | static const struct ata_port_operations sis_old_ops = { |
@@ -741,8 +733,6 @@ static const struct ata_port_operations sis_old_ops = { | |||
741 | .irq_clear = ata_bmdma_irq_clear, | 733 | .irq_clear = ata_bmdma_irq_clear, |
742 | 734 | ||
743 | .port_start = ata_port_start, | 735 | .port_start = ata_port_start, |
744 | .port_stop = ata_port_stop, | ||
745 | .host_stop = ata_host_stop, | ||
746 | }; | 736 | }; |
747 | 737 | ||
748 | static struct ata_port_info sis_info = { | 738 | static struct ata_port_info sis_info = { |
diff --git a/drivers/ata/pata_sl82c105.c b/drivers/ata/pata_sl82c105.c index e94f515ef54b..d118a1822c45 100644 --- a/drivers/ata/pata_sl82c105.c +++ b/drivers/ata/pata_sl82c105.c | |||
@@ -268,8 +268,6 @@ static struct ata_port_operations sl82c105_port_ops = { | |||
268 | .irq_clear = ata_bmdma_irq_clear, | 268 | .irq_clear = ata_bmdma_irq_clear, |
269 | 269 | ||
270 | .port_start = ata_port_start, | 270 | .port_start = ata_port_start, |
271 | .port_stop = ata_port_stop, | ||
272 | .host_stop = ata_host_stop | ||
273 | }; | 271 | }; |
274 | 272 | ||
275 | /** | 273 | /** |
diff --git a/drivers/ata/pata_triflex.c b/drivers/ata/pata_triflex.c index a142971f1307..57385a2f8286 100644 --- a/drivers/ata/pata_triflex.c +++ b/drivers/ata/pata_triflex.c | |||
@@ -227,8 +227,6 @@ static struct ata_port_operations triflex_port_ops = { | |||
227 | .irq_clear = ata_bmdma_irq_clear, | 227 | .irq_clear = ata_bmdma_irq_clear, |
228 | 228 | ||
229 | .port_start = ata_port_start, | 229 | .port_start = ata_port_start, |
230 | .port_stop = ata_port_stop, | ||
231 | .host_stop = ata_host_stop | ||
232 | }; | 230 | }; |
233 | 231 | ||
234 | static int triflex_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 232 | static int triflex_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
diff --git a/drivers/ata/pata_via.c b/drivers/ata/pata_via.c index 2addce11000a..2b262363b96a 100644 --- a/drivers/ata/pata_via.c +++ b/drivers/ata/pata_via.c | |||
@@ -340,8 +340,6 @@ static struct ata_port_operations via_port_ops = { | |||
340 | .irq_clear = ata_bmdma_irq_clear, | 340 | .irq_clear = ata_bmdma_irq_clear, |
341 | 341 | ||
342 | .port_start = ata_port_start, | 342 | .port_start = ata_port_start, |
343 | .port_stop = ata_port_stop, | ||
344 | .host_stop = ata_host_stop | ||
345 | }; | 343 | }; |
346 | 344 | ||
347 | static struct ata_port_operations via_port_ops_noirq = { | 345 | static struct ata_port_operations via_port_ops_noirq = { |
@@ -375,8 +373,6 @@ static struct ata_port_operations via_port_ops_noirq = { | |||
375 | .irq_clear = ata_bmdma_irq_clear, | 373 | .irq_clear = ata_bmdma_irq_clear, |
376 | 374 | ||
377 | .port_start = ata_port_start, | 375 | .port_start = ata_port_start, |
378 | .port_stop = ata_port_stop, | ||
379 | .host_stop = ata_host_stop | ||
380 | }; | 376 | }; |
381 | 377 | ||
382 | /** | 378 | /** |
diff --git a/drivers/ata/pata_winbond.c b/drivers/ata/pata_winbond.c index 022da95a3389..bba04a6e3708 100644 --- a/drivers/ata/pata_winbond.c +++ b/drivers/ata/pata_winbond.c | |||
@@ -160,8 +160,6 @@ static struct ata_port_operations winbond_port_ops = { | |||
160 | .irq_clear = ata_bmdma_irq_clear, | 160 | .irq_clear = ata_bmdma_irq_clear, |
161 | 161 | ||
162 | .port_start = ata_port_start, | 162 | .port_start = ata_port_start, |
163 | .port_stop = ata_port_stop, | ||
164 | .host_stop = ata_host_stop | ||
165 | }; | 163 | }; |
166 | 164 | ||
167 | /** | 165 | /** |
@@ -288,7 +286,7 @@ static __exit void winbond_exit(void) | |||
288 | int i; | 286 | int i; |
289 | 287 | ||
290 | for (i = 0; i < nr_winbond_host; i++) { | 288 | for (i = 0; i < nr_winbond_host; i++) { |
291 | ata_host_remove(winbond_host[i]); | 289 | ata_host_detach(winbond_host[i]); |
292 | release_region(winbond_data[i].config, 2); | 290 | release_region(winbond_data[i].config, 2); |
293 | platform_device_unregister(winbond_data[i].platform_dev); | 291 | platform_device_unregister(winbond_data[i].platform_dev); |
294 | } | 292 | } |
diff --git a/drivers/ata/pdc_adma.c b/drivers/ata/pdc_adma.c index 90786d7a20bb..a6bf7cbdfdc5 100644 --- a/drivers/ata/pdc_adma.c +++ b/drivers/ata/pdc_adma.c | |||
@@ -42,7 +42,6 @@ | |||
42 | #include <linux/sched.h> | 42 | #include <linux/sched.h> |
43 | #include <linux/device.h> | 43 | #include <linux/device.h> |
44 | #include <scsi/scsi_host.h> | 44 | #include <scsi/scsi_host.h> |
45 | #include <asm/io.h> | ||
46 | #include <linux/libata.h> | 45 | #include <linux/libata.h> |
47 | 46 | ||
48 | #define DRV_NAME "pdc_adma" | 47 | #define DRV_NAME "pdc_adma" |
@@ -550,48 +549,28 @@ static int adma_port_start(struct ata_port *ap) | |||
550 | if (rc) | 549 | if (rc) |
551 | return rc; | 550 | return rc; |
552 | adma_enter_reg_mode(ap); | 551 | adma_enter_reg_mode(ap); |
553 | rc = -ENOMEM; | 552 | pp = devm_kzalloc(dev, sizeof(*pp), GFP_KERNEL); |
554 | pp = kzalloc(sizeof(*pp), GFP_KERNEL); | ||
555 | if (!pp) | 553 | if (!pp) |
556 | goto err_out; | 554 | return -ENOMEM; |
557 | pp->pkt = dma_alloc_coherent(dev, ADMA_PKT_BYTES, &pp->pkt_dma, | 555 | pp->pkt = dmam_alloc_coherent(dev, ADMA_PKT_BYTES, &pp->pkt_dma, |
558 | GFP_KERNEL); | 556 | GFP_KERNEL); |
559 | if (!pp->pkt) | 557 | if (!pp->pkt) |
560 | goto err_out_kfree; | 558 | return -ENOMEM; |
561 | /* paranoia? */ | 559 | /* paranoia? */ |
562 | if ((pp->pkt_dma & 7) != 0) { | 560 | if ((pp->pkt_dma & 7) != 0) { |
563 | printk("bad alignment for pp->pkt_dma: %08x\n", | 561 | printk("bad alignment for pp->pkt_dma: %08x\n", |
564 | (u32)pp->pkt_dma); | 562 | (u32)pp->pkt_dma); |
565 | dma_free_coherent(dev, ADMA_PKT_BYTES, | 563 | return -ENOMEM; |
566 | pp->pkt, pp->pkt_dma); | ||
567 | goto err_out_kfree; | ||
568 | } | 564 | } |
569 | memset(pp->pkt, 0, ADMA_PKT_BYTES); | 565 | memset(pp->pkt, 0, ADMA_PKT_BYTES); |
570 | ap->private_data = pp; | 566 | ap->private_data = pp; |
571 | adma_reinit_engine(ap); | 567 | adma_reinit_engine(ap); |
572 | return 0; | 568 | return 0; |
573 | |||
574 | err_out_kfree: | ||
575 | kfree(pp); | ||
576 | err_out: | ||
577 | ata_port_stop(ap); | ||
578 | return rc; | ||
579 | } | 569 | } |
580 | 570 | ||
581 | static void adma_port_stop(struct ata_port *ap) | 571 | static void adma_port_stop(struct ata_port *ap) |
582 | { | 572 | { |
583 | struct device *dev = ap->host->dev; | ||
584 | struct adma_port_priv *pp = ap->private_data; | ||
585 | |||
586 | adma_reset_engine(ADMA_REGS(ap->host->mmio_base, ap->port_no)); | 573 | adma_reset_engine(ADMA_REGS(ap->host->mmio_base, ap->port_no)); |
587 | if (pp != NULL) { | ||
588 | ap->private_data = NULL; | ||
589 | if (pp->pkt != NULL) | ||
590 | dma_free_coherent(dev, ADMA_PKT_BYTES, | ||
591 | pp->pkt, pp->pkt_dma); | ||
592 | kfree(pp); | ||
593 | } | ||
594 | ata_port_stop(ap); | ||
595 | } | 574 | } |
596 | 575 | ||
597 | static void adma_host_stop(struct ata_host *host) | 576 | static void adma_host_stop(struct ata_host *host) |
@@ -600,8 +579,6 @@ static void adma_host_stop(struct ata_host *host) | |||
600 | 579 | ||
601 | for (port_no = 0; port_no < ADMA_PORTS; ++port_no) | 580 | for (port_no = 0; port_no < ADMA_PORTS; ++port_no) |
602 | adma_reset_engine(ADMA_REGS(host->mmio_base, port_no)); | 581 | adma_reset_engine(ADMA_REGS(host->mmio_base, port_no)); |
603 | |||
604 | ata_pci_host_stop(host); | ||
605 | } | 582 | } |
606 | 583 | ||
607 | static void adma_host_init(unsigned int chip_id, | 584 | static void adma_host_init(unsigned int chip_id, |
@@ -649,34 +626,28 @@ static int adma_ata_init_one(struct pci_dev *pdev, | |||
649 | if (!printed_version++) | 626 | if (!printed_version++) |
650 | dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); | 627 | dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); |
651 | 628 | ||
652 | rc = pci_enable_device(pdev); | 629 | rc = pcim_enable_device(pdev); |
653 | if (rc) | 630 | if (rc) |
654 | return rc; | 631 | return rc; |
655 | 632 | ||
656 | rc = pci_request_regions(pdev, DRV_NAME); | 633 | rc = pci_request_regions(pdev, DRV_NAME); |
657 | if (rc) | 634 | if (rc) |
658 | goto err_out; | 635 | return rc; |
659 | 636 | ||
660 | if ((pci_resource_flags(pdev, 4) & IORESOURCE_MEM) == 0) { | 637 | if ((pci_resource_flags(pdev, 4) & IORESOURCE_MEM) == 0) |
661 | rc = -ENODEV; | 638 | return -ENODEV; |
662 | goto err_out_regions; | ||
663 | } | ||
664 | 639 | ||
665 | mmio_base = pci_iomap(pdev, 4, 0); | 640 | mmio_base = pcim_iomap(pdev, 4, 0); |
666 | if (mmio_base == NULL) { | 641 | if (mmio_base == NULL) |
667 | rc = -ENOMEM; | 642 | return -ENOMEM; |
668 | goto err_out_regions; | ||
669 | } | ||
670 | 643 | ||
671 | rc = adma_set_dma_masks(pdev, mmio_base); | 644 | rc = adma_set_dma_masks(pdev, mmio_base); |
672 | if (rc) | 645 | if (rc) |
673 | goto err_out_iounmap; | 646 | return rc; |
674 | 647 | ||
675 | probe_ent = kzalloc(sizeof(*probe_ent), GFP_KERNEL); | 648 | probe_ent = devm_kzalloc(&pdev->dev, sizeof(*probe_ent), GFP_KERNEL); |
676 | if (probe_ent == NULL) { | 649 | if (probe_ent == NULL) |
677 | rc = -ENOMEM; | 650 | return -ENOMEM; |
678 | goto err_out_iounmap; | ||
679 | } | ||
680 | 651 | ||
681 | probe_ent->dev = pci_dev_to_dev(pdev); | 652 | probe_ent->dev = pci_dev_to_dev(pdev); |
682 | INIT_LIST_HEAD(&probe_ent->node); | 653 | INIT_LIST_HEAD(&probe_ent->node); |
@@ -703,19 +674,11 @@ static int adma_ata_init_one(struct pci_dev *pdev, | |||
703 | /* initialize adapter */ | 674 | /* initialize adapter */ |
704 | adma_host_init(board_idx, probe_ent); | 675 | adma_host_init(board_idx, probe_ent); |
705 | 676 | ||
706 | rc = ata_device_add(probe_ent); | 677 | if (!ata_device_add(probe_ent)) |
707 | kfree(probe_ent); | 678 | return -ENODEV; |
708 | if (rc != ADMA_PORTS) | ||
709 | goto err_out_iounmap; | ||
710 | return 0; | ||
711 | 679 | ||
712 | err_out_iounmap: | 680 | devm_kfree(&pdev->dev, probe_ent); |
713 | pci_iounmap(pdev, mmio_base); | 681 | return 0; |
714 | err_out_regions: | ||
715 | pci_release_regions(pdev); | ||
716 | err_out: | ||
717 | pci_disable_device(pdev); | ||
718 | return rc; | ||
719 | } | 682 | } |
720 | 683 | ||
721 | static int __init adma_ata_init(void) | 684 | static int __init adma_ata_init(void) |
diff --git a/drivers/ata/sata_inic162x.c b/drivers/ata/sata_inic162x.c index b67817e440c5..c98e0227a60c 100644 --- a/drivers/ata/sata_inic162x.c +++ b/drivers/ata/sata_inic162x.c | |||
@@ -523,7 +523,7 @@ static int inic_port_start(struct ata_port *ap) | |||
523 | int rc; | 523 | int rc; |
524 | 524 | ||
525 | /* alloc and initialize private data */ | 525 | /* alloc and initialize private data */ |
526 | pp = kzalloc(sizeof(*pp), GFP_KERNEL); | 526 | pp = devm_kzalloc(ap->host->dev, sizeof(*pp), GFP_KERNEL); |
527 | if (!pp) | 527 | if (!pp) |
528 | return -ENOMEM; | 528 | return -ENOMEM; |
529 | ap->private_data = pp; | 529 | ap->private_data = pp; |
@@ -545,12 +545,6 @@ static int inic_port_start(struct ata_port *ap) | |||
545 | return 0; | 545 | return 0; |
546 | } | 546 | } |
547 | 547 | ||
548 | static void inic_port_stop(struct ata_port *ap) | ||
549 | { | ||
550 | ata_port_stop(ap); | ||
551 | kfree(ap->private_data); | ||
552 | } | ||
553 | |||
554 | static struct ata_port_operations inic_port_ops = { | 548 | static struct ata_port_operations inic_port_ops = { |
555 | .port_disable = ata_port_disable, | 549 | .port_disable = ata_port_disable, |
556 | .tf_load = ata_tf_load, | 550 | .tf_load = ata_tf_load, |
@@ -583,8 +577,6 @@ static struct ata_port_operations inic_port_ops = { | |||
583 | .port_resume = inic_port_resume, | 577 | .port_resume = inic_port_resume, |
584 | 578 | ||
585 | .port_start = inic_port_start, | 579 | .port_start = inic_port_start, |
586 | .port_stop = inic_port_stop, | ||
587 | .host_stop = ata_pci_host_stop | ||
588 | }; | 580 | }; |
589 | 581 | ||
590 | static struct ata_port_info inic_port_info = { | 582 | static struct ata_port_info inic_port_info = { |
@@ -675,42 +667,37 @@ static int inic_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
675 | if (!printed_version++) | 667 | if (!printed_version++) |
676 | dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); | 668 | dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); |
677 | 669 | ||
678 | rc = pci_enable_device(pdev); | 670 | rc = pcim_enable_device(pdev); |
679 | if (rc) | 671 | if (rc) |
680 | return rc; | 672 | return rc; |
681 | 673 | ||
682 | rc = pci_request_regions(pdev, DRV_NAME); | 674 | rc = pci_request_regions(pdev, DRV_NAME); |
683 | if (rc) | 675 | if (rc) |
684 | goto err_out; | 676 | return rc; |
685 | 677 | ||
686 | rc = -ENOMEM; | ||
687 | mmio_base = pci_iomap(pdev, MMIO_BAR, 0); | 678 | mmio_base = pci_iomap(pdev, MMIO_BAR, 0); |
688 | if (!mmio_base) | 679 | if (!mmio_base) |
689 | goto err_out_regions; | 680 | return -ENOMEM; |
690 | 681 | ||
691 | /* Set dma_mask. This devices doesn't support 64bit addressing. */ | 682 | /* Set dma_mask. This devices doesn't support 64bit addressing. */ |
692 | rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK); | 683 | rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK); |
693 | if (rc) { | 684 | if (rc) { |
694 | dev_printk(KERN_ERR, &pdev->dev, | 685 | dev_printk(KERN_ERR, &pdev->dev, |
695 | "32-bit DMA enable failed\n"); | 686 | "32-bit DMA enable failed\n"); |
696 | goto err_out_map; | 687 | return rc; |
697 | } | 688 | } |
698 | 689 | ||
699 | rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK); | 690 | rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK); |
700 | if (rc) { | 691 | if (rc) { |
701 | dev_printk(KERN_ERR, &pdev->dev, | 692 | dev_printk(KERN_ERR, &pdev->dev, |
702 | "32-bit consistent DMA enable failed\n"); | 693 | "32-bit consistent DMA enable failed\n"); |
703 | goto err_out_map; | 694 | return rc; |
704 | } | 695 | } |
705 | 696 | ||
706 | rc = -ENOMEM; | 697 | probe_ent = devm_kzalloc(&pdev->dev, sizeof(*probe_ent), GFP_KERNEL); |
707 | probe_ent = kzalloc(sizeof(*probe_ent), GFP_KERNEL); | 698 | hpriv = devm_kzalloc(&pdev->dev, sizeof(*hpriv), GFP_KERNEL); |
708 | if (!probe_ent) | 699 | if (!probe_ent || !hpriv) |
709 | goto err_out_map; | 700 | return -ENOMEM; |
710 | |||
711 | hpriv = kzalloc(sizeof(*hpriv), GFP_KERNEL); | ||
712 | if (!hpriv) | ||
713 | goto err_out_ent; | ||
714 | 701 | ||
715 | probe_ent->dev = &pdev->dev; | 702 | probe_ent->dev = &pdev->dev; |
716 | INIT_LIST_HEAD(&probe_ent->node); | 703 | INIT_LIST_HEAD(&probe_ent->node); |
@@ -749,30 +736,17 @@ static int inic_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
749 | if (rc) { | 736 | if (rc) { |
750 | dev_printk(KERN_ERR, &pdev->dev, | 737 | dev_printk(KERN_ERR, &pdev->dev, |
751 | "failed to initialize controller\n"); | 738 | "failed to initialize controller\n"); |
752 | goto err_out_hpriv; | 739 | return rc; |
753 | } | 740 | } |
754 | 741 | ||
755 | pci_set_master(pdev); | 742 | pci_set_master(pdev); |
756 | 743 | ||
757 | rc = -ENODEV; | ||
758 | if (!ata_device_add(probe_ent)) | 744 | if (!ata_device_add(probe_ent)) |
759 | goto err_out_hpriv; | 745 | return -ENODEV; |
760 | 746 | ||
761 | kfree(probe_ent); | 747 | devm_kfree(&pdev->dev, probe_ent); |
762 | 748 | ||
763 | return 0; | 749 | return 0; |
764 | |||
765 | err_out_hpriv: | ||
766 | kfree(hpriv); | ||
767 | err_out_ent: | ||
768 | kfree(probe_ent); | ||
769 | err_out_map: | ||
770 | pci_iounmap(pdev, mmio_base); | ||
771 | err_out_regions: | ||
772 | pci_release_regions(pdev); | ||
773 | err_out: | ||
774 | pci_disable_device(pdev); | ||
775 | return rc; | ||
776 | } | 750 | } |
777 | 751 | ||
778 | static const struct pci_device_id inic_pci_tbl[] = { | 752 | static const struct pci_device_id inic_pci_tbl[] = { |
diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c index aae0b5201c1e..c073e453dcdd 100644 --- a/drivers/ata/sata_mv.c +++ b/drivers/ata/sata_mv.c | |||
@@ -34,7 +34,6 @@ | |||
34 | #include <scsi/scsi_host.h> | 34 | #include <scsi/scsi_host.h> |
35 | #include <scsi/scsi_cmnd.h> | 35 | #include <scsi/scsi_cmnd.h> |
36 | #include <linux/libata.h> | 36 | #include <linux/libata.h> |
37 | #include <asm/io.h> | ||
38 | 37 | ||
39 | #define DRV_NAME "sata_mv" | 38 | #define DRV_NAME "sata_mv" |
40 | #define DRV_VERSION "0.7" | 39 | #define DRV_VERSION "0.7" |
@@ -342,7 +341,6 @@ static u32 mv5_scr_read(struct ata_port *ap, unsigned int sc_reg_in); | |||
342 | static void mv5_scr_write(struct ata_port *ap, unsigned int sc_reg_in, u32 val); | 341 | static void mv5_scr_write(struct ata_port *ap, unsigned int sc_reg_in, u32 val); |
343 | static void mv_phy_reset(struct ata_port *ap); | 342 | static void mv_phy_reset(struct ata_port *ap); |
344 | static void __mv_phy_reset(struct ata_port *ap, int can_sleep); | 343 | static void __mv_phy_reset(struct ata_port *ap, int can_sleep); |
345 | static void mv_host_stop(struct ata_host *host); | ||
346 | static int mv_port_start(struct ata_port *ap); | 344 | static int mv_port_start(struct ata_port *ap); |
347 | static void mv_port_stop(struct ata_port *ap); | 345 | static void mv_port_stop(struct ata_port *ap); |
348 | static void mv_qc_prep(struct ata_queued_cmd *qc); | 346 | static void mv_qc_prep(struct ata_queued_cmd *qc); |
@@ -418,7 +416,6 @@ static const struct ata_port_operations mv5_ops = { | |||
418 | 416 | ||
419 | .port_start = mv_port_start, | 417 | .port_start = mv_port_start, |
420 | .port_stop = mv_port_stop, | 418 | .port_stop = mv_port_stop, |
421 | .host_stop = mv_host_stop, | ||
422 | }; | 419 | }; |
423 | 420 | ||
424 | static const struct ata_port_operations mv6_ops = { | 421 | static const struct ata_port_operations mv6_ops = { |
@@ -446,7 +443,6 @@ static const struct ata_port_operations mv6_ops = { | |||
446 | 443 | ||
447 | .port_start = mv_port_start, | 444 | .port_start = mv_port_start, |
448 | .port_stop = mv_port_stop, | 445 | .port_stop = mv_port_stop, |
449 | .host_stop = mv_host_stop, | ||
450 | }; | 446 | }; |
451 | 447 | ||
452 | static const struct ata_port_operations mv_iie_ops = { | 448 | static const struct ata_port_operations mv_iie_ops = { |
@@ -474,7 +470,6 @@ static const struct ata_port_operations mv_iie_ops = { | |||
474 | 470 | ||
475 | .port_start = mv_port_start, | 471 | .port_start = mv_port_start, |
476 | .port_stop = mv_port_stop, | 472 | .port_stop = mv_port_stop, |
477 | .host_stop = mv_host_stop, | ||
478 | }; | 473 | }; |
479 | 474 | ||
480 | static const struct ata_port_info mv_port_info[] = { | 475 | static const struct ata_port_info mv_port_info[] = { |
@@ -809,35 +804,6 @@ static void mv_scr_write(struct ata_port *ap, unsigned int sc_reg_in, u32 val) | |||
809 | } | 804 | } |
810 | } | 805 | } |
811 | 806 | ||
812 | /** | ||
813 | * mv_host_stop - Host specific cleanup/stop routine. | ||
814 | * @host: host data structure | ||
815 | * | ||
816 | * Disable ints, cleanup host memory, call general purpose | ||
817 | * host_stop. | ||
818 | * | ||
819 | * LOCKING: | ||
820 | * Inherited from caller. | ||
821 | */ | ||
822 | static void mv_host_stop(struct ata_host *host) | ||
823 | { | ||
824 | struct mv_host_priv *hpriv = host->private_data; | ||
825 | struct pci_dev *pdev = to_pci_dev(host->dev); | ||
826 | |||
827 | if (hpriv->hp_flags & MV_HP_FLAG_MSI) { | ||
828 | pci_disable_msi(pdev); | ||
829 | } else { | ||
830 | pci_intx(pdev, 0); | ||
831 | } | ||
832 | kfree(hpriv); | ||
833 | ata_host_stop(host); | ||
834 | } | ||
835 | |||
836 | static inline void mv_priv_free(struct mv_port_priv *pp, struct device *dev) | ||
837 | { | ||
838 | dma_free_coherent(dev, MV_PORT_PRIV_DMA_SZ, pp->crpb, pp->crpb_dma); | ||
839 | } | ||
840 | |||
841 | static void mv_edma_cfg(struct mv_host_priv *hpriv, void __iomem *port_mmio) | 807 | static void mv_edma_cfg(struct mv_host_priv *hpriv, void __iomem *port_mmio) |
842 | { | 808 | { |
843 | u32 cfg = readl(port_mmio + EDMA_CFG_OFS); | 809 | u32 cfg = readl(port_mmio + EDMA_CFG_OFS); |
@@ -883,22 +849,21 @@ static int mv_port_start(struct ata_port *ap) | |||
883 | void __iomem *port_mmio = mv_ap_base(ap); | 849 | void __iomem *port_mmio = mv_ap_base(ap); |
884 | void *mem; | 850 | void *mem; |
885 | dma_addr_t mem_dma; | 851 | dma_addr_t mem_dma; |
886 | int rc = -ENOMEM; | 852 | int rc; |
887 | 853 | ||
888 | pp = kmalloc(sizeof(*pp), GFP_KERNEL); | 854 | pp = devm_kzalloc(dev, sizeof(*pp), GFP_KERNEL); |
889 | if (!pp) | 855 | if (!pp) |
890 | goto err_out; | 856 | return -ENOMEM; |
891 | memset(pp, 0, sizeof(*pp)); | ||
892 | 857 | ||
893 | mem = dma_alloc_coherent(dev, MV_PORT_PRIV_DMA_SZ, &mem_dma, | 858 | mem = dmam_alloc_coherent(dev, MV_PORT_PRIV_DMA_SZ, &mem_dma, |
894 | GFP_KERNEL); | 859 | GFP_KERNEL); |
895 | if (!mem) | 860 | if (!mem) |
896 | goto err_out_pp; | 861 | return -ENOMEM; |
897 | memset(mem, 0, MV_PORT_PRIV_DMA_SZ); | 862 | memset(mem, 0, MV_PORT_PRIV_DMA_SZ); |
898 | 863 | ||
899 | rc = ata_pad_alloc(ap, dev); | 864 | rc = ata_pad_alloc(ap, dev); |
900 | if (rc) | 865 | if (rc) |
901 | goto err_out_priv; | 866 | return rc; |
902 | 867 | ||
903 | /* First item in chunk of DMA memory: | 868 | /* First item in chunk of DMA memory: |
904 | * 32-slot command request table (CRQB), 32 bytes each in size | 869 | * 32-slot command request table (CRQB), 32 bytes each in size |
@@ -951,13 +916,6 @@ static int mv_port_start(struct ata_port *ap) | |||
951 | */ | 916 | */ |
952 | ap->private_data = pp; | 917 | ap->private_data = pp; |
953 | return 0; | 918 | return 0; |
954 | |||
955 | err_out_priv: | ||
956 | mv_priv_free(pp, dev); | ||
957 | err_out_pp: | ||
958 | kfree(pp); | ||
959 | err_out: | ||
960 | return rc; | ||
961 | } | 919 | } |
962 | 920 | ||
963 | /** | 921 | /** |
@@ -971,18 +929,11 @@ err_out: | |||
971 | */ | 929 | */ |
972 | static void mv_port_stop(struct ata_port *ap) | 930 | static void mv_port_stop(struct ata_port *ap) |
973 | { | 931 | { |
974 | struct device *dev = ap->host->dev; | ||
975 | struct mv_port_priv *pp = ap->private_data; | ||
976 | unsigned long flags; | 932 | unsigned long flags; |
977 | 933 | ||
978 | spin_lock_irqsave(&ap->host->lock, flags); | 934 | spin_lock_irqsave(&ap->host->lock, flags); |
979 | mv_stop_dma(ap); | 935 | mv_stop_dma(ap); |
980 | spin_unlock_irqrestore(&ap->host->lock, flags); | 936 | spin_unlock_irqrestore(&ap->host->lock, flags); |
981 | |||
982 | ap->private_data = NULL; | ||
983 | ata_pad_free(ap, dev); | ||
984 | mv_priv_free(pp, dev); | ||
985 | kfree(pp); | ||
986 | } | 937 | } |
987 | 938 | ||
988 | /** | 939 | /** |
@@ -2342,49 +2293,41 @@ static void mv_print_info(struct ata_probe_ent *probe_ent) | |||
2342 | static int mv_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | 2293 | static int mv_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) |
2343 | { | 2294 | { |
2344 | static int printed_version = 0; | 2295 | static int printed_version = 0; |
2345 | struct ata_probe_ent *probe_ent = NULL; | 2296 | struct device *dev = &pdev->dev; |
2297 | struct ata_probe_ent *probe_ent; | ||
2346 | struct mv_host_priv *hpriv; | 2298 | struct mv_host_priv *hpriv; |
2347 | unsigned int board_idx = (unsigned int)ent->driver_data; | 2299 | unsigned int board_idx = (unsigned int)ent->driver_data; |
2348 | void __iomem *mmio_base; | 2300 | void __iomem *mmio_base; |
2349 | int pci_dev_busy = 0, rc; | 2301 | int rc; |
2350 | 2302 | ||
2351 | if (!printed_version++) | 2303 | if (!printed_version++) |
2352 | dev_printk(KERN_INFO, &pdev->dev, "version " DRV_VERSION "\n"); | 2304 | dev_printk(KERN_INFO, &pdev->dev, "version " DRV_VERSION "\n"); |
2353 | 2305 | ||
2354 | rc = pci_enable_device(pdev); | 2306 | rc = pcim_enable_device(pdev); |
2355 | if (rc) { | 2307 | if (rc) |
2356 | return rc; | 2308 | return rc; |
2357 | } | ||
2358 | pci_set_master(pdev); | 2309 | pci_set_master(pdev); |
2359 | 2310 | ||
2360 | rc = pci_request_regions(pdev, DRV_NAME); | 2311 | rc = pci_request_regions(pdev, DRV_NAME); |
2361 | if (rc) { | 2312 | if (rc) { |
2362 | pci_dev_busy = 1; | 2313 | pcim_pin_device(pdev); |
2363 | goto err_out; | 2314 | return rc; |
2364 | } | 2315 | } |
2365 | 2316 | ||
2366 | probe_ent = kmalloc(sizeof(*probe_ent), GFP_KERNEL); | 2317 | probe_ent = devm_kzalloc(dev, sizeof(*probe_ent), GFP_KERNEL); |
2367 | if (probe_ent == NULL) { | 2318 | if (probe_ent == NULL) |
2368 | rc = -ENOMEM; | 2319 | return -ENOMEM; |
2369 | goto err_out_regions; | ||
2370 | } | ||
2371 | 2320 | ||
2372 | memset(probe_ent, 0, sizeof(*probe_ent)); | ||
2373 | probe_ent->dev = pci_dev_to_dev(pdev); | 2321 | probe_ent->dev = pci_dev_to_dev(pdev); |
2374 | INIT_LIST_HEAD(&probe_ent->node); | 2322 | INIT_LIST_HEAD(&probe_ent->node); |
2375 | 2323 | ||
2376 | mmio_base = pci_iomap(pdev, MV_PRIMARY_BAR, 0); | 2324 | mmio_base = pcim_iomap(pdev, MV_PRIMARY_BAR, 0); |
2377 | if (mmio_base == NULL) { | 2325 | if (mmio_base == NULL) |
2378 | rc = -ENOMEM; | 2326 | return -ENOMEM; |
2379 | goto err_out_free_ent; | ||
2380 | } | ||
2381 | 2327 | ||
2382 | hpriv = kmalloc(sizeof(*hpriv), GFP_KERNEL); | 2328 | hpriv = devm_kzalloc(dev, sizeof(*hpriv), GFP_KERNEL); |
2383 | if (!hpriv) { | 2329 | if (!hpriv) |
2384 | rc = -ENOMEM; | 2330 | return -ENOMEM; |
2385 | goto err_out_iounmap; | ||
2386 | } | ||
2387 | memset(hpriv, 0, sizeof(*hpriv)); | ||
2388 | 2331 | ||
2389 | probe_ent->sht = mv_port_info[board_idx].sht; | 2332 | probe_ent->sht = mv_port_info[board_idx].sht; |
2390 | probe_ent->port_flags = mv_port_info[board_idx].flags; | 2333 | probe_ent->port_flags = mv_port_info[board_idx].flags; |
@@ -2399,48 +2342,21 @@ static int mv_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
2399 | 2342 | ||
2400 | /* initialize adapter */ | 2343 | /* initialize adapter */ |
2401 | rc = mv_init_host(pdev, probe_ent, board_idx); | 2344 | rc = mv_init_host(pdev, probe_ent, board_idx); |
2402 | if (rc) { | 2345 | if (rc) |
2403 | goto err_out_hpriv; | 2346 | return rc; |
2404 | } | ||
2405 | 2347 | ||
2406 | /* Enable interrupts */ | 2348 | /* Enable interrupts */ |
2407 | if (msi && pci_enable_msi(pdev) == 0) { | 2349 | if (msi && !pci_enable_msi(pdev)) |
2408 | hpriv->hp_flags |= MV_HP_FLAG_MSI; | ||
2409 | } else { | ||
2410 | pci_intx(pdev, 1); | 2350 | pci_intx(pdev, 1); |
2411 | } | ||
2412 | 2351 | ||
2413 | mv_dump_pci_cfg(pdev, 0x68); | 2352 | mv_dump_pci_cfg(pdev, 0x68); |
2414 | mv_print_info(probe_ent); | 2353 | mv_print_info(probe_ent); |
2415 | 2354 | ||
2416 | if (ata_device_add(probe_ent) == 0) { | 2355 | if (ata_device_add(probe_ent) == 0) |
2417 | rc = -ENODEV; /* No devices discovered */ | 2356 | return -ENODEV; |
2418 | goto err_out_dev_add; | ||
2419 | } | ||
2420 | 2357 | ||
2421 | kfree(probe_ent); | 2358 | devm_kfree(dev, probe_ent); |
2422 | return 0; | 2359 | return 0; |
2423 | |||
2424 | err_out_dev_add: | ||
2425 | if (MV_HP_FLAG_MSI & hpriv->hp_flags) { | ||
2426 | pci_disable_msi(pdev); | ||
2427 | } else { | ||
2428 | pci_intx(pdev, 0); | ||
2429 | } | ||
2430 | err_out_hpriv: | ||
2431 | kfree(hpriv); | ||
2432 | err_out_iounmap: | ||
2433 | pci_iounmap(pdev, mmio_base); | ||
2434 | err_out_free_ent: | ||
2435 | kfree(probe_ent); | ||
2436 | err_out_regions: | ||
2437 | pci_release_regions(pdev); | ||
2438 | err_out: | ||
2439 | if (!pci_dev_busy) { | ||
2440 | pci_disable_device(pdev); | ||
2441 | } | ||
2442 | |||
2443 | return rc; | ||
2444 | } | 2360 | } |
2445 | 2361 | ||
2446 | static int __init mv_init(void) | 2362 | static int __init mv_init(void) |
diff --git a/drivers/ata/sata_nv.c b/drivers/ata/sata_nv.c index 246df22ecd05..18361a38aee7 100644 --- a/drivers/ata/sata_nv.c +++ b/drivers/ata/sata_nv.c | |||
@@ -363,8 +363,6 @@ static const struct ata_port_operations nv_generic_ops = { | |||
363 | .scr_read = nv_scr_read, | 363 | .scr_read = nv_scr_read, |
364 | .scr_write = nv_scr_write, | 364 | .scr_write = nv_scr_write, |
365 | .port_start = ata_port_start, | 365 | .port_start = ata_port_start, |
366 | .port_stop = ata_port_stop, | ||
367 | .host_stop = ata_pci_host_stop, | ||
368 | }; | 366 | }; |
369 | 367 | ||
370 | static const struct ata_port_operations nv_nf2_ops = { | 368 | static const struct ata_port_operations nv_nf2_ops = { |
@@ -390,8 +388,6 @@ static const struct ata_port_operations nv_nf2_ops = { | |||
390 | .scr_read = nv_scr_read, | 388 | .scr_read = nv_scr_read, |
391 | .scr_write = nv_scr_write, | 389 | .scr_write = nv_scr_write, |
392 | .port_start = ata_port_start, | 390 | .port_start = ata_port_start, |
393 | .port_stop = ata_port_stop, | ||
394 | .host_stop = ata_pci_host_stop, | ||
395 | }; | 391 | }; |
396 | 392 | ||
397 | static const struct ata_port_operations nv_ck804_ops = { | 393 | static const struct ata_port_operations nv_ck804_ops = { |
@@ -417,7 +413,6 @@ static const struct ata_port_operations nv_ck804_ops = { | |||
417 | .scr_read = nv_scr_read, | 413 | .scr_read = nv_scr_read, |
418 | .scr_write = nv_scr_write, | 414 | .scr_write = nv_scr_write, |
419 | .port_start = ata_port_start, | 415 | .port_start = ata_port_start, |
420 | .port_stop = ata_port_stop, | ||
421 | .host_stop = nv_ck804_host_stop, | 416 | .host_stop = nv_ck804_host_stop, |
422 | }; | 417 | }; |
423 | 418 | ||
@@ -928,11 +923,9 @@ static int nv_adma_port_start(struct ata_port *ap) | |||
928 | if (rc) | 923 | if (rc) |
929 | return rc; | 924 | return rc; |
930 | 925 | ||
931 | pp = kzalloc(sizeof(*pp), GFP_KERNEL); | 926 | pp = devm_kzalloc(dev, sizeof(*pp), GFP_KERNEL); |
932 | if (!pp) { | 927 | if (!pp) |
933 | rc = -ENOMEM; | 928 | return -ENOMEM; |
934 | goto err_out; | ||
935 | } | ||
936 | 929 | ||
937 | mmio = ap->host->mmio_base + NV_ADMA_PORT + | 930 | mmio = ap->host->mmio_base + NV_ADMA_PORT + |
938 | ap->port_no * NV_ADMA_PORT_SIZE; | 931 | ap->port_no * NV_ADMA_PORT_SIZE; |
@@ -941,13 +934,10 @@ static int nv_adma_port_start(struct ata_port *ap) | |||
941 | pp->notifier_clear_block = pp->gen_block + | 934 | pp->notifier_clear_block = pp->gen_block + |
942 | NV_ADMA_NOTIFIER_CLEAR + (4 * ap->port_no); | 935 | NV_ADMA_NOTIFIER_CLEAR + (4 * ap->port_no); |
943 | 936 | ||
944 | mem = dma_alloc_coherent(dev, NV_ADMA_PORT_PRIV_DMA_SZ, | 937 | mem = dmam_alloc_coherent(dev, NV_ADMA_PORT_PRIV_DMA_SZ, |
945 | &mem_dma, GFP_KERNEL); | 938 | &mem_dma, GFP_KERNEL); |
946 | 939 | if (!mem) | |
947 | if (!mem) { | 940 | return -ENOMEM; |
948 | rc = -ENOMEM; | ||
949 | goto err_out_kfree; | ||
950 | } | ||
951 | memset(mem, 0, NV_ADMA_PORT_PRIV_DMA_SZ); | 941 | memset(mem, 0, NV_ADMA_PORT_PRIV_DMA_SZ); |
952 | 942 | ||
953 | /* | 943 | /* |
@@ -993,28 +983,15 @@ static int nv_adma_port_start(struct ata_port *ap) | |||
993 | readl( mmio + NV_ADMA_CTL ); /* flush posted write */ | 983 | readl( mmio + NV_ADMA_CTL ); /* flush posted write */ |
994 | 984 | ||
995 | return 0; | 985 | return 0; |
996 | |||
997 | err_out_kfree: | ||
998 | kfree(pp); | ||
999 | err_out: | ||
1000 | ata_port_stop(ap); | ||
1001 | return rc; | ||
1002 | } | 986 | } |
1003 | 987 | ||
1004 | static void nv_adma_port_stop(struct ata_port *ap) | 988 | static void nv_adma_port_stop(struct ata_port *ap) |
1005 | { | 989 | { |
1006 | struct device *dev = ap->host->dev; | ||
1007 | struct nv_adma_port_priv *pp = ap->private_data; | 990 | struct nv_adma_port_priv *pp = ap->private_data; |
1008 | void __iomem *mmio = pp->ctl_block; | 991 | void __iomem *mmio = pp->ctl_block; |
1009 | 992 | ||
1010 | VPRINTK("ENTER\n"); | 993 | VPRINTK("ENTER\n"); |
1011 | |||
1012 | writew(0, mmio + NV_ADMA_CTL); | 994 | writew(0, mmio + NV_ADMA_CTL); |
1013 | |||
1014 | ap->private_data = NULL; | ||
1015 | dma_free_coherent(dev, NV_ADMA_PORT_PRIV_DMA_SZ, pp->cpb, pp->cpb_dma); | ||
1016 | kfree(pp); | ||
1017 | ata_port_stop(ap); | ||
1018 | } | 995 | } |
1019 | 996 | ||
1020 | static int nv_adma_port_suspend(struct ata_port *ap, pm_message_t mesg) | 997 | static int nv_adma_port_suspend(struct ata_port *ap, pm_message_t mesg) |
@@ -1433,7 +1410,6 @@ static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
1433 | struct ata_port_info *ppi[2]; | 1410 | struct ata_port_info *ppi[2]; |
1434 | struct ata_probe_ent *probe_ent; | 1411 | struct ata_probe_ent *probe_ent; |
1435 | struct nv_host_priv *hpriv; | 1412 | struct nv_host_priv *hpriv; |
1436 | int pci_dev_busy = 0; | ||
1437 | int rc; | 1413 | int rc; |
1438 | u32 bar; | 1414 | u32 bar; |
1439 | unsigned long base; | 1415 | unsigned long base; |
@@ -1450,14 +1426,14 @@ static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
1450 | if (!printed_version++) | 1426 | if (!printed_version++) |
1451 | dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); | 1427 | dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); |
1452 | 1428 | ||
1453 | rc = pci_enable_device(pdev); | 1429 | rc = pcim_enable_device(pdev); |
1454 | if (rc) | 1430 | if (rc) |
1455 | goto err_out; | 1431 | return rc; |
1456 | 1432 | ||
1457 | rc = pci_request_regions(pdev, DRV_NAME); | 1433 | rc = pci_request_regions(pdev, DRV_NAME); |
1458 | if (rc) { | 1434 | if (rc) { |
1459 | pci_dev_busy = 1; | 1435 | pcim_pin_device(pdev); |
1460 | goto err_out_disable; | 1436 | return rc; |
1461 | } | 1437 | } |
1462 | 1438 | ||
1463 | if(type >= CK804 && adma_enabled) { | 1439 | if(type >= CK804 && adma_enabled) { |
@@ -1471,28 +1447,27 @@ static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
1471 | if(!mask_set) { | 1447 | if(!mask_set) { |
1472 | rc = pci_set_dma_mask(pdev, ATA_DMA_MASK); | 1448 | rc = pci_set_dma_mask(pdev, ATA_DMA_MASK); |
1473 | if (rc) | 1449 | if (rc) |
1474 | goto err_out_regions; | 1450 | return rc; |
1475 | rc = pci_set_consistent_dma_mask(pdev, ATA_DMA_MASK); | 1451 | rc = pci_set_consistent_dma_mask(pdev, ATA_DMA_MASK); |
1476 | if (rc) | 1452 | if (rc) |
1477 | goto err_out_regions; | 1453 | return rc; |
1478 | } | 1454 | } |
1479 | 1455 | ||
1480 | rc = -ENOMEM; | 1456 | rc = -ENOMEM; |
1481 | 1457 | ||
1482 | hpriv = kmalloc(sizeof(*hpriv), GFP_KERNEL); | 1458 | hpriv = devm_kzalloc(&pdev->dev, sizeof(*hpriv), GFP_KERNEL); |
1483 | if (!hpriv) | 1459 | if (!hpriv) |
1484 | goto err_out_regions; | 1460 | return -ENOMEM; |
1485 | 1461 | ||
1486 | ppi[0] = ppi[1] = &nv_port_info[type]; | 1462 | ppi[0] = ppi[1] = &nv_port_info[type]; |
1487 | probe_ent = ata_pci_init_native_mode(pdev, ppi, ATA_PORT_PRIMARY | ATA_PORT_SECONDARY); | 1463 | probe_ent = ata_pci_init_native_mode(pdev, ppi, ATA_PORT_PRIMARY | ATA_PORT_SECONDARY); |
1488 | if (!probe_ent) | 1464 | if (!probe_ent) |
1489 | goto err_out_regions; | 1465 | return -ENOMEM; |
1466 | |||
1467 | probe_ent->mmio_base = pcim_iomap(pdev, 5, 0); | ||
1468 | if (!probe_ent->mmio_base) | ||
1469 | return -EIO; | ||
1490 | 1470 | ||
1491 | probe_ent->mmio_base = pci_iomap(pdev, 5, 0); | ||
1492 | if (!probe_ent->mmio_base) { | ||
1493 | rc = -EIO; | ||
1494 | goto err_out_free_ent; | ||
1495 | } | ||
1496 | probe_ent->private_data = hpriv; | 1471 | probe_ent->private_data = hpriv; |
1497 | hpriv->type = type; | 1472 | hpriv->type = type; |
1498 | 1473 | ||
@@ -1515,28 +1490,15 @@ static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
1515 | if (type == ADMA) { | 1490 | if (type == ADMA) { |
1516 | rc = nv_adma_host_init(probe_ent); | 1491 | rc = nv_adma_host_init(probe_ent); |
1517 | if (rc) | 1492 | if (rc) |
1518 | goto err_out_iounmap; | 1493 | return rc; |
1519 | } | 1494 | } |
1520 | 1495 | ||
1521 | rc = ata_device_add(probe_ent); | 1496 | rc = ata_device_add(probe_ent); |
1522 | if (rc != NV_PORTS) | 1497 | if (rc != NV_PORTS) |
1523 | goto err_out_iounmap; | 1498 | return -ENODEV; |
1524 | |||
1525 | kfree(probe_ent); | ||
1526 | 1499 | ||
1500 | devm_kfree(&pdev->dev, probe_ent); | ||
1527 | return 0; | 1501 | return 0; |
1528 | |||
1529 | err_out_iounmap: | ||
1530 | pci_iounmap(pdev, probe_ent->mmio_base); | ||
1531 | err_out_free_ent: | ||
1532 | kfree(probe_ent); | ||
1533 | err_out_regions: | ||
1534 | pci_release_regions(pdev); | ||
1535 | err_out_disable: | ||
1536 | if (!pci_dev_busy) | ||
1537 | pci_disable_device(pdev); | ||
1538 | err_out: | ||
1539 | return rc; | ||
1540 | } | 1502 | } |
1541 | 1503 | ||
1542 | static void nv_remove_one (struct pci_dev *pdev) | 1504 | static void nv_remove_one (struct pci_dev *pdev) |
@@ -1602,8 +1564,6 @@ static void nv_ck804_host_stop(struct ata_host *host) | |||
1602 | pci_read_config_byte(pdev, NV_MCP_SATA_CFG_20, ®val); | 1564 | pci_read_config_byte(pdev, NV_MCP_SATA_CFG_20, ®val); |
1603 | regval &= ~NV_MCP_SATA_CFG_20_SATA_SPACE_EN; | 1565 | regval &= ~NV_MCP_SATA_CFG_20_SATA_SPACE_EN; |
1604 | pci_write_config_byte(pdev, NV_MCP_SATA_CFG_20, regval); | 1566 | pci_write_config_byte(pdev, NV_MCP_SATA_CFG_20, regval); |
1605 | |||
1606 | ata_pci_host_stop(host); | ||
1607 | } | 1567 | } |
1608 | 1568 | ||
1609 | static void nv_adma_host_stop(struct ata_host *host) | 1569 | static void nv_adma_host_stop(struct ata_host *host) |
diff --git a/drivers/ata/sata_promise.c b/drivers/ata/sata_promise.c index 32ae03e9081b..e09c609d4961 100644 --- a/drivers/ata/sata_promise.c +++ b/drivers/ata/sata_promise.c | |||
@@ -43,7 +43,6 @@ | |||
43 | #include <scsi/scsi_host.h> | 43 | #include <scsi/scsi_host.h> |
44 | #include <scsi/scsi_cmnd.h> | 44 | #include <scsi/scsi_cmnd.h> |
45 | #include <linux/libata.h> | 45 | #include <linux/libata.h> |
46 | #include <asm/io.h> | ||
47 | #include "sata_promise.h" | 46 | #include "sata_promise.h" |
48 | 47 | ||
49 | #define DRV_NAME "sata_promise" | 48 | #define DRV_NAME "sata_promise" |
@@ -121,7 +120,6 @@ static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *e | |||
121 | static irqreturn_t pdc_interrupt (int irq, void *dev_instance); | 120 | static irqreturn_t pdc_interrupt (int irq, void *dev_instance); |
122 | static void pdc_eng_timeout(struct ata_port *ap); | 121 | static void pdc_eng_timeout(struct ata_port *ap); |
123 | static int pdc_port_start(struct ata_port *ap); | 122 | static int pdc_port_start(struct ata_port *ap); |
124 | static void pdc_port_stop(struct ata_port *ap); | ||
125 | static void pdc_pata_phy_reset(struct ata_port *ap); | 123 | static void pdc_pata_phy_reset(struct ata_port *ap); |
126 | static void pdc_qc_prep(struct ata_queued_cmd *qc); | 124 | static void pdc_qc_prep(struct ata_queued_cmd *qc); |
127 | static void pdc_tf_load_mmio(struct ata_port *ap, const struct ata_taskfile *tf); | 125 | static void pdc_tf_load_mmio(struct ata_port *ap, const struct ata_taskfile *tf); |
@@ -130,7 +128,6 @@ static int pdc_check_atapi_dma(struct ata_queued_cmd *qc); | |||
130 | static int pdc_old_check_atapi_dma(struct ata_queued_cmd *qc); | 128 | static int pdc_old_check_atapi_dma(struct ata_queued_cmd *qc); |
131 | static void pdc_irq_clear(struct ata_port *ap); | 129 | static void pdc_irq_clear(struct ata_port *ap); |
132 | static unsigned int pdc_qc_issue_prot(struct ata_queued_cmd *qc); | 130 | static unsigned int pdc_qc_issue_prot(struct ata_queued_cmd *qc); |
133 | static void pdc_host_stop(struct ata_host *host); | ||
134 | static void pdc_freeze(struct ata_port *ap); | 131 | static void pdc_freeze(struct ata_port *ap); |
135 | static void pdc_thaw(struct ata_port *ap); | 132 | static void pdc_thaw(struct ata_port *ap); |
136 | static void pdc_error_handler(struct ata_port *ap); | 133 | static void pdc_error_handler(struct ata_port *ap); |
@@ -177,8 +174,6 @@ static const struct ata_port_operations pdc_sata_ops = { | |||
177 | .scr_read = pdc_sata_scr_read, | 174 | .scr_read = pdc_sata_scr_read, |
178 | .scr_write = pdc_sata_scr_write, | 175 | .scr_write = pdc_sata_scr_write, |
179 | .port_start = pdc_port_start, | 176 | .port_start = pdc_port_start, |
180 | .port_stop = pdc_port_stop, | ||
181 | .host_stop = pdc_host_stop, | ||
182 | }; | 177 | }; |
183 | 178 | ||
184 | /* First-generation chips need a more restrictive ->check_atapi_dma op */ | 179 | /* First-generation chips need a more restrictive ->check_atapi_dma op */ |
@@ -204,8 +199,6 @@ static const struct ata_port_operations pdc_old_sata_ops = { | |||
204 | .scr_read = pdc_sata_scr_read, | 199 | .scr_read = pdc_sata_scr_read, |
205 | .scr_write = pdc_sata_scr_write, | 200 | .scr_write = pdc_sata_scr_write, |
206 | .port_start = pdc_port_start, | 201 | .port_start = pdc_port_start, |
207 | .port_stop = pdc_port_stop, | ||
208 | .host_stop = pdc_host_stop, | ||
209 | }; | 202 | }; |
210 | 203 | ||
211 | static const struct ata_port_operations pdc_pata_ops = { | 204 | static const struct ata_port_operations pdc_pata_ops = { |
@@ -227,8 +220,6 @@ static const struct ata_port_operations pdc_pata_ops = { | |||
227 | .irq_clear = pdc_irq_clear, | 220 | .irq_clear = pdc_irq_clear, |
228 | 221 | ||
229 | .port_start = pdc_port_start, | 222 | .port_start = pdc_port_start, |
230 | .port_stop = pdc_port_stop, | ||
231 | .host_stop = pdc_host_stop, | ||
232 | }; | 223 | }; |
233 | 224 | ||
234 | static const struct ata_port_info pdc_port_info[] = { | 225 | static const struct ata_port_info pdc_port_info[] = { |
@@ -332,17 +323,13 @@ static int pdc_port_start(struct ata_port *ap) | |||
332 | if (rc) | 323 | if (rc) |
333 | return rc; | 324 | return rc; |
334 | 325 | ||
335 | pp = kzalloc(sizeof(*pp), GFP_KERNEL); | 326 | pp = devm_kzalloc(dev, sizeof(*pp), GFP_KERNEL); |
336 | if (!pp) { | 327 | if (!pp) |
337 | rc = -ENOMEM; | 328 | return -ENOMEM; |
338 | goto err_out; | ||
339 | } | ||
340 | 329 | ||
341 | pp->pkt = dma_alloc_coherent(dev, 128, &pp->pkt_dma, GFP_KERNEL); | 330 | pp->pkt = dmam_alloc_coherent(dev, 128, &pp->pkt_dma, GFP_KERNEL); |
342 | if (!pp->pkt) { | 331 | if (!pp->pkt) |
343 | rc = -ENOMEM; | 332 | return -ENOMEM; |
344 | goto err_out_kfree; | ||
345 | } | ||
346 | 333 | ||
347 | ap->private_data = pp; | 334 | ap->private_data = pp; |
348 | 335 | ||
@@ -357,37 +344,8 @@ static int pdc_port_start(struct ata_port *ap) | |||
357 | } | 344 | } |
358 | 345 | ||
359 | return 0; | 346 | return 0; |
360 | |||
361 | err_out_kfree: | ||
362 | kfree(pp); | ||
363 | err_out: | ||
364 | ata_port_stop(ap); | ||
365 | return rc; | ||
366 | } | 347 | } |
367 | 348 | ||
368 | |||
369 | static void pdc_port_stop(struct ata_port *ap) | ||
370 | { | ||
371 | struct device *dev = ap->host->dev; | ||
372 | struct pdc_port_priv *pp = ap->private_data; | ||
373 | |||
374 | ap->private_data = NULL; | ||
375 | dma_free_coherent(dev, 128, pp->pkt, pp->pkt_dma); | ||
376 | kfree(pp); | ||
377 | ata_port_stop(ap); | ||
378 | } | ||
379 | |||
380 | |||
381 | static void pdc_host_stop(struct ata_host *host) | ||
382 | { | ||
383 | struct pdc_host_priv *hp = host->private_data; | ||
384 | |||
385 | ata_pci_host_stop(host); | ||
386 | |||
387 | kfree(hp); | ||
388 | } | ||
389 | |||
390 | |||
391 | static void pdc_reset_port(struct ata_port *ap) | 349 | static void pdc_reset_port(struct ata_port *ap) |
392 | { | 350 | { |
393 | void __iomem *mmio = (void __iomem *) ap->ioaddr.cmd_addr + PDC_CTLSTAT; | 351 | void __iomem *mmio = (void __iomem *) ap->ioaddr.cmd_addr + PDC_CTLSTAT; |
@@ -924,56 +882,49 @@ static void pdc_host_init(unsigned int chip_id, struct ata_probe_ent *pe) | |||
924 | static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | 882 | static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) |
925 | { | 883 | { |
926 | static int printed_version; | 884 | static int printed_version; |
927 | struct ata_probe_ent *probe_ent = NULL; | 885 | struct ata_probe_ent *probe_ent; |
928 | struct pdc_host_priv *hp; | 886 | struct pdc_host_priv *hp; |
929 | unsigned long base; | 887 | unsigned long base; |
930 | void __iomem *mmio_base; | 888 | void __iomem *mmio_base; |
931 | unsigned int board_idx = (unsigned int) ent->driver_data; | 889 | unsigned int board_idx = (unsigned int) ent->driver_data; |
932 | int pci_dev_busy = 0; | ||
933 | int rc; | 890 | int rc; |
934 | u8 tmp; | 891 | u8 tmp; |
935 | 892 | ||
936 | if (!printed_version++) | 893 | if (!printed_version++) |
937 | dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); | 894 | dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); |
938 | 895 | ||
939 | rc = pci_enable_device(pdev); | 896 | rc = pcim_enable_device(pdev); |
940 | if (rc) | 897 | if (rc) |
941 | return rc; | 898 | return rc; |
942 | 899 | ||
943 | rc = pci_request_regions(pdev, DRV_NAME); | 900 | rc = pci_request_regions(pdev, DRV_NAME); |
944 | if (rc) { | 901 | if (rc) { |
945 | pci_dev_busy = 1; | 902 | pcim_pin_device(pdev); |
946 | goto err_out; | 903 | return rc; |
947 | } | 904 | } |
948 | 905 | ||
949 | rc = pci_set_dma_mask(pdev, ATA_DMA_MASK); | 906 | rc = pci_set_dma_mask(pdev, ATA_DMA_MASK); |
950 | if (rc) | 907 | if (rc) |
951 | goto err_out_regions; | 908 | return rc; |
952 | rc = pci_set_consistent_dma_mask(pdev, ATA_DMA_MASK); | 909 | rc = pci_set_consistent_dma_mask(pdev, ATA_DMA_MASK); |
953 | if (rc) | 910 | if (rc) |
954 | goto err_out_regions; | 911 | return rc; |
955 | 912 | ||
956 | probe_ent = kzalloc(sizeof(*probe_ent), GFP_KERNEL); | 913 | probe_ent = devm_kzalloc(&pdev->dev, sizeof(*probe_ent), GFP_KERNEL); |
957 | if (probe_ent == NULL) { | 914 | if (probe_ent == NULL) |
958 | rc = -ENOMEM; | 915 | return -ENOMEM; |
959 | goto err_out_regions; | ||
960 | } | ||
961 | 916 | ||
962 | probe_ent->dev = pci_dev_to_dev(pdev); | 917 | probe_ent->dev = pci_dev_to_dev(pdev); |
963 | INIT_LIST_HEAD(&probe_ent->node); | 918 | INIT_LIST_HEAD(&probe_ent->node); |
964 | 919 | ||
965 | mmio_base = pci_iomap(pdev, 3, 0); | 920 | mmio_base = pcim_iomap(pdev, 3, 0); |
966 | if (mmio_base == NULL) { | 921 | if (mmio_base == NULL) |
967 | rc = -ENOMEM; | 922 | return -ENOMEM; |
968 | goto err_out_free_ent; | ||
969 | } | ||
970 | base = (unsigned long) mmio_base; | 923 | base = (unsigned long) mmio_base; |
971 | 924 | ||
972 | hp = kzalloc(sizeof(*hp), GFP_KERNEL); | 925 | hp = devm_kzalloc(&pdev->dev, sizeof(*hp), GFP_KERNEL); |
973 | if (hp == NULL) { | 926 | if (hp == NULL) |
974 | rc = -ENOMEM; | 927 | return -ENOMEM; |
975 | goto err_out_free_ent; | ||
976 | } | ||
977 | 928 | ||
978 | probe_ent->private_data = hp; | 929 | probe_ent->private_data = hp; |
979 | 930 | ||
@@ -1043,22 +994,11 @@ static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *e | |||
1043 | /* initialize adapter */ | 994 | /* initialize adapter */ |
1044 | pdc_host_init(board_idx, probe_ent); | 995 | pdc_host_init(board_idx, probe_ent); |
1045 | 996 | ||
1046 | /* FIXME: Need any other frees than hp? */ | ||
1047 | if (!ata_device_add(probe_ent)) | 997 | if (!ata_device_add(probe_ent)) |
1048 | kfree(hp); | 998 | return -ENODEV; |
1049 | |||
1050 | kfree(probe_ent); | ||
1051 | 999 | ||
1000 | devm_kfree(&pdev->dev, probe_ent); | ||
1052 | return 0; | 1001 | return 0; |
1053 | |||
1054 | err_out_free_ent: | ||
1055 | kfree(probe_ent); | ||
1056 | err_out_regions: | ||
1057 | pci_release_regions(pdev); | ||
1058 | err_out: | ||
1059 | if (!pci_dev_busy) | ||
1060 | pci_disable_device(pdev); | ||
1061 | return rc; | ||
1062 | } | 1002 | } |
1063 | 1003 | ||
1064 | 1004 | ||
diff --git a/drivers/ata/sata_qstor.c b/drivers/ata/sata_qstor.c index 0292a79f9747..339f61648af6 100644 --- a/drivers/ata/sata_qstor.c +++ b/drivers/ata/sata_qstor.c | |||
@@ -37,7 +37,6 @@ | |||
37 | #include <linux/sched.h> | 37 | #include <linux/sched.h> |
38 | #include <linux/device.h> | 38 | #include <linux/device.h> |
39 | #include <scsi/scsi_host.h> | 39 | #include <scsi/scsi_host.h> |
40 | #include <asm/io.h> | ||
41 | #include <linux/libata.h> | 40 | #include <linux/libata.h> |
42 | 41 | ||
43 | #define DRV_NAME "sata_qstor" | 42 | #define DRV_NAME "sata_qstor" |
@@ -117,7 +116,6 @@ static int qs_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *en | |||
117 | static irqreturn_t qs_intr (int irq, void *dev_instance); | 116 | static irqreturn_t qs_intr (int irq, void *dev_instance); |
118 | static int qs_port_start(struct ata_port *ap); | 117 | static int qs_port_start(struct ata_port *ap); |
119 | static void qs_host_stop(struct ata_host *host); | 118 | static void qs_host_stop(struct ata_host *host); |
120 | static void qs_port_stop(struct ata_port *ap); | ||
121 | static void qs_phy_reset(struct ata_port *ap); | 119 | static void qs_phy_reset(struct ata_port *ap); |
122 | static void qs_qc_prep(struct ata_queued_cmd *qc); | 120 | static void qs_qc_prep(struct ata_queued_cmd *qc); |
123 | static unsigned int qs_qc_issue(struct ata_queued_cmd *qc); | 121 | static unsigned int qs_qc_issue(struct ata_queued_cmd *qc); |
@@ -164,7 +162,6 @@ static const struct ata_port_operations qs_ata_ops = { | |||
164 | .scr_read = qs_scr_read, | 162 | .scr_read = qs_scr_read, |
165 | .scr_write = qs_scr_write, | 163 | .scr_write = qs_scr_write, |
166 | .port_start = qs_port_start, | 164 | .port_start = qs_port_start, |
167 | .port_stop = qs_port_stop, | ||
168 | .host_stop = qs_host_stop, | 165 | .host_stop = qs_host_stop, |
169 | .bmdma_stop = qs_bmdma_stop, | 166 | .bmdma_stop = qs_bmdma_stop, |
170 | .bmdma_status = qs_bmdma_status, | 167 | .bmdma_status = qs_bmdma_status, |
@@ -501,17 +498,13 @@ static int qs_port_start(struct ata_port *ap) | |||
501 | if (rc) | 498 | if (rc) |
502 | return rc; | 499 | return rc; |
503 | qs_enter_reg_mode(ap); | 500 | qs_enter_reg_mode(ap); |
504 | pp = kzalloc(sizeof(*pp), GFP_KERNEL); | 501 | pp = devm_kzalloc(dev, sizeof(*pp), GFP_KERNEL); |
505 | if (!pp) { | 502 | if (!pp) |
506 | rc = -ENOMEM; | 503 | return -ENOMEM; |
507 | goto err_out; | 504 | pp->pkt = dmam_alloc_coherent(dev, QS_PKT_BYTES, &pp->pkt_dma, |
508 | } | 505 | GFP_KERNEL); |
509 | pp->pkt = dma_alloc_coherent(dev, QS_PKT_BYTES, &pp->pkt_dma, | 506 | if (!pp->pkt) |
510 | GFP_KERNEL); | 507 | return -ENOMEM; |
511 | if (!pp->pkt) { | ||
512 | rc = -ENOMEM; | ||
513 | goto err_out_kfree; | ||
514 | } | ||
515 | memset(pp->pkt, 0, QS_PKT_BYTES); | 508 | memset(pp->pkt, 0, QS_PKT_BYTES); |
516 | ap->private_data = pp; | 509 | ap->private_data = pp; |
517 | 510 | ||
@@ -519,38 +512,14 @@ static int qs_port_start(struct ata_port *ap) | |||
519 | writel((u32) addr, chan + QS_CCF_CPBA); | 512 | writel((u32) addr, chan + QS_CCF_CPBA); |
520 | writel((u32)(addr >> 32), chan + QS_CCF_CPBA + 4); | 513 | writel((u32)(addr >> 32), chan + QS_CCF_CPBA + 4); |
521 | return 0; | 514 | return 0; |
522 | |||
523 | err_out_kfree: | ||
524 | kfree(pp); | ||
525 | err_out: | ||
526 | ata_port_stop(ap); | ||
527 | return rc; | ||
528 | } | ||
529 | |||
530 | static void qs_port_stop(struct ata_port *ap) | ||
531 | { | ||
532 | struct device *dev = ap->host->dev; | ||
533 | struct qs_port_priv *pp = ap->private_data; | ||
534 | |||
535 | if (pp != NULL) { | ||
536 | ap->private_data = NULL; | ||
537 | if (pp->pkt != NULL) | ||
538 | dma_free_coherent(dev, QS_PKT_BYTES, pp->pkt, | ||
539 | pp->pkt_dma); | ||
540 | kfree(pp); | ||
541 | } | ||
542 | ata_port_stop(ap); | ||
543 | } | 515 | } |
544 | 516 | ||
545 | static void qs_host_stop(struct ata_host *host) | 517 | static void qs_host_stop(struct ata_host *host) |
546 | { | 518 | { |
547 | void __iomem *mmio_base = host->mmio_base; | 519 | void __iomem *mmio_base = host->mmio_base; |
548 | struct pci_dev *pdev = to_pci_dev(host->dev); | ||
549 | 520 | ||
550 | writeb(0, mmio_base + QS_HCT_CTRL); /* disable host interrupts */ | 521 | writeb(0, mmio_base + QS_HCT_CTRL); /* disable host interrupts */ |
551 | writeb(QS_CNFG3_GSRST, mmio_base + QS_HCF_CNFG3); /* global reset */ | 522 | writeb(QS_CNFG3_GSRST, mmio_base + QS_HCF_CNFG3); /* global reset */ |
552 | |||
553 | pci_iounmap(pdev, mmio_base); | ||
554 | } | 523 | } |
555 | 524 | ||
556 | static void qs_host_init(unsigned int chip_id, struct ata_probe_ent *pe) | 525 | static void qs_host_init(unsigned int chip_id, struct ata_probe_ent *pe) |
@@ -638,36 +607,29 @@ static int qs_ata_init_one(struct pci_dev *pdev, | |||
638 | if (!printed_version++) | 607 | if (!printed_version++) |
639 | dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); | 608 | dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); |
640 | 609 | ||
641 | rc = pci_enable_device(pdev); | 610 | rc = pcim_enable_device(pdev); |
642 | if (rc) | 611 | if (rc) |
643 | return rc; | 612 | return rc; |
644 | 613 | ||
645 | rc = pci_request_regions(pdev, DRV_NAME); | 614 | rc = pci_request_regions(pdev, DRV_NAME); |
646 | if (rc) | 615 | if (rc) |
647 | goto err_out; | 616 | return rc; |
648 | 617 | ||
649 | if ((pci_resource_flags(pdev, 4) & IORESOURCE_MEM) == 0) { | 618 | if ((pci_resource_flags(pdev, 4) & IORESOURCE_MEM) == 0) |
650 | rc = -ENODEV; | 619 | return -ENODEV; |
651 | goto err_out_regions; | ||
652 | } | ||
653 | 620 | ||
654 | mmio_base = pci_iomap(pdev, 4, 0); | 621 | mmio_base = pcim_iomap(pdev, 4, 0); |
655 | if (mmio_base == NULL) { | 622 | if (mmio_base == NULL) |
656 | rc = -ENOMEM; | 623 | return -ENOMEM; |
657 | goto err_out_regions; | ||
658 | } | ||
659 | 624 | ||
660 | rc = qs_set_dma_masks(pdev, mmio_base); | 625 | rc = qs_set_dma_masks(pdev, mmio_base); |
661 | if (rc) | 626 | if (rc) |
662 | goto err_out_iounmap; | 627 | return rc; |
663 | 628 | ||
664 | probe_ent = kmalloc(sizeof(*probe_ent), GFP_KERNEL); | 629 | probe_ent = devm_kzalloc(&pdev->dev, sizeof(*probe_ent), GFP_KERNEL); |
665 | if (probe_ent == NULL) { | 630 | if (probe_ent == NULL) |
666 | rc = -ENOMEM; | 631 | return -ENOMEM; |
667 | goto err_out_iounmap; | ||
668 | } | ||
669 | 632 | ||
670 | memset(probe_ent, 0, sizeof(*probe_ent)); | ||
671 | probe_ent->dev = pci_dev_to_dev(pdev); | 633 | probe_ent->dev = pci_dev_to_dev(pdev); |
672 | INIT_LIST_HEAD(&probe_ent->node); | 634 | INIT_LIST_HEAD(&probe_ent->node); |
673 | 635 | ||
@@ -694,19 +656,11 @@ static int qs_ata_init_one(struct pci_dev *pdev, | |||
694 | /* initialize adapter */ | 656 | /* initialize adapter */ |
695 | qs_host_init(board_idx, probe_ent); | 657 | qs_host_init(board_idx, probe_ent); |
696 | 658 | ||
697 | rc = ata_device_add(probe_ent); | 659 | if (ata_device_add(probe_ent) != QS_PORTS) |
698 | kfree(probe_ent); | 660 | return -EIO; |
699 | if (rc != QS_PORTS) | ||
700 | goto err_out_iounmap; | ||
701 | return 0; | ||
702 | 661 | ||
703 | err_out_iounmap: | 662 | devm_kfree(&pdev->dev, probe_ent); |
704 | pci_iounmap(pdev, mmio_base); | 663 | return 0; |
705 | err_out_regions: | ||
706 | pci_release_regions(pdev); | ||
707 | err_out: | ||
708 | pci_disable_device(pdev); | ||
709 | return rc; | ||
710 | } | 664 | } |
711 | 665 | ||
712 | static int __init qs_ata_init(void) | 666 | static int __init qs_ata_init(void) |
diff --git a/drivers/ata/sata_sil.c b/drivers/ata/sata_sil.c index 1f3fdcf29876..00f2465dcdce 100644 --- a/drivers/ata/sata_sil.c +++ b/drivers/ata/sata_sil.c | |||
@@ -210,8 +210,6 @@ static const struct ata_port_operations sil_ops = { | |||
210 | .scr_read = sil_scr_read, | 210 | .scr_read = sil_scr_read, |
211 | .scr_write = sil_scr_write, | 211 | .scr_write = sil_scr_write, |
212 | .port_start = ata_port_start, | 212 | .port_start = ata_port_start, |
213 | .port_stop = ata_port_stop, | ||
214 | .host_stop = ata_pci_host_stop, | ||
215 | }; | 213 | }; |
216 | 214 | ||
217 | static const struct ata_port_info sil_port_info[] = { | 215 | static const struct ata_port_info sil_port_info[] = { |
@@ -621,38 +619,36 @@ static void sil_init_controller(struct pci_dev *pdev, | |||
621 | static int sil_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | 619 | static int sil_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) |
622 | { | 620 | { |
623 | static int printed_version; | 621 | static int printed_version; |
624 | struct ata_probe_ent *probe_ent = NULL; | 622 | struct device *dev = &pdev->dev; |
623 | struct ata_probe_ent *probe_ent; | ||
625 | unsigned long base; | 624 | unsigned long base; |
626 | void __iomem *mmio_base; | 625 | void __iomem *mmio_base; |
627 | int rc; | 626 | int rc; |
628 | unsigned int i; | 627 | unsigned int i; |
629 | int pci_dev_busy = 0; | ||
630 | 628 | ||
631 | if (!printed_version++) | 629 | if (!printed_version++) |
632 | dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); | 630 | dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); |
633 | 631 | ||
634 | rc = pci_enable_device(pdev); | 632 | rc = pcim_enable_device(pdev); |
635 | if (rc) | 633 | if (rc) |
636 | return rc; | 634 | return rc; |
637 | 635 | ||
638 | rc = pci_request_regions(pdev, DRV_NAME); | 636 | rc = pci_request_regions(pdev, DRV_NAME); |
639 | if (rc) { | 637 | if (rc) { |
640 | pci_dev_busy = 1; | 638 | pcim_pin_device(pdev); |
641 | goto err_out; | 639 | return rc; |
642 | } | 640 | } |
643 | 641 | ||
644 | rc = pci_set_dma_mask(pdev, ATA_DMA_MASK); | 642 | rc = pci_set_dma_mask(pdev, ATA_DMA_MASK); |
645 | if (rc) | 643 | if (rc) |
646 | goto err_out_regions; | 644 | return rc; |
647 | rc = pci_set_consistent_dma_mask(pdev, ATA_DMA_MASK); | 645 | rc = pci_set_consistent_dma_mask(pdev, ATA_DMA_MASK); |
648 | if (rc) | 646 | if (rc) |
649 | goto err_out_regions; | 647 | return rc; |
650 | 648 | ||
651 | probe_ent = kzalloc(sizeof(*probe_ent), GFP_KERNEL); | 649 | probe_ent = devm_kzalloc(dev, sizeof(*probe_ent), GFP_KERNEL); |
652 | if (probe_ent == NULL) { | 650 | if (probe_ent == NULL) |
653 | rc = -ENOMEM; | 651 | return -ENOMEM; |
654 | goto err_out_regions; | ||
655 | } | ||
656 | 652 | ||
657 | INIT_LIST_HEAD(&probe_ent->node); | 653 | INIT_LIST_HEAD(&probe_ent->node); |
658 | probe_ent->dev = pci_dev_to_dev(pdev); | 654 | probe_ent->dev = pci_dev_to_dev(pdev); |
@@ -666,11 +662,9 @@ static int sil_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
666 | probe_ent->irq_flags = IRQF_SHARED; | 662 | probe_ent->irq_flags = IRQF_SHARED; |
667 | probe_ent->port_flags = sil_port_info[ent->driver_data].flags; | 663 | probe_ent->port_flags = sil_port_info[ent->driver_data].flags; |
668 | 664 | ||
669 | mmio_base = pci_iomap(pdev, 5, 0); | 665 | mmio_base = pcim_iomap(pdev, 5, 0); |
670 | if (mmio_base == NULL) { | 666 | if (mmio_base == NULL) |
671 | rc = -ENOMEM; | 667 | return -ENOMEM; |
672 | goto err_out_free_ent; | ||
673 | } | ||
674 | 668 | ||
675 | probe_ent->mmio_base = mmio_base; | 669 | probe_ent->mmio_base = mmio_base; |
676 | 670 | ||
@@ -690,20 +684,11 @@ static int sil_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
690 | 684 | ||
691 | pci_set_master(pdev); | 685 | pci_set_master(pdev); |
692 | 686 | ||
693 | /* FIXME: check ata_device_add return value */ | 687 | if (!ata_device_add(probe_ent)) |
694 | ata_device_add(probe_ent); | 688 | return -ENODEV; |
695 | kfree(probe_ent); | ||
696 | 689 | ||
690 | devm_kfree(dev, probe_ent); | ||
697 | return 0; | 691 | return 0; |
698 | |||
699 | err_out_free_ent: | ||
700 | kfree(probe_ent); | ||
701 | err_out_regions: | ||
702 | pci_release_regions(pdev); | ||
703 | err_out: | ||
704 | if (!pci_dev_busy) | ||
705 | pci_disable_device(pdev); | ||
706 | return rc; | ||
707 | } | 692 | } |
708 | 693 | ||
709 | #ifdef CONFIG_PM | 694 | #ifdef CONFIG_PM |
diff --git a/drivers/ata/sata_sil24.c b/drivers/ata/sata_sil24.c index da982ed4bc47..c7a3c0275bee 100644 --- a/drivers/ata/sata_sil24.c +++ b/drivers/ata/sata_sil24.c | |||
@@ -28,7 +28,6 @@ | |||
28 | #include <scsi/scsi_host.h> | 28 | #include <scsi/scsi_host.h> |
29 | #include <scsi/scsi_cmnd.h> | 29 | #include <scsi/scsi_cmnd.h> |
30 | #include <linux/libata.h> | 30 | #include <linux/libata.h> |
31 | #include <asm/io.h> | ||
32 | 31 | ||
33 | #define DRV_NAME "sata_sil24" | 32 | #define DRV_NAME "sata_sil24" |
34 | #define DRV_VERSION "0.3" | 33 | #define DRV_VERSION "0.3" |
@@ -341,8 +340,6 @@ static void sil24_thaw(struct ata_port *ap); | |||
341 | static void sil24_error_handler(struct ata_port *ap); | 340 | static void sil24_error_handler(struct ata_port *ap); |
342 | static void sil24_post_internal_cmd(struct ata_queued_cmd *qc); | 341 | static void sil24_post_internal_cmd(struct ata_queued_cmd *qc); |
343 | static int sil24_port_start(struct ata_port *ap); | 342 | static int sil24_port_start(struct ata_port *ap); |
344 | static void sil24_port_stop(struct ata_port *ap); | ||
345 | static void sil24_host_stop(struct ata_host *host); | ||
346 | static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent); | 343 | static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent); |
347 | #ifdef CONFIG_PM | 344 | #ifdef CONFIG_PM |
348 | static int sil24_pci_device_resume(struct pci_dev *pdev); | 345 | static int sil24_pci_device_resume(struct pci_dev *pdev); |
@@ -362,7 +359,7 @@ static struct pci_driver sil24_pci_driver = { | |||
362 | .name = DRV_NAME, | 359 | .name = DRV_NAME, |
363 | .id_table = sil24_pci_tbl, | 360 | .id_table = sil24_pci_tbl, |
364 | .probe = sil24_init_one, | 361 | .probe = sil24_init_one, |
365 | .remove = ata_pci_remove_one, /* safe? */ | 362 | .remove = ata_pci_remove_one, |
366 | #ifdef CONFIG_PM | 363 | #ifdef CONFIG_PM |
367 | .suspend = ata_pci_device_suspend, | 364 | .suspend = ata_pci_device_suspend, |
368 | .resume = sil24_pci_device_resume, | 365 | .resume = sil24_pci_device_resume, |
@@ -416,8 +413,6 @@ static const struct ata_port_operations sil24_ops = { | |||
416 | .post_internal_cmd = sil24_post_internal_cmd, | 413 | .post_internal_cmd = sil24_post_internal_cmd, |
417 | 414 | ||
418 | .port_start = sil24_port_start, | 415 | .port_start = sil24_port_start, |
419 | .port_stop = sil24_port_stop, | ||
420 | .host_stop = sil24_host_stop, | ||
421 | }; | 416 | }; |
422 | 417 | ||
423 | /* | 418 | /* |
@@ -938,13 +933,6 @@ static void sil24_post_internal_cmd(struct ata_queued_cmd *qc) | |||
938 | sil24_init_port(ap); | 933 | sil24_init_port(ap); |
939 | } | 934 | } |
940 | 935 | ||
941 | static inline void sil24_cblk_free(struct sil24_port_priv *pp, struct device *dev) | ||
942 | { | ||
943 | const size_t cb_size = sizeof(*pp->cmd_block) * SIL24_MAX_CMDS; | ||
944 | |||
945 | dma_free_coherent(dev, cb_size, pp->cmd_block, pp->cmd_block_dma); | ||
946 | } | ||
947 | |||
948 | static int sil24_port_start(struct ata_port *ap) | 936 | static int sil24_port_start(struct ata_port *ap) |
949 | { | 937 | { |
950 | struct device *dev = ap->host->dev; | 938 | struct device *dev = ap->host->dev; |
@@ -952,22 +940,22 @@ static int sil24_port_start(struct ata_port *ap) | |||
952 | union sil24_cmd_block *cb; | 940 | union sil24_cmd_block *cb; |
953 | size_t cb_size = sizeof(*cb) * SIL24_MAX_CMDS; | 941 | size_t cb_size = sizeof(*cb) * SIL24_MAX_CMDS; |
954 | dma_addr_t cb_dma; | 942 | dma_addr_t cb_dma; |
955 | int rc = -ENOMEM; | 943 | int rc; |
956 | 944 | ||
957 | pp = kzalloc(sizeof(*pp), GFP_KERNEL); | 945 | pp = devm_kzalloc(dev, sizeof(*pp), GFP_KERNEL); |
958 | if (!pp) | 946 | if (!pp) |
959 | goto err_out; | 947 | return -ENOMEM; |
960 | 948 | ||
961 | pp->tf.command = ATA_DRDY; | 949 | pp->tf.command = ATA_DRDY; |
962 | 950 | ||
963 | cb = dma_alloc_coherent(dev, cb_size, &cb_dma, GFP_KERNEL); | 951 | cb = dmam_alloc_coherent(dev, cb_size, &cb_dma, GFP_KERNEL); |
964 | if (!cb) | 952 | if (!cb) |
965 | goto err_out_pp; | 953 | return -ENOMEM; |
966 | memset(cb, 0, cb_size); | 954 | memset(cb, 0, cb_size); |
967 | 955 | ||
968 | rc = ata_pad_alloc(ap, dev); | 956 | rc = ata_pad_alloc(ap, dev); |
969 | if (rc) | 957 | if (rc) |
970 | goto err_out_pad; | 958 | return rc; |
971 | 959 | ||
972 | pp->cmd_block = cb; | 960 | pp->cmd_block = cb; |
973 | pp->cmd_block_dma = cb_dma; | 961 | pp->cmd_block_dma = cb_dma; |
@@ -975,33 +963,6 @@ static int sil24_port_start(struct ata_port *ap) | |||
975 | ap->private_data = pp; | 963 | ap->private_data = pp; |
976 | 964 | ||
977 | return 0; | 965 | return 0; |
978 | |||
979 | err_out_pad: | ||
980 | sil24_cblk_free(pp, dev); | ||
981 | err_out_pp: | ||
982 | kfree(pp); | ||
983 | err_out: | ||
984 | return rc; | ||
985 | } | ||
986 | |||
987 | static void sil24_port_stop(struct ata_port *ap) | ||
988 | { | ||
989 | struct device *dev = ap->host->dev; | ||
990 | struct sil24_port_priv *pp = ap->private_data; | ||
991 | |||
992 | sil24_cblk_free(pp, dev); | ||
993 | ata_pad_free(ap, dev); | ||
994 | kfree(pp); | ||
995 | } | ||
996 | |||
997 | static void sil24_host_stop(struct ata_host *host) | ||
998 | { | ||
999 | struct sil24_host_priv *hpriv = host->private_data; | ||
1000 | struct pci_dev *pdev = to_pci_dev(host->dev); | ||
1001 | |||
1002 | pci_iounmap(pdev, hpriv->host_base); | ||
1003 | pci_iounmap(pdev, hpriv->port_base); | ||
1004 | kfree(hpriv); | ||
1005 | } | 966 | } |
1006 | 967 | ||
1007 | static void sil24_init_controller(struct pci_dev *pdev, int n_ports, | 968 | static void sil24_init_controller(struct pci_dev *pdev, int n_ports, |
@@ -1066,43 +1027,38 @@ static void sil24_init_controller(struct pci_dev *pdev, int n_ports, | |||
1066 | static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | 1027 | static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) |
1067 | { | 1028 | { |
1068 | static int printed_version = 0; | 1029 | static int printed_version = 0; |
1030 | struct device *dev = &pdev->dev; | ||
1069 | unsigned int board_id = (unsigned int)ent->driver_data; | 1031 | unsigned int board_id = (unsigned int)ent->driver_data; |
1070 | struct ata_port_info *pinfo = &sil24_port_info[board_id]; | 1032 | struct ata_port_info *pinfo = &sil24_port_info[board_id]; |
1071 | struct ata_probe_ent *probe_ent = NULL; | 1033 | struct ata_probe_ent *probe_ent; |
1072 | struct sil24_host_priv *hpriv = NULL; | 1034 | struct sil24_host_priv *hpriv; |
1073 | void __iomem *host_base = NULL; | 1035 | void __iomem *host_base; |
1074 | void __iomem *port_base = NULL; | 1036 | void __iomem *port_base; |
1075 | int i, rc; | 1037 | int i, rc; |
1076 | u32 tmp; | 1038 | u32 tmp; |
1077 | 1039 | ||
1078 | if (!printed_version++) | 1040 | if (!printed_version++) |
1079 | dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); | 1041 | dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); |
1080 | 1042 | ||
1081 | rc = pci_enable_device(pdev); | 1043 | rc = pcim_enable_device(pdev); |
1082 | if (rc) | 1044 | if (rc) |
1083 | return rc; | 1045 | return rc; |
1084 | 1046 | ||
1085 | rc = pci_request_regions(pdev, DRV_NAME); | 1047 | rc = pci_request_regions(pdev, DRV_NAME); |
1086 | if (rc) | 1048 | if (rc) |
1087 | goto out_disable; | 1049 | return rc; |
1088 | 1050 | ||
1089 | rc = -ENOMEM; | ||
1090 | /* map mmio registers */ | 1051 | /* map mmio registers */ |
1091 | host_base = pci_iomap(pdev, 0, 0); | 1052 | host_base = pcim_iomap(pdev, 0, 0); |
1092 | if (!host_base) | 1053 | port_base = pcim_iomap(pdev, 2, 0); |
1093 | goto out_free; | 1054 | if (!host_base || !port_base) |
1094 | port_base = pci_iomap(pdev, 2, 0); | 1055 | return -ENOMEM; |
1095 | if (!port_base) | ||
1096 | goto out_free; | ||
1097 | 1056 | ||
1098 | /* allocate & init probe_ent and hpriv */ | 1057 | /* allocate & init probe_ent and hpriv */ |
1099 | probe_ent = kzalloc(sizeof(*probe_ent), GFP_KERNEL); | 1058 | probe_ent = devm_kzalloc(dev, sizeof(*probe_ent), GFP_KERNEL); |
1100 | if (!probe_ent) | 1059 | hpriv = devm_kzalloc(dev, sizeof(*hpriv), GFP_KERNEL); |
1101 | goto out_free; | 1060 | if (!probe_ent || !hpriv) |
1102 | 1061 | return -ENOMEM; | |
1103 | hpriv = kzalloc(sizeof(*hpriv), GFP_KERNEL); | ||
1104 | if (!hpriv) | ||
1105 | goto out_free; | ||
1106 | 1062 | ||
1107 | probe_ent->dev = pci_dev_to_dev(pdev); | 1063 | probe_ent->dev = pci_dev_to_dev(pdev); |
1108 | INIT_LIST_HEAD(&probe_ent->node); | 1064 | INIT_LIST_HEAD(&probe_ent->node); |
@@ -1132,7 +1088,7 @@ static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
1132 | if (rc) { | 1088 | if (rc) { |
1133 | dev_printk(KERN_ERR, &pdev->dev, | 1089 | dev_printk(KERN_ERR, &pdev->dev, |
1134 | "64-bit DMA enable failed\n"); | 1090 | "64-bit DMA enable failed\n"); |
1135 | goto out_free; | 1091 | return rc; |
1136 | } | 1092 | } |
1137 | } | 1093 | } |
1138 | } else { | 1094 | } else { |
@@ -1140,13 +1096,13 @@ static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
1140 | if (rc) { | 1096 | if (rc) { |
1141 | dev_printk(KERN_ERR, &pdev->dev, | 1097 | dev_printk(KERN_ERR, &pdev->dev, |
1142 | "32-bit DMA enable failed\n"); | 1098 | "32-bit DMA enable failed\n"); |
1143 | goto out_free; | 1099 | return rc; |
1144 | } | 1100 | } |
1145 | rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK); | 1101 | rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK); |
1146 | if (rc) { | 1102 | if (rc) { |
1147 | dev_printk(KERN_ERR, &pdev->dev, | 1103 | dev_printk(KERN_ERR, &pdev->dev, |
1148 | "32-bit consistent DMA enable failed\n"); | 1104 | "32-bit consistent DMA enable failed\n"); |
1149 | goto out_free; | 1105 | return rc; |
1150 | } | 1106 | } |
1151 | } | 1107 | } |
1152 | 1108 | ||
@@ -1176,23 +1132,11 @@ static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
1176 | 1132 | ||
1177 | pci_set_master(pdev); | 1133 | pci_set_master(pdev); |
1178 | 1134 | ||
1179 | /* FIXME: check ata_device_add return value */ | 1135 | if (!ata_device_add(probe_ent)) |
1180 | ata_device_add(probe_ent); | 1136 | return -ENODEV; |
1181 | 1137 | ||
1182 | kfree(probe_ent); | 1138 | devm_kfree(dev, probe_ent); |
1183 | return 0; | 1139 | return 0; |
1184 | |||
1185 | out_free: | ||
1186 | if (host_base) | ||
1187 | pci_iounmap(pdev, host_base); | ||
1188 | if (port_base) | ||
1189 | pci_iounmap(pdev, port_base); | ||
1190 | kfree(probe_ent); | ||
1191 | kfree(hpriv); | ||
1192 | pci_release_regions(pdev); | ||
1193 | out_disable: | ||
1194 | pci_disable_device(pdev); | ||
1195 | return rc; | ||
1196 | } | 1140 | } |
1197 | 1141 | ||
1198 | #ifdef CONFIG_PM | 1142 | #ifdef CONFIG_PM |
diff --git a/drivers/ata/sata_sis.c b/drivers/ata/sata_sis.c index af6f42578f59..7e51f1c0f7cb 100644 --- a/drivers/ata/sata_sis.c +++ b/drivers/ata/sata_sis.c | |||
@@ -126,8 +126,6 @@ static const struct ata_port_operations sis_ops = { | |||
126 | .scr_read = sis_scr_read, | 126 | .scr_read = sis_scr_read, |
127 | .scr_write = sis_scr_write, | 127 | .scr_write = sis_scr_write, |
128 | .port_start = ata_port_start, | 128 | .port_start = ata_port_start, |
129 | .port_stop = ata_port_stop, | ||
130 | .host_stop = ata_host_stop, | ||
131 | }; | 129 | }; |
132 | 130 | ||
133 | static struct ata_port_info sis_port_info = { | 131 | static struct ata_port_info sis_port_info = { |
@@ -260,29 +258,28 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
260 | int rc; | 258 | int rc; |
261 | u32 genctl, val; | 259 | u32 genctl, val; |
262 | struct ata_port_info pi = sis_port_info, *ppi[2] = { &pi, &pi }; | 260 | struct ata_port_info pi = sis_port_info, *ppi[2] = { &pi, &pi }; |
263 | int pci_dev_busy = 0; | ||
264 | u8 pmr; | 261 | u8 pmr; |
265 | u8 port2_start = 0x20; | 262 | u8 port2_start = 0x20; |
266 | 263 | ||
267 | if (!printed_version++) | 264 | if (!printed_version++) |
268 | dev_printk(KERN_INFO, &pdev->dev, "version " DRV_VERSION "\n"); | 265 | dev_printk(KERN_INFO, &pdev->dev, "version " DRV_VERSION "\n"); |
269 | 266 | ||
270 | rc = pci_enable_device(pdev); | 267 | rc = pcim_enable_device(pdev); |
271 | if (rc) | 268 | if (rc) |
272 | return rc; | 269 | return rc; |
273 | 270 | ||
274 | rc = pci_request_regions(pdev, DRV_NAME); | 271 | rc = pci_request_regions(pdev, DRV_NAME); |
275 | if (rc) { | 272 | if (rc) { |
276 | pci_dev_busy = 1; | 273 | pcim_pin_device(pdev); |
277 | goto err_out; | 274 | return rc; |
278 | } | 275 | } |
279 | 276 | ||
280 | rc = pci_set_dma_mask(pdev, ATA_DMA_MASK); | 277 | rc = pci_set_dma_mask(pdev, ATA_DMA_MASK); |
281 | if (rc) | 278 | if (rc) |
282 | goto err_out_regions; | 279 | return rc; |
283 | rc = pci_set_consistent_dma_mask(pdev, ATA_DMA_MASK); | 280 | rc = pci_set_consistent_dma_mask(pdev, ATA_DMA_MASK); |
284 | if (rc) | 281 | if (rc) |
285 | goto err_out_regions; | 282 | return rc; |
286 | 283 | ||
287 | /* check and see if the SCRs are in IO space or PCI cfg space */ | 284 | /* check and see if the SCRs are in IO space or PCI cfg space */ |
288 | pci_read_config_dword(pdev, SIS_GENCTL, &genctl); | 285 | pci_read_config_dword(pdev, SIS_GENCTL, &genctl); |
@@ -351,10 +348,8 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
351 | } | 348 | } |
352 | 349 | ||
353 | probe_ent = ata_pci_init_native_mode(pdev, ppi, ATA_PORT_PRIMARY | ATA_PORT_SECONDARY); | 350 | probe_ent = ata_pci_init_native_mode(pdev, ppi, ATA_PORT_PRIMARY | ATA_PORT_SECONDARY); |
354 | if (!probe_ent) { | 351 | if (!probe_ent) |
355 | rc = -ENOMEM; | 352 | return -ENOMEM; |
356 | goto err_out_regions; | ||
357 | } | ||
358 | 353 | ||
359 | if (!(probe_ent->port_flags & SIS_FLAG_CFGSCR)) { | 354 | if (!(probe_ent->port_flags & SIS_FLAG_CFGSCR)) { |
360 | probe_ent->port[0].scr_addr = | 355 | probe_ent->port[0].scr_addr = |
@@ -366,20 +361,12 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
366 | pci_set_master(pdev); | 361 | pci_set_master(pdev); |
367 | pci_intx(pdev, 1); | 362 | pci_intx(pdev, 1); |
368 | 363 | ||
369 | /* FIXME: check ata_device_add return value */ | 364 | if (!ata_device_add(probe_ent)) |
370 | ata_device_add(probe_ent); | 365 | return -EIO; |
371 | kfree(probe_ent); | ||
372 | 366 | ||
367 | devm_kfree(&pdev->dev, probe_ent); | ||
373 | return 0; | 368 | return 0; |
374 | 369 | ||
375 | err_out_regions: | ||
376 | pci_release_regions(pdev); | ||
377 | |||
378 | err_out: | ||
379 | if (!pci_dev_busy) | ||
380 | pci_disable_device(pdev); | ||
381 | return rc; | ||
382 | |||
383 | } | 370 | } |
384 | 371 | ||
385 | static int __init sis_init(void) | 372 | static int __init sis_init(void) |
diff --git a/drivers/ata/sata_svw.c b/drivers/ata/sata_svw.c index 5f4e82ade6cd..9c48b418ad7f 100644 --- a/drivers/ata/sata_svw.c +++ b/drivers/ata/sata_svw.c | |||
@@ -359,8 +359,6 @@ static const struct ata_port_operations k2_sata_ops = { | |||
359 | .scr_read = k2_sata_scr_read, | 359 | .scr_read = k2_sata_scr_read, |
360 | .scr_write = k2_sata_scr_write, | 360 | .scr_write = k2_sata_scr_write, |
361 | .port_start = ata_port_start, | 361 | .port_start = ata_port_start, |
362 | .port_stop = ata_port_stop, | ||
363 | .host_stop = ata_pci_host_stop, | ||
364 | }; | 362 | }; |
365 | 363 | ||
366 | static void k2_sata_setup_port(struct ata_ioports *port, unsigned long base) | 364 | static void k2_sata_setup_port(struct ata_ioports *port, unsigned long base) |
@@ -386,12 +384,12 @@ static void k2_sata_setup_port(struct ata_ioports *port, unsigned long base) | |||
386 | static int k2_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | 384 | static int k2_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) |
387 | { | 385 | { |
388 | static int printed_version; | 386 | static int printed_version; |
389 | struct ata_probe_ent *probe_ent = NULL; | 387 | struct device *dev = &pdev->dev; |
388 | struct ata_probe_ent *probe_ent; | ||
390 | unsigned long base; | 389 | unsigned long base; |
391 | void __iomem *mmio_base; | 390 | void __iomem *mmio_base; |
392 | const struct k2_board_info *board_info = | 391 | const struct k2_board_info *board_info = |
393 | &k2_board_info[ent->driver_data]; | 392 | &k2_board_info[ent->driver_data]; |
394 | int pci_dev_busy = 0; | ||
395 | int rc; | 393 | int rc; |
396 | int i; | 394 | int i; |
397 | 395 | ||
@@ -402,7 +400,7 @@ static int k2_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *e | |||
402 | * If this driver happens to only be useful on Apple's K2, then | 400 | * If this driver happens to only be useful on Apple's K2, then |
403 | * we should check that here as it has a normal Serverworks ID | 401 | * we should check that here as it has a normal Serverworks ID |
404 | */ | 402 | */ |
405 | rc = pci_enable_device(pdev); | 403 | rc = pcim_enable_device(pdev); |
406 | if (rc) | 404 | if (rc) |
407 | return rc; | 405 | return rc; |
408 | /* | 406 | /* |
@@ -415,32 +413,27 @@ static int k2_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *e | |||
415 | /* Request PCI regions */ | 413 | /* Request PCI regions */ |
416 | rc = pci_request_regions(pdev, DRV_NAME); | 414 | rc = pci_request_regions(pdev, DRV_NAME); |
417 | if (rc) { | 415 | if (rc) { |
418 | pci_dev_busy = 1; | 416 | pcim_pin_device(pdev); |
419 | goto err_out; | 417 | return rc; |
420 | } | 418 | } |
421 | 419 | ||
422 | rc = pci_set_dma_mask(pdev, ATA_DMA_MASK); | 420 | rc = pci_set_dma_mask(pdev, ATA_DMA_MASK); |
423 | if (rc) | 421 | if (rc) |
424 | goto err_out_regions; | 422 | return rc; |
425 | rc = pci_set_consistent_dma_mask(pdev, ATA_DMA_MASK); | 423 | rc = pci_set_consistent_dma_mask(pdev, ATA_DMA_MASK); |
426 | if (rc) | 424 | if (rc) |
427 | goto err_out_regions; | 425 | return rc; |
428 | 426 | ||
429 | probe_ent = kmalloc(sizeof(*probe_ent), GFP_KERNEL); | 427 | probe_ent = devm_kzalloc(dev, sizeof(*probe_ent), GFP_KERNEL); |
430 | if (probe_ent == NULL) { | 428 | if (probe_ent == NULL) |
431 | rc = -ENOMEM; | 429 | return -ENOMEM; |
432 | goto err_out_regions; | ||
433 | } | ||
434 | 430 | ||
435 | memset(probe_ent, 0, sizeof(*probe_ent)); | ||
436 | probe_ent->dev = pci_dev_to_dev(pdev); | 431 | probe_ent->dev = pci_dev_to_dev(pdev); |
437 | INIT_LIST_HEAD(&probe_ent->node); | 432 | INIT_LIST_HEAD(&probe_ent->node); |
438 | 433 | ||
439 | mmio_base = pci_iomap(pdev, 5, 0); | 434 | mmio_base = pcim_iomap(pdev, 5, 0); |
440 | if (mmio_base == NULL) { | 435 | if (mmio_base == NULL) |
441 | rc = -ENOMEM; | 436 | return -ENOMEM; |
442 | goto err_out_free_ent; | ||
443 | } | ||
444 | base = (unsigned long) mmio_base; | 437 | base = (unsigned long) mmio_base; |
445 | 438 | ||
446 | /* Clear a magic bit in SCR1 according to Darwin, those help | 439 | /* Clear a magic bit in SCR1 according to Darwin, those help |
@@ -478,20 +471,11 @@ static int k2_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *e | |||
478 | 471 | ||
479 | pci_set_master(pdev); | 472 | pci_set_master(pdev); |
480 | 473 | ||
481 | /* FIXME: check ata_device_add return value */ | 474 | if (!ata_device_add(probe_ent)) |
482 | ata_device_add(probe_ent); | 475 | return -ENODEV; |
483 | kfree(probe_ent); | ||
484 | 476 | ||
477 | devm_kfree(dev, probe_ent); | ||
485 | return 0; | 478 | return 0; |
486 | |||
487 | err_out_free_ent: | ||
488 | kfree(probe_ent); | ||
489 | err_out_regions: | ||
490 | pci_release_regions(pdev); | ||
491 | err_out: | ||
492 | if (!pci_dev_busy) | ||
493 | pci_disable_device(pdev); | ||
494 | return rc; | ||
495 | } | 479 | } |
496 | 480 | ||
497 | /* 0x240 is device ID for Apple K2 device | 481 | /* 0x240 is device ID for Apple K2 device |
diff --git a/drivers/ata/sata_sx4.c b/drivers/ata/sata_sx4.c index ae7992de4b08..d9838dcb4b01 100644 --- a/drivers/ata/sata_sx4.c +++ b/drivers/ata/sata_sx4.c | |||
@@ -42,7 +42,6 @@ | |||
42 | #include <scsi/scsi_host.h> | 42 | #include <scsi/scsi_host.h> |
43 | #include <scsi/scsi_cmnd.h> | 43 | #include <scsi/scsi_cmnd.h> |
44 | #include <linux/libata.h> | 44 | #include <linux/libata.h> |
45 | #include <asm/io.h> | ||
46 | #include "sata_promise.h" | 45 | #include "sata_promise.h" |
47 | 46 | ||
48 | #define DRV_NAME "sata_sx4" | 47 | #define DRV_NAME "sata_sx4" |
@@ -156,11 +155,9 @@ static irqreturn_t pdc20621_interrupt (int irq, void *dev_instance); | |||
156 | static void pdc_eng_timeout(struct ata_port *ap); | 155 | static void pdc_eng_timeout(struct ata_port *ap); |
157 | static void pdc_20621_phy_reset (struct ata_port *ap); | 156 | static void pdc_20621_phy_reset (struct ata_port *ap); |
158 | static int pdc_port_start(struct ata_port *ap); | 157 | static int pdc_port_start(struct ata_port *ap); |
159 | static void pdc_port_stop(struct ata_port *ap); | ||
160 | static void pdc20621_qc_prep(struct ata_queued_cmd *qc); | 158 | static void pdc20621_qc_prep(struct ata_queued_cmd *qc); |
161 | static void pdc_tf_load_mmio(struct ata_port *ap, const struct ata_taskfile *tf); | 159 | static void pdc_tf_load_mmio(struct ata_port *ap, const struct ata_taskfile *tf); |
162 | static void pdc_exec_command_mmio(struct ata_port *ap, const struct ata_taskfile *tf); | 160 | static void pdc_exec_command_mmio(struct ata_port *ap, const struct ata_taskfile *tf); |
163 | static void pdc20621_host_stop(struct ata_host *host); | ||
164 | static unsigned int pdc20621_dimm_init(struct ata_probe_ent *pe); | 161 | static unsigned int pdc20621_dimm_init(struct ata_probe_ent *pe); |
165 | static int pdc20621_detect_dimm(struct ata_probe_ent *pe); | 162 | static int pdc20621_detect_dimm(struct ata_probe_ent *pe); |
166 | static unsigned int pdc20621_i2c_read(struct ata_probe_ent *pe, | 163 | static unsigned int pdc20621_i2c_read(struct ata_probe_ent *pe, |
@@ -210,8 +207,6 @@ static const struct ata_port_operations pdc_20621_ops = { | |||
210 | .irq_handler = pdc20621_interrupt, | 207 | .irq_handler = pdc20621_interrupt, |
211 | .irq_clear = pdc20621_irq_clear, | 208 | .irq_clear = pdc20621_irq_clear, |
212 | .port_start = pdc_port_start, | 209 | .port_start = pdc_port_start, |
213 | .port_stop = pdc_port_stop, | ||
214 | .host_stop = pdc20621_host_stop, | ||
215 | }; | 210 | }; |
216 | 211 | ||
217 | static const struct ata_port_info pdc_port_info[] = { | 212 | static const struct ata_port_info pdc_port_info[] = { |
@@ -243,18 +238,6 @@ static struct pci_driver pdc_sata_pci_driver = { | |||
243 | }; | 238 | }; |
244 | 239 | ||
245 | 240 | ||
246 | static void pdc20621_host_stop(struct ata_host *host) | ||
247 | { | ||
248 | struct pci_dev *pdev = to_pci_dev(host->dev); | ||
249 | struct pdc_host_priv *hpriv = host->private_data; | ||
250 | void __iomem *dimm_mmio = hpriv->dimm_mmio; | ||
251 | |||
252 | pci_iounmap(pdev, dimm_mmio); | ||
253 | kfree(hpriv); | ||
254 | |||
255 | pci_iounmap(pdev, host->mmio_base); | ||
256 | } | ||
257 | |||
258 | static int pdc_port_start(struct ata_port *ap) | 241 | static int pdc_port_start(struct ata_port *ap) |
259 | { | 242 | { |
260 | struct device *dev = ap->host->dev; | 243 | struct device *dev = ap->host->dev; |
@@ -265,43 +248,19 @@ static int pdc_port_start(struct ata_port *ap) | |||
265 | if (rc) | 248 | if (rc) |
266 | return rc; | 249 | return rc; |
267 | 250 | ||
268 | pp = kmalloc(sizeof(*pp), GFP_KERNEL); | 251 | pp = devm_kzalloc(dev, sizeof(*pp), GFP_KERNEL); |
269 | if (!pp) { | 252 | if (!pp) |
270 | rc = -ENOMEM; | 253 | return -ENOMEM; |
271 | goto err_out; | ||
272 | } | ||
273 | memset(pp, 0, sizeof(*pp)); | ||
274 | 254 | ||
275 | pp->pkt = dma_alloc_coherent(dev, 128, &pp->pkt_dma, GFP_KERNEL); | 255 | pp->pkt = dmam_alloc_coherent(dev, 128, &pp->pkt_dma, GFP_KERNEL); |
276 | if (!pp->pkt) { | 256 | if (!pp->pkt) |
277 | rc = -ENOMEM; | 257 | return -ENOMEM; |
278 | goto err_out_kfree; | ||
279 | } | ||
280 | 258 | ||
281 | ap->private_data = pp; | 259 | ap->private_data = pp; |
282 | 260 | ||
283 | return 0; | 261 | return 0; |
284 | |||
285 | err_out_kfree: | ||
286 | kfree(pp); | ||
287 | err_out: | ||
288 | ata_port_stop(ap); | ||
289 | return rc; | ||
290 | } | ||
291 | |||
292 | |||
293 | static void pdc_port_stop(struct ata_port *ap) | ||
294 | { | ||
295 | struct device *dev = ap->host->dev; | ||
296 | struct pdc_port_priv *pp = ap->private_data; | ||
297 | |||
298 | ap->private_data = NULL; | ||
299 | dma_free_coherent(dev, 128, pp->pkt, pp->pkt_dma); | ||
300 | kfree(pp); | ||
301 | ata_port_stop(ap); | ||
302 | } | 262 | } |
303 | 263 | ||
304 | |||
305 | static void pdc_20621_phy_reset (struct ata_port *ap) | 264 | static void pdc_20621_phy_reset (struct ata_port *ap) |
306 | { | 265 | { |
307 | VPRINTK("ENTER\n"); | 266 | VPRINTK("ENTER\n"); |
@@ -1365,65 +1324,53 @@ static void pdc_20621_init(struct ata_probe_ent *pe) | |||
1365 | static int pdc_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | 1324 | static int pdc_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) |
1366 | { | 1325 | { |
1367 | static int printed_version; | 1326 | static int printed_version; |
1368 | struct ata_probe_ent *probe_ent = NULL; | 1327 | struct ata_probe_ent *probe_ent; |
1369 | unsigned long base; | 1328 | unsigned long base; |
1370 | void __iomem *mmio_base; | 1329 | void __iomem *mmio_base; |
1371 | void __iomem *dimm_mmio = NULL; | 1330 | void __iomem *dimm_mmio; |
1372 | struct pdc_host_priv *hpriv = NULL; | 1331 | struct pdc_host_priv *hpriv; |
1373 | unsigned int board_idx = (unsigned int) ent->driver_data; | 1332 | unsigned int board_idx = (unsigned int) ent->driver_data; |
1374 | int pci_dev_busy = 0; | ||
1375 | int rc; | 1333 | int rc; |
1376 | 1334 | ||
1377 | if (!printed_version++) | 1335 | if (!printed_version++) |
1378 | dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); | 1336 | dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); |
1379 | 1337 | ||
1380 | rc = pci_enable_device(pdev); | 1338 | rc = pcim_enable_device(pdev); |
1381 | if (rc) | 1339 | if (rc) |
1382 | return rc; | 1340 | return rc; |
1383 | 1341 | ||
1384 | rc = pci_request_regions(pdev, DRV_NAME); | 1342 | rc = pci_request_regions(pdev, DRV_NAME); |
1385 | if (rc) { | 1343 | if (rc) { |
1386 | pci_dev_busy = 1; | 1344 | pcim_pin_device(pdev); |
1387 | goto err_out; | 1345 | return rc; |
1388 | } | 1346 | } |
1389 | 1347 | ||
1390 | rc = pci_set_dma_mask(pdev, ATA_DMA_MASK); | 1348 | rc = pci_set_dma_mask(pdev, ATA_DMA_MASK); |
1391 | if (rc) | 1349 | if (rc) |
1392 | goto err_out_regions; | 1350 | return rc; |
1393 | rc = pci_set_consistent_dma_mask(pdev, ATA_DMA_MASK); | 1351 | rc = pci_set_consistent_dma_mask(pdev, ATA_DMA_MASK); |
1394 | if (rc) | 1352 | if (rc) |
1395 | goto err_out_regions; | 1353 | return rc; |
1396 | 1354 | ||
1397 | probe_ent = kmalloc(sizeof(*probe_ent), GFP_KERNEL); | 1355 | probe_ent = devm_kzalloc(&pdev->dev, sizeof(*probe_ent), GFP_KERNEL); |
1398 | if (probe_ent == NULL) { | 1356 | if (probe_ent == NULL) |
1399 | rc = -ENOMEM; | 1357 | return -ENOMEM; |
1400 | goto err_out_regions; | ||
1401 | } | ||
1402 | 1358 | ||
1403 | memset(probe_ent, 0, sizeof(*probe_ent)); | ||
1404 | probe_ent->dev = pci_dev_to_dev(pdev); | 1359 | probe_ent->dev = pci_dev_to_dev(pdev); |
1405 | INIT_LIST_HEAD(&probe_ent->node); | 1360 | INIT_LIST_HEAD(&probe_ent->node); |
1406 | 1361 | ||
1407 | mmio_base = pci_iomap(pdev, 3, 0); | 1362 | mmio_base = pcim_iomap(pdev, 3, 0); |
1408 | if (mmio_base == NULL) { | 1363 | if (mmio_base == NULL) |
1409 | rc = -ENOMEM; | 1364 | return -ENOMEM; |
1410 | goto err_out_free_ent; | ||
1411 | } | ||
1412 | base = (unsigned long) mmio_base; | 1365 | base = (unsigned long) mmio_base; |
1413 | 1366 | ||
1414 | hpriv = kmalloc(sizeof(*hpriv), GFP_KERNEL); | 1367 | hpriv = devm_kzalloc(&pdev->dev, sizeof(*hpriv), GFP_KERNEL); |
1415 | if (!hpriv) { | 1368 | if (!hpriv) |
1416 | rc = -ENOMEM; | 1369 | return -ENOMEM; |
1417 | goto err_out_iounmap; | ||
1418 | } | ||
1419 | memset(hpriv, 0, sizeof(*hpriv)); | ||
1420 | 1370 | ||
1421 | dimm_mmio = pci_iomap(pdev, 4, 0); | 1371 | dimm_mmio = pcim_iomap(pdev, 4, 0); |
1422 | if (!dimm_mmio) { | 1372 | if (!dimm_mmio) |
1423 | kfree(hpriv); | 1373 | return -ENOMEM; |
1424 | rc = -ENOMEM; | ||
1425 | goto err_out_iounmap; | ||
1426 | } | ||
1427 | 1374 | ||
1428 | hpriv->dimm_mmio = dimm_mmio; | 1375 | hpriv->dimm_mmio = dimm_mmio; |
1429 | 1376 | ||
@@ -1451,31 +1398,15 @@ static int pdc_sata_init_one (struct pci_dev *pdev, const struct pci_device_id * | |||
1451 | 1398 | ||
1452 | /* initialize adapter */ | 1399 | /* initialize adapter */ |
1453 | /* initialize local dimm */ | 1400 | /* initialize local dimm */ |
1454 | if (pdc20621_dimm_init(probe_ent)) { | 1401 | if (pdc20621_dimm_init(probe_ent)) |
1455 | rc = -ENOMEM; | 1402 | return -ENOMEM; |
1456 | goto err_out_iounmap_dimm; | ||
1457 | } | ||
1458 | pdc_20621_init(probe_ent); | 1403 | pdc_20621_init(probe_ent); |
1459 | 1404 | ||
1460 | /* FIXME: check ata_device_add return value */ | 1405 | if (!ata_device_add(probe_ent)) |
1461 | ata_device_add(probe_ent); | 1406 | return -ENODEV; |
1462 | kfree(probe_ent); | ||
1463 | 1407 | ||
1408 | devm_kfree(&pdev->dev, probe_ent); | ||
1464 | return 0; | 1409 | return 0; |
1465 | |||
1466 | err_out_iounmap_dimm: /* only get to this label if 20621 */ | ||
1467 | kfree(hpriv); | ||
1468 | pci_iounmap(pdev, dimm_mmio); | ||
1469 | err_out_iounmap: | ||
1470 | pci_iounmap(pdev, mmio_base); | ||
1471 | err_out_free_ent: | ||
1472 | kfree(probe_ent); | ||
1473 | err_out_regions: | ||
1474 | pci_release_regions(pdev); | ||
1475 | err_out: | ||
1476 | if (!pci_dev_busy) | ||
1477 | pci_disable_device(pdev); | ||
1478 | return rc; | ||
1479 | } | 1410 | } |
1480 | 1411 | ||
1481 | 1412 | ||
diff --git a/drivers/ata/sata_uli.c b/drivers/ata/sata_uli.c index a43aec62d505..22eed6d07495 100644 --- a/drivers/ata/sata_uli.c +++ b/drivers/ata/sata_uli.c | |||
@@ -122,8 +122,6 @@ static const struct ata_port_operations uli_ops = { | |||
122 | .scr_write = uli_scr_write, | 122 | .scr_write = uli_scr_write, |
123 | 123 | ||
124 | .port_start = ata_port_start, | 124 | .port_start = ata_port_start, |
125 | .port_stop = ata_port_stop, | ||
126 | .host_stop = ata_host_stop, | ||
127 | }; | 125 | }; |
128 | 126 | ||
129 | static struct ata_port_info uli_port_info = { | 127 | static struct ata_port_info uli_port_info = { |
@@ -189,41 +187,36 @@ static int uli_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
189 | struct ata_port_info *ppi[2]; | 187 | struct ata_port_info *ppi[2]; |
190 | int rc; | 188 | int rc; |
191 | unsigned int board_idx = (unsigned int) ent->driver_data; | 189 | unsigned int board_idx = (unsigned int) ent->driver_data; |
192 | int pci_dev_busy = 0; | ||
193 | struct uli_priv *hpriv; | 190 | struct uli_priv *hpriv; |
194 | 191 | ||
195 | if (!printed_version++) | 192 | if (!printed_version++) |
196 | dev_printk(KERN_INFO, &pdev->dev, "version " DRV_VERSION "\n"); | 193 | dev_printk(KERN_INFO, &pdev->dev, "version " DRV_VERSION "\n"); |
197 | 194 | ||
198 | rc = pci_enable_device(pdev); | 195 | rc = pcim_enable_device(pdev); |
199 | if (rc) | 196 | if (rc) |
200 | return rc; | 197 | return rc; |
201 | 198 | ||
202 | rc = pci_request_regions(pdev, DRV_NAME); | 199 | rc = pci_request_regions(pdev, DRV_NAME); |
203 | if (rc) { | 200 | if (rc) { |
204 | pci_dev_busy = 1; | 201 | pcim_pin_device(pdev); |
205 | goto err_out; | 202 | return rc; |
206 | } | 203 | } |
207 | 204 | ||
208 | rc = pci_set_dma_mask(pdev, ATA_DMA_MASK); | 205 | rc = pci_set_dma_mask(pdev, ATA_DMA_MASK); |
209 | if (rc) | 206 | if (rc) |
210 | goto err_out_regions; | 207 | return rc; |
211 | rc = pci_set_consistent_dma_mask(pdev, ATA_DMA_MASK); | 208 | rc = pci_set_consistent_dma_mask(pdev, ATA_DMA_MASK); |
212 | if (rc) | 209 | if (rc) |
213 | goto err_out_regions; | 210 | return rc; |
214 | 211 | ||
215 | ppi[0] = ppi[1] = &uli_port_info; | 212 | ppi[0] = ppi[1] = &uli_port_info; |
216 | probe_ent = ata_pci_init_native_mode(pdev, ppi, ATA_PORT_PRIMARY | ATA_PORT_SECONDARY); | 213 | probe_ent = ata_pci_init_native_mode(pdev, ppi, ATA_PORT_PRIMARY | ATA_PORT_SECONDARY); |
217 | if (!probe_ent) { | 214 | if (!probe_ent) |
218 | rc = -ENOMEM; | 215 | return -ENOMEM; |
219 | goto err_out_regions; | ||
220 | } | ||
221 | 216 | ||
222 | hpriv = kzalloc(sizeof(*hpriv), GFP_KERNEL); | 217 | hpriv = devm_kzalloc(&pdev->dev, sizeof(*hpriv), GFP_KERNEL); |
223 | if (!hpriv) { | 218 | if (!hpriv) |
224 | rc = -ENOMEM; | 219 | return -ENOMEM; |
225 | goto err_out_probe_ent; | ||
226 | } | ||
227 | 220 | ||
228 | probe_ent->private_data = hpriv; | 221 | probe_ent->private_data = hpriv; |
229 | 222 | ||
@@ -269,21 +262,11 @@ static int uli_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
269 | pci_set_master(pdev); | 262 | pci_set_master(pdev); |
270 | pci_intx(pdev, 1); | 263 | pci_intx(pdev, 1); |
271 | 264 | ||
272 | /* FIXME: check ata_device_add return value */ | 265 | if (!ata_device_add(probe_ent)) |
273 | ata_device_add(probe_ent); | 266 | return -ENODEV; |
274 | kfree(probe_ent); | ||
275 | 267 | ||
268 | devm_kfree(&pdev->dev, probe_ent); | ||
276 | return 0; | 269 | return 0; |
277 | |||
278 | err_out_probe_ent: | ||
279 | kfree(probe_ent); | ||
280 | err_out_regions: | ||
281 | pci_release_regions(pdev); | ||
282 | err_out: | ||
283 | if (!pci_dev_busy) | ||
284 | pci_disable_device(pdev); | ||
285 | return rc; | ||
286 | |||
287 | } | 270 | } |
288 | 271 | ||
289 | static int __init uli_init(void) | 272 | static int __init uli_init(void) |
diff --git a/drivers/ata/sata_via.c b/drivers/ata/sata_via.c index e95acfac30b9..c7f527578d11 100644 --- a/drivers/ata/sata_via.c +++ b/drivers/ata/sata_via.c | |||
@@ -44,7 +44,6 @@ | |||
44 | #include <linux/device.h> | 44 | #include <linux/device.h> |
45 | #include <scsi/scsi_host.h> | 45 | #include <scsi/scsi_host.h> |
46 | #include <linux/libata.h> | 46 | #include <linux/libata.h> |
47 | #include <asm/io.h> | ||
48 | 47 | ||
49 | #define DRV_NAME "sata_via" | 48 | #define DRV_NAME "sata_via" |
50 | #define DRV_VERSION "2.0" | 49 | #define DRV_VERSION "2.0" |
@@ -146,8 +145,6 @@ static const struct ata_port_operations vt6420_sata_ops = { | |||
146 | .irq_clear = ata_bmdma_irq_clear, | 145 | .irq_clear = ata_bmdma_irq_clear, |
147 | 146 | ||
148 | .port_start = ata_port_start, | 147 | .port_start = ata_port_start, |
149 | .port_stop = ata_port_stop, | ||
150 | .host_stop = ata_host_stop, | ||
151 | }; | 148 | }; |
152 | 149 | ||
153 | static const struct ata_port_operations vt6421_pata_ops = { | 150 | static const struct ata_port_operations vt6421_pata_ops = { |
@@ -180,8 +177,6 @@ static const struct ata_port_operations vt6421_pata_ops = { | |||
180 | .irq_clear = ata_bmdma_irq_clear, | 177 | .irq_clear = ata_bmdma_irq_clear, |
181 | 178 | ||
182 | .port_start = vt6421_port_start, | 179 | .port_start = vt6421_port_start, |
183 | .port_stop = ata_port_stop, | ||
184 | .host_stop = ata_host_stop, | ||
185 | }; | 180 | }; |
186 | 181 | ||
187 | static const struct ata_port_operations vt6421_sata_ops = { | 182 | static const struct ata_port_operations vt6421_sata_ops = { |
@@ -214,8 +209,6 @@ static const struct ata_port_operations vt6421_sata_ops = { | |||
214 | .scr_write = svia_scr_write, | 209 | .scr_write = svia_scr_write, |
215 | 210 | ||
216 | .port_start = vt6421_port_start, | 211 | .port_start = vt6421_port_start, |
217 | .port_stop = ata_port_stop, | ||
218 | .host_stop = ata_host_stop, | ||
219 | }; | 212 | }; |
220 | 213 | ||
221 | static struct ata_port_info vt6420_port_info = { | 214 | static struct ata_port_info vt6420_port_info = { |
@@ -446,7 +439,7 @@ static struct ata_probe_ent *vt6421_init_probe_ent(struct pci_dev *pdev) | |||
446 | struct ata_probe_ent *probe_ent; | 439 | struct ata_probe_ent *probe_ent; |
447 | unsigned int i; | 440 | unsigned int i; |
448 | 441 | ||
449 | probe_ent = kmalloc(sizeof(*probe_ent), GFP_KERNEL); | 442 | probe_ent = devm_kzalloc(&pdev->dev, sizeof(*probe_ent), GFP_KERNEL); |
450 | if (!probe_ent) | 443 | if (!probe_ent) |
451 | return NULL; | 444 | return NULL; |
452 | 445 | ||
@@ -517,20 +510,19 @@ static int svia_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
517 | struct ata_probe_ent *probe_ent; | 510 | struct ata_probe_ent *probe_ent; |
518 | int board_id = (int) ent->driver_data; | 511 | int board_id = (int) ent->driver_data; |
519 | const int *bar_sizes; | 512 | const int *bar_sizes; |
520 | int pci_dev_busy = 0; | ||
521 | u8 tmp8; | 513 | u8 tmp8; |
522 | 514 | ||
523 | if (!printed_version++) | 515 | if (!printed_version++) |
524 | dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); | 516 | dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); |
525 | 517 | ||
526 | rc = pci_enable_device(pdev); | 518 | rc = pcim_enable_device(pdev); |
527 | if (rc) | 519 | if (rc) |
528 | return rc; | 520 | return rc; |
529 | 521 | ||
530 | rc = pci_request_regions(pdev, DRV_NAME); | 522 | rc = pci_request_regions(pdev, DRV_NAME); |
531 | if (rc) { | 523 | if (rc) { |
532 | pci_dev_busy = 1; | 524 | pcim_pin_device(pdev); |
533 | goto err_out; | 525 | return rc; |
534 | } | 526 | } |
535 | 527 | ||
536 | if (board_id == vt6420) { | 528 | if (board_id == vt6420) { |
@@ -539,8 +531,7 @@ static int svia_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
539 | dev_printk(KERN_ERR, &pdev->dev, | 531 | dev_printk(KERN_ERR, &pdev->dev, |
540 | "SATA master/slave not supported (0x%x)\n", | 532 | "SATA master/slave not supported (0x%x)\n", |
541 | (int) tmp8); | 533 | (int) tmp8); |
542 | rc = -EIO; | 534 | return -EIO; |
543 | goto err_out_regions; | ||
544 | } | 535 | } |
545 | 536 | ||
546 | bar_sizes = &svia_bar_sizes[0]; | 537 | bar_sizes = &svia_bar_sizes[0]; |
@@ -556,16 +547,15 @@ static int svia_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
556 | i, | 547 | i, |
557 | (unsigned long long)pci_resource_start(pdev, i), | 548 | (unsigned long long)pci_resource_start(pdev, i), |
558 | (unsigned long long)pci_resource_len(pdev, i)); | 549 | (unsigned long long)pci_resource_len(pdev, i)); |
559 | rc = -ENODEV; | 550 | return -ENODEV; |
560 | goto err_out_regions; | ||
561 | } | 551 | } |
562 | 552 | ||
563 | rc = pci_set_dma_mask(pdev, ATA_DMA_MASK); | 553 | rc = pci_set_dma_mask(pdev, ATA_DMA_MASK); |
564 | if (rc) | 554 | if (rc) |
565 | goto err_out_regions; | 555 | return rc; |
566 | rc = pci_set_consistent_dma_mask(pdev, ATA_DMA_MASK); | 556 | rc = pci_set_consistent_dma_mask(pdev, ATA_DMA_MASK); |
567 | if (rc) | 557 | if (rc) |
568 | goto err_out_regions; | 558 | return rc; |
569 | 559 | ||
570 | if (board_id == vt6420) | 560 | if (board_id == vt6420) |
571 | probe_ent = vt6420_init_probe_ent(pdev); | 561 | probe_ent = vt6420_init_probe_ent(pdev); |
@@ -574,26 +564,18 @@ static int svia_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
574 | 564 | ||
575 | if (!probe_ent) { | 565 | if (!probe_ent) { |
576 | dev_printk(KERN_ERR, &pdev->dev, "out of memory\n"); | 566 | dev_printk(KERN_ERR, &pdev->dev, "out of memory\n"); |
577 | rc = -ENOMEM; | 567 | return -ENOMEM; |
578 | goto err_out_regions; | ||
579 | } | 568 | } |
580 | 569 | ||
581 | svia_configure(pdev); | 570 | svia_configure(pdev); |
582 | 571 | ||
583 | pci_set_master(pdev); | 572 | pci_set_master(pdev); |
584 | 573 | ||
585 | /* FIXME: check ata_device_add return value */ | 574 | if (!ata_device_add(probe_ent)) |
586 | ata_device_add(probe_ent); | 575 | return -ENODEV; |
587 | kfree(probe_ent); | ||
588 | 576 | ||
577 | devm_kfree(&pdev->dev, probe_ent); | ||
589 | return 0; | 578 | return 0; |
590 | |||
591 | err_out_regions: | ||
592 | pci_release_regions(pdev); | ||
593 | err_out: | ||
594 | if (!pci_dev_busy) | ||
595 | pci_disable_device(pdev); | ||
596 | return rc; | ||
597 | } | 579 | } |
598 | 580 | ||
599 | static int __init svia_init(void) | 581 | static int __init svia_init(void) |
diff --git a/drivers/ata/sata_vsc.c b/drivers/ata/sata_vsc.c index 8d1683ebadc6..af77f71bdaa5 100644 --- a/drivers/ata/sata_vsc.c +++ b/drivers/ata/sata_vsc.c | |||
@@ -94,13 +94,6 @@ enum { | |||
94 | VSC_SATA_INT_ERROR_P | VSC_SATA_INT_ERROR_R | \ | 94 | VSC_SATA_INT_ERROR_P | VSC_SATA_INT_ERROR_R | \ |
95 | VSC_SATA_INT_ERROR_E | VSC_SATA_INT_ERROR_M | \ | 95 | VSC_SATA_INT_ERROR_E | VSC_SATA_INT_ERROR_M | \ |
96 | VSC_SATA_INT_PHY_CHANGE), | 96 | VSC_SATA_INT_PHY_CHANGE), |
97 | |||
98 | /* Host private flags (hp_flags) */ | ||
99 | VSC_SATA_HP_FLAG_MSI = (1 << 0), | ||
100 | }; | ||
101 | |||
102 | struct vsc_sata_host_priv { | ||
103 | u32 hp_flags; | ||
104 | }; | 97 | }; |
105 | 98 | ||
106 | #define is_vsc_sata_int_err(port_idx, int_status) \ | 99 | #define is_vsc_sata_int_err(port_idx, int_status) \ |
@@ -124,20 +117,6 @@ static void vsc_sata_scr_write (struct ata_port *ap, unsigned int sc_reg, | |||
124 | } | 117 | } |
125 | 118 | ||
126 | 119 | ||
127 | static void vsc_sata_host_stop(struct ata_host *host) | ||
128 | { | ||
129 | struct vsc_sata_host_priv *hpriv = host->private_data; | ||
130 | struct pci_dev *pdev = to_pci_dev(host->dev); | ||
131 | |||
132 | if (hpriv->hp_flags & VSC_SATA_HP_FLAG_MSI) | ||
133 | pci_disable_msi(pdev); | ||
134 | else | ||
135 | pci_intx(pdev, 0); | ||
136 | kfree (hpriv); | ||
137 | ata_pci_host_stop(host); | ||
138 | } | ||
139 | |||
140 | |||
141 | static void vsc_intr_mask_update(struct ata_port *ap, u8 ctl) | 120 | static void vsc_intr_mask_update(struct ata_port *ap, u8 ctl) |
142 | { | 121 | { |
143 | void __iomem *mask_addr; | 122 | void __iomem *mask_addr; |
@@ -331,8 +310,6 @@ static const struct ata_port_operations vsc_sata_ops = { | |||
331 | .scr_read = vsc_sata_scr_read, | 310 | .scr_read = vsc_sata_scr_read, |
332 | .scr_write = vsc_sata_scr_write, | 311 | .scr_write = vsc_sata_scr_write, |
333 | .port_start = ata_port_start, | 312 | .port_start = ata_port_start, |
334 | .port_stop = ata_port_stop, | ||
335 | .host_stop = vsc_sata_host_stop, | ||
336 | }; | 313 | }; |
337 | 314 | ||
338 | static void __devinit vsc_sata_setup_port(struct ata_ioports *port, unsigned long base) | 315 | static void __devinit vsc_sata_setup_port(struct ata_ioports *port, unsigned long base) |
@@ -361,31 +338,27 @@ static int __devinit vsc_sata_init_one (struct pci_dev *pdev, const struct pci_d | |||
361 | { | 338 | { |
362 | static int printed_version; | 339 | static int printed_version; |
363 | struct ata_probe_ent *probe_ent = NULL; | 340 | struct ata_probe_ent *probe_ent = NULL; |
364 | struct vsc_sata_host_priv *hpriv; | ||
365 | unsigned long base; | 341 | unsigned long base; |
366 | int pci_dev_busy = 0; | ||
367 | void __iomem *mmio_base; | 342 | void __iomem *mmio_base; |
368 | int rc; | 343 | int rc; |
369 | 344 | ||
370 | if (!printed_version++) | 345 | if (!printed_version++) |
371 | dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); | 346 | dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); |
372 | 347 | ||
373 | rc = pci_enable_device(pdev); | 348 | rc = pcim_enable_device(pdev); |
374 | if (rc) | 349 | if (rc) |
375 | return rc; | 350 | return rc; |
376 | 351 | ||
377 | /* | 352 | /* |
378 | * Check if we have needed resource mapped. | 353 | * Check if we have needed resource mapped. |
379 | */ | 354 | */ |
380 | if (pci_resource_len(pdev, 0) == 0) { | 355 | if (pci_resource_len(pdev, 0) == 0) |
381 | rc = -ENODEV; | 356 | return -ENODEV; |
382 | goto err_out; | ||
383 | } | ||
384 | 357 | ||
385 | rc = pci_request_regions(pdev, DRV_NAME); | 358 | rc = pci_request_regions(pdev, DRV_NAME); |
386 | if (rc) { | 359 | if (rc) { |
387 | pci_dev_busy = 1; | 360 | pcim_pin_device(pdev); |
388 | goto err_out; | 361 | return rc; |
389 | } | 362 | } |
390 | 363 | ||
391 | /* | 364 | /* |
@@ -393,44 +366,29 @@ static int __devinit vsc_sata_init_one (struct pci_dev *pdev, const struct pci_d | |||
393 | */ | 366 | */ |
394 | rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK); | 367 | rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK); |
395 | if (rc) | 368 | if (rc) |
396 | goto err_out_regions; | 369 | return rc; |
397 | rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK); | 370 | rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK); |
398 | if (rc) | 371 | if (rc) |
399 | goto err_out_regions; | 372 | return rc; |
400 | |||
401 | probe_ent = kmalloc(sizeof(*probe_ent), GFP_KERNEL); | ||
402 | if (probe_ent == NULL) { | ||
403 | rc = -ENOMEM; | ||
404 | goto err_out_regions; | ||
405 | } | ||
406 | 373 | ||
407 | memset(probe_ent, 0, sizeof(*probe_ent)); | 374 | probe_ent = devm_kzalloc(&pdev->dev, sizeof(*probe_ent), GFP_KERNEL); |
375 | if (probe_ent == NULL) | ||
376 | return -ENOMEM; | ||
408 | probe_ent->dev = pci_dev_to_dev(pdev); | 377 | probe_ent->dev = pci_dev_to_dev(pdev); |
409 | INIT_LIST_HEAD(&probe_ent->node); | 378 | INIT_LIST_HEAD(&probe_ent->node); |
410 | 379 | ||
411 | mmio_base = pci_iomap(pdev, 0, 0); | 380 | mmio_base = pcim_iomap(pdev, 0, 0); |
412 | if (mmio_base == NULL) { | 381 | if (mmio_base == NULL) |
413 | rc = -ENOMEM; | 382 | return -ENOMEM; |
414 | goto err_out_free_ent; | ||
415 | } | ||
416 | base = (unsigned long) mmio_base; | 383 | base = (unsigned long) mmio_base; |
417 | 384 | ||
418 | hpriv = kmalloc(sizeof(*hpriv), GFP_KERNEL); | ||
419 | if (!hpriv) { | ||
420 | rc = -ENOMEM; | ||
421 | goto err_out_iounmap; | ||
422 | } | ||
423 | memset(hpriv, 0, sizeof(*hpriv)); | ||
424 | |||
425 | /* | 385 | /* |
426 | * Due to a bug in the chip, the default cache line size can't be used | 386 | * Due to a bug in the chip, the default cache line size can't be used |
427 | */ | 387 | */ |
428 | pci_write_config_byte(pdev, PCI_CACHE_LINE_SIZE, 0x80); | 388 | pci_write_config_byte(pdev, PCI_CACHE_LINE_SIZE, 0x80); |
429 | 389 | ||
430 | if (pci_enable_msi(pdev) == 0) { | 390 | if (pci_enable_msi(pdev) == 0) |
431 | hpriv->hp_flags |= VSC_SATA_HP_FLAG_MSI; | ||
432 | pci_intx(pdev, 0); | 391 | pci_intx(pdev, 0); |
433 | } | ||
434 | else | 392 | else |
435 | probe_ent->irq_flags = IRQF_SHARED; | 393 | probe_ent->irq_flags = IRQF_SHARED; |
436 | 394 | ||
@@ -441,7 +399,6 @@ static int __devinit vsc_sata_init_one (struct pci_dev *pdev, const struct pci_d | |||
441 | probe_ent->n_ports = 4; | 399 | probe_ent->n_ports = 4; |
442 | probe_ent->irq = pdev->irq; | 400 | probe_ent->irq = pdev->irq; |
443 | probe_ent->mmio_base = mmio_base; | 401 | probe_ent->mmio_base = mmio_base; |
444 | probe_ent->private_data = hpriv; | ||
445 | 402 | ||
446 | /* We don't care much about the PIO/UDMA masks, but the core won't like us | 403 | /* We don't care much about the PIO/UDMA masks, but the core won't like us |
447 | * if we don't fill these | 404 | * if we don't fill these |
@@ -466,22 +423,11 @@ static int __devinit vsc_sata_init_one (struct pci_dev *pdev, const struct pci_d | |||
466 | */ | 423 | */ |
467 | pci_write_config_dword(pdev, 0x98, 0); | 424 | pci_write_config_dword(pdev, 0x98, 0); |
468 | 425 | ||
469 | /* FIXME: check ata_device_add return value */ | 426 | if (!ata_device_add(probe_ent)) |
470 | ata_device_add(probe_ent); | 427 | return -ENODEV; |
471 | 428 | ||
472 | kfree(probe_ent); | 429 | devm_kfree(&pdev->dev, probe_ent); |
473 | return 0; | 430 | return 0; |
474 | |||
475 | err_out_iounmap: | ||
476 | pci_iounmap(pdev, mmio_base); | ||
477 | err_out_free_ent: | ||
478 | kfree(probe_ent); | ||
479 | err_out_regions: | ||
480 | pci_release_regions(pdev); | ||
481 | err_out: | ||
482 | if (!pci_dev_busy) | ||
483 | pci_disable_device(pdev); | ||
484 | return rc; | ||
485 | } | 431 | } |
486 | 432 | ||
487 | static const struct pci_device_id vsc_sata_pci_tbl[] = { | 433 | static const struct pci_device_id vsc_sata_pci_tbl[] = { |