diff options
author | Chuanxiao Dong <chuanxiao.dong@intel.com> | 2010-08-09 06:37:00 -0400 |
---|---|---|
committer | David Woodhouse <David.Woodhouse@intel.com> | 2010-08-10 19:28:36 -0400 |
commit | 5c0eb90094d64d56df8be23bb75d48e63c96c180 (patch) | |
tree | 042de2a2382a341e82fa80d9a3431af232f22623 /drivers | |
parent | e8a89cebdbaab14caaa26debdb4ffd493b8831af (diff) |
nand/denali: Fixed probe function bugs
Fixed a pci_resource_len function error;
Changed returning sequence of probe function;
Signed-off-by: Chuanxiao Dong <chuanxiao.dong@intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/mtd/nand/denali.c | 44 |
1 files changed, 23 insertions, 21 deletions
diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c index 618fb42b86b0..ab960efb67f0 100644 --- a/drivers/mtd/nand/denali.c +++ b/drivers/mtd/nand/denali.c | |||
@@ -1536,7 +1536,7 @@ static int denali_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) | |||
1536 | ret = pci_enable_device(dev); | 1536 | ret = pci_enable_device(dev); |
1537 | if (ret) { | 1537 | if (ret) { |
1538 | printk(KERN_ERR "Spectra: pci_enable_device failed.\n"); | 1538 | printk(KERN_ERR "Spectra: pci_enable_device failed.\n"); |
1539 | goto failed_enable; | 1539 | goto failed_alloc_memery; |
1540 | } | 1540 | } |
1541 | 1541 | ||
1542 | if (id->driver_data == INTEL_CE4100) { | 1542 | if (id->driver_data == INTEL_CE4100) { |
@@ -1547,7 +1547,7 @@ static int denali_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) | |||
1547 | printk(KERN_ERR "Intel CE4100 only supports" | 1547 | printk(KERN_ERR "Intel CE4100 only supports" |
1548 | " ONFI timing mode 1 or below\n"); | 1548 | " ONFI timing mode 1 or below\n"); |
1549 | ret = -EINVAL; | 1549 | ret = -EINVAL; |
1550 | goto failed_enable; | 1550 | goto failed_enable_dev; |
1551 | } | 1551 | } |
1552 | denali->platform = INTEL_CE4100; | 1552 | denali->platform = INTEL_CE4100; |
1553 | mem_base = pci_resource_start(dev, 0); | 1553 | mem_base = pci_resource_start(dev, 0); |
@@ -1557,7 +1557,7 @@ static int denali_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) | |||
1557 | } else { | 1557 | } else { |
1558 | denali->platform = INTEL_MRST; | 1558 | denali->platform = INTEL_MRST; |
1559 | csr_base = pci_resource_start(dev, 0); | 1559 | csr_base = pci_resource_start(dev, 0); |
1560 | csr_len = pci_resource_start(dev, 0); | 1560 | csr_len = pci_resource_len(dev, 0); |
1561 | mem_base = pci_resource_start(dev, 1); | 1561 | mem_base = pci_resource_start(dev, 1); |
1562 | mem_len = pci_resource_len(dev, 1); | 1562 | mem_len = pci_resource_len(dev, 1); |
1563 | if (!mem_len) { | 1563 | if (!mem_len) { |
@@ -1576,7 +1576,7 @@ static int denali_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) | |||
1576 | 1576 | ||
1577 | if (ret) { | 1577 | if (ret) { |
1578 | printk(KERN_ERR "Spectra: no usable DMA configuration\n"); | 1578 | printk(KERN_ERR "Spectra: no usable DMA configuration\n"); |
1579 | goto failed_enable; | 1579 | goto failed_enable_dev; |
1580 | } | 1580 | } |
1581 | denali->buf.dma_buf = | 1581 | denali->buf.dma_buf = |
1582 | pci_map_single(dev, denali->buf.buf, | 1582 | pci_map_single(dev, denali->buf.buf, |
@@ -1585,7 +1585,7 @@ static int denali_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) | |||
1585 | 1585 | ||
1586 | if (pci_dma_mapping_error(dev, denali->buf.dma_buf)) { | 1586 | if (pci_dma_mapping_error(dev, denali->buf.dma_buf)) { |
1587 | printk(KERN_ERR "Spectra: failed to map DMA buffer\n"); | 1587 | printk(KERN_ERR "Spectra: failed to map DMA buffer\n"); |
1588 | goto failed_enable; | 1588 | goto failed_enable_dev; |
1589 | } | 1589 | } |
1590 | 1590 | ||
1591 | pci_set_master(dev); | 1591 | pci_set_master(dev); |
@@ -1594,14 +1594,14 @@ static int denali_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) | |||
1594 | ret = pci_request_regions(dev, DENALI_NAND_NAME); | 1594 | ret = pci_request_regions(dev, DENALI_NAND_NAME); |
1595 | if (ret) { | 1595 | if (ret) { |
1596 | printk(KERN_ERR "Spectra: Unable to request memory regions\n"); | 1596 | printk(KERN_ERR "Spectra: Unable to request memory regions\n"); |
1597 | goto failed_req_csr; | 1597 | goto failed_dma_map; |
1598 | } | 1598 | } |
1599 | 1599 | ||
1600 | denali->flash_reg = ioremap_nocache(csr_base, csr_len); | 1600 | denali->flash_reg = ioremap_nocache(csr_base, csr_len); |
1601 | if (!denali->flash_reg) { | 1601 | if (!denali->flash_reg) { |
1602 | printk(KERN_ERR "Spectra: Unable to remap memory region\n"); | 1602 | printk(KERN_ERR "Spectra: Unable to remap memory region\n"); |
1603 | ret = -ENOMEM; | 1603 | ret = -ENOMEM; |
1604 | goto failed_remap_csr; | 1604 | goto failed_req_regions; |
1605 | } | 1605 | } |
1606 | nand_dbg_print(NAND_DBG_DEBUG, "Spectra: CSR 0x%08Lx -> 0x%p (0x%lx)\n", | 1606 | nand_dbg_print(NAND_DBG_DEBUG, "Spectra: CSR 0x%08Lx -> 0x%p (0x%lx)\n", |
1607 | (uint64_t)csr_base, denali->flash_reg, csr_len); | 1607 | (uint64_t)csr_base, denali->flash_reg, csr_len); |
@@ -1609,9 +1609,8 @@ static int denali_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) | |||
1609 | denali->flash_mem = ioremap_nocache(mem_base, mem_len); | 1609 | denali->flash_mem = ioremap_nocache(mem_base, mem_len); |
1610 | if (!denali->flash_mem) { | 1610 | if (!denali->flash_mem) { |
1611 | printk(KERN_ERR "Spectra: ioremap_nocache failed!"); | 1611 | printk(KERN_ERR "Spectra: ioremap_nocache failed!"); |
1612 | iounmap(denali->flash_reg); | ||
1613 | ret = -ENOMEM; | 1612 | ret = -ENOMEM; |
1614 | goto failed_remap_csr; | 1613 | goto failed_remap_reg; |
1615 | } | 1614 | } |
1616 | 1615 | ||
1617 | nand_dbg_print(NAND_DBG_WARN, | 1616 | nand_dbg_print(NAND_DBG_WARN, |
@@ -1627,7 +1626,7 @@ static int denali_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) | |||
1627 | DENALI_NAND_NAME, denali)) { | 1626 | DENALI_NAND_NAME, denali)) { |
1628 | printk(KERN_ERR "Spectra: Unable to allocate IRQ\n"); | 1627 | printk(KERN_ERR "Spectra: Unable to allocate IRQ\n"); |
1629 | ret = -ENODEV; | 1628 | ret = -ENODEV; |
1630 | goto failed_request_irq; | 1629 | goto failed_remap_mem; |
1631 | } | 1630 | } |
1632 | 1631 | ||
1633 | /* now that our ISR is registered, we can enable interrupts */ | 1632 | /* now that our ISR is registered, we can enable interrupts */ |
@@ -1664,7 +1663,7 @@ static int denali_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) | |||
1664 | * with the nand subsystem */ | 1663 | * with the nand subsystem */ |
1665 | if (nand_scan_ident(&denali->mtd, LLD_MAX_FLASH_BANKS, NULL)) { | 1664 | if (nand_scan_ident(&denali->mtd, LLD_MAX_FLASH_BANKS, NULL)) { |
1666 | ret = -ENXIO; | 1665 | ret = -ENXIO; |
1667 | goto failed_nand; | 1666 | goto failed_req_irq; |
1668 | } | 1667 | } |
1669 | 1668 | ||
1670 | /* MTD supported page sizes vary by kernel. We validate our | 1669 | /* MTD supported page sizes vary by kernel. We validate our |
@@ -1674,7 +1673,7 @@ static int denali_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) | |||
1674 | ret = -ENODEV; | 1673 | ret = -ENODEV; |
1675 | printk(KERN_ERR "Spectra: device size not supported by this " | 1674 | printk(KERN_ERR "Spectra: device size not supported by this " |
1676 | "version of MTD."); | 1675 | "version of MTD."); |
1677 | goto failed_nand; | 1676 | goto failed_req_irq; |
1678 | } | 1677 | } |
1679 | 1678 | ||
1680 | /* support for multi nand | 1679 | /* support for multi nand |
@@ -1725,7 +1724,7 @@ static int denali_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) | |||
1725 | ECC_SECTOR_SIZE))) { | 1724 | ECC_SECTOR_SIZE))) { |
1726 | printk(KERN_ERR "Your NAND chip OOB is not large enough to" | 1725 | printk(KERN_ERR "Your NAND chip OOB is not large enough to" |
1727 | " contain 8bit ECC correction codes"); | 1726 | " contain 8bit ECC correction codes"); |
1728 | goto failed_nand; | 1727 | goto failed_req_irq; |
1729 | } else { | 1728 | } else { |
1730 | denali->nand.ecc.layout = &nand_8bit_oob; | 1729 | denali->nand.ecc.layout = &nand_8bit_oob; |
1731 | denali->nand.ecc.bytes = ECC_8BITS; | 1730 | denali->nand.ecc.bytes = ECC_8BITS; |
@@ -1769,28 +1768,31 @@ static int denali_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) | |||
1769 | 1768 | ||
1770 | if (nand_scan_tail(&denali->mtd)) { | 1769 | if (nand_scan_tail(&denali->mtd)) { |
1771 | ret = -ENXIO; | 1770 | ret = -ENXIO; |
1772 | goto failed_nand; | 1771 | goto failed_req_irq; |
1773 | } | 1772 | } |
1774 | 1773 | ||
1775 | ret = add_mtd_device(&denali->mtd); | 1774 | ret = add_mtd_device(&denali->mtd); |
1776 | if (ret) { | 1775 | if (ret) { |
1777 | printk(KERN_ERR "Spectra: Failed to register" | 1776 | printk(KERN_ERR "Spectra: Failed to register" |
1778 | " MTD device: %d\n", ret); | 1777 | " MTD device: %d\n", ret); |
1779 | goto failed_nand; | 1778 | goto failed_req_irq; |
1780 | } | 1779 | } |
1781 | return 0; | 1780 | return 0; |
1782 | 1781 | ||
1783 | failed_nand: | 1782 | failed_req_irq: |
1784 | denali_irq_cleanup(dev->irq, denali); | 1783 | denali_irq_cleanup(dev->irq, denali); |
1785 | failed_request_irq: | 1784 | failed_remap_mem: |
1786 | iounmap(denali->flash_reg); | ||
1787 | iounmap(denali->flash_mem); | 1785 | iounmap(denali->flash_mem); |
1788 | failed_remap_csr: | 1786 | failed_remap_reg: |
1787 | iounmap(denali->flash_reg); | ||
1788 | failed_req_regions: | ||
1789 | pci_release_regions(dev); | 1789 | pci_release_regions(dev); |
1790 | failed_req_csr: | 1790 | failed_dma_map: |
1791 | pci_unmap_single(dev, denali->buf.dma_buf, DENALI_BUF_SIZE, | 1791 | pci_unmap_single(dev, denali->buf.dma_buf, DENALI_BUF_SIZE, |
1792 | PCI_DMA_BIDIRECTIONAL); | 1792 | PCI_DMA_BIDIRECTIONAL); |
1793 | failed_enable: | 1793 | failed_enable_dev: |
1794 | pci_disable_device(dev); | ||
1795 | failed_alloc_memery: | ||
1794 | kfree(denali); | 1796 | kfree(denali); |
1795 | return ret; | 1797 | return ret; |
1796 | } | 1798 | } |