diff options
author | Julia Lawall <Julia.Lawall@lip6.fr> | 2013-01-07 07:51:21 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2013-02-13 14:27:47 -0500 |
commit | 47de201c73fbe435e7b635fa0eb812c7ce68be43 (patch) | |
tree | bd4d2cc449119ecce970b09deae49f0842368c2a /drivers/media/platform/soc_camera | |
parent | ec34e1d579819789ecde888c1d54310824957893 (diff) |
[media] drivers/media/platform/soc_camera/pxa_camera.c: use devm_ functions
This patch uses various devm_ functions for data that is allocated in the
probe function of a platform driver and is only freed in the remove
function.
This also fixes a checkpatch warning, removing a space before a \n in a
string.
Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/platform/soc_camera')
-rw-r--r-- | drivers/media/platform/soc_camera/pxa_camera.c | 65 |
1 files changed, 15 insertions, 50 deletions
diff --git a/drivers/media/platform/soc_camera/pxa_camera.c b/drivers/media/platform/soc_camera/pxa_camera.c index 9c97f7e985e1..395e2e043615 100644 --- a/drivers/media/platform/soc_camera/pxa_camera.c +++ b/drivers/media/platform/soc_camera/pxa_camera.c | |||
@@ -1661,23 +1661,18 @@ static int pxa_camera_probe(struct platform_device *pdev) | |||
1661 | 1661 | ||
1662 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 1662 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
1663 | irq = platform_get_irq(pdev, 0); | 1663 | irq = platform_get_irq(pdev, 0); |
1664 | if (!res || irq < 0) { | 1664 | if (!res || irq < 0) |
1665 | err = -ENODEV; | 1665 | return -ENODEV; |
1666 | goto exit; | ||
1667 | } | ||
1668 | 1666 | ||
1669 | pcdev = kzalloc(sizeof(*pcdev), GFP_KERNEL); | 1667 | pcdev = devm_kzalloc(&pdev->dev, sizeof(*pcdev), GFP_KERNEL); |
1670 | if (!pcdev) { | 1668 | if (!pcdev) { |
1671 | dev_err(&pdev->dev, "Could not allocate pcdev\n"); | 1669 | dev_err(&pdev->dev, "Could not allocate pcdev\n"); |
1672 | err = -ENOMEM; | 1670 | return -ENOMEM; |
1673 | goto exit; | ||
1674 | } | 1671 | } |
1675 | 1672 | ||
1676 | pcdev->clk = clk_get(&pdev->dev, NULL); | 1673 | pcdev->clk = devm_clk_get(&pdev->dev, NULL); |
1677 | if (IS_ERR(pcdev->clk)) { | 1674 | if (IS_ERR(pcdev->clk)) |
1678 | err = PTR_ERR(pcdev->clk); | 1675 | return PTR_ERR(pcdev->clk); |
1679 | goto exit_kfree; | ||
1680 | } | ||
1681 | 1676 | ||
1682 | pcdev->res = res; | 1677 | pcdev->res = res; |
1683 | 1678 | ||
@@ -1715,17 +1710,9 @@ static int pxa_camera_probe(struct platform_device *pdev) | |||
1715 | /* | 1710 | /* |
1716 | * Request the regions. | 1711 | * Request the regions. |
1717 | */ | 1712 | */ |
1718 | if (!request_mem_region(res->start, resource_size(res), | 1713 | base = devm_request_and_ioremap(&pdev->dev, res); |
1719 | PXA_CAM_DRV_NAME)) { | 1714 | if (!base) |
1720 | err = -EBUSY; | 1715 | return -ENOMEM; |
1721 | goto exit_clk; | ||
1722 | } | ||
1723 | |||
1724 | base = ioremap(res->start, resource_size(res)); | ||
1725 | if (!base) { | ||
1726 | err = -ENOMEM; | ||
1727 | goto exit_release; | ||
1728 | } | ||
1729 | pcdev->irq = irq; | 1716 | pcdev->irq = irq; |
1730 | pcdev->base = base; | 1717 | pcdev->base = base; |
1731 | 1718 | ||
@@ -1734,7 +1721,7 @@ static int pxa_camera_probe(struct platform_device *pdev) | |||
1734 | pxa_camera_dma_irq_y, pcdev); | 1721 | pxa_camera_dma_irq_y, pcdev); |
1735 | if (err < 0) { | 1722 | if (err < 0) { |
1736 | dev_err(&pdev->dev, "Can't request DMA for Y\n"); | 1723 | dev_err(&pdev->dev, "Can't request DMA for Y\n"); |
1737 | goto exit_iounmap; | 1724 | return err; |
1738 | } | 1725 | } |
1739 | pcdev->dma_chans[0] = err; | 1726 | pcdev->dma_chans[0] = err; |
1740 | dev_dbg(&pdev->dev, "got DMA channel %d\n", pcdev->dma_chans[0]); | 1727 | dev_dbg(&pdev->dev, "got DMA channel %d\n", pcdev->dma_chans[0]); |
@@ -1762,10 +1749,10 @@ static int pxa_camera_probe(struct platform_device *pdev) | |||
1762 | DRCMR(70) = pcdev->dma_chans[2] | DRCMR_MAPVLD; | 1749 | DRCMR(70) = pcdev->dma_chans[2] | DRCMR_MAPVLD; |
1763 | 1750 | ||
1764 | /* request irq */ | 1751 | /* request irq */ |
1765 | err = request_irq(pcdev->irq, pxa_camera_irq, 0, PXA_CAM_DRV_NAME, | 1752 | err = devm_request_irq(&pdev->dev, pcdev->irq, pxa_camera_irq, 0, |
1766 | pcdev); | 1753 | PXA_CAM_DRV_NAME, pcdev); |
1767 | if (err) { | 1754 | if (err) { |
1768 | dev_err(&pdev->dev, "Camera interrupt register failed \n"); | 1755 | dev_err(&pdev->dev, "Camera interrupt register failed\n"); |
1769 | goto exit_free_dma; | 1756 | goto exit_free_dma; |
1770 | } | 1757 | } |
1771 | 1758 | ||
@@ -1777,27 +1764,16 @@ static int pxa_camera_probe(struct platform_device *pdev) | |||
1777 | 1764 | ||
1778 | err = soc_camera_host_register(&pcdev->soc_host); | 1765 | err = soc_camera_host_register(&pcdev->soc_host); |
1779 | if (err) | 1766 | if (err) |
1780 | goto exit_free_irq; | 1767 | goto exit_free_dma; |
1781 | 1768 | ||
1782 | return 0; | 1769 | return 0; |
1783 | 1770 | ||
1784 | exit_free_irq: | ||
1785 | free_irq(pcdev->irq, pcdev); | ||
1786 | exit_free_dma: | 1771 | exit_free_dma: |
1787 | pxa_free_dma(pcdev->dma_chans[2]); | 1772 | pxa_free_dma(pcdev->dma_chans[2]); |
1788 | exit_free_dma_u: | 1773 | exit_free_dma_u: |
1789 | pxa_free_dma(pcdev->dma_chans[1]); | 1774 | pxa_free_dma(pcdev->dma_chans[1]); |
1790 | exit_free_dma_y: | 1775 | exit_free_dma_y: |
1791 | pxa_free_dma(pcdev->dma_chans[0]); | 1776 | pxa_free_dma(pcdev->dma_chans[0]); |
1792 | exit_iounmap: | ||
1793 | iounmap(base); | ||
1794 | exit_release: | ||
1795 | release_mem_region(res->start, resource_size(res)); | ||
1796 | exit_clk: | ||
1797 | clk_put(pcdev->clk); | ||
1798 | exit_kfree: | ||
1799 | kfree(pcdev); | ||
1800 | exit: | ||
1801 | return err; | 1777 | return err; |
1802 | } | 1778 | } |
1803 | 1779 | ||
@@ -1806,24 +1782,13 @@ static int pxa_camera_remove(struct platform_device *pdev) | |||
1806 | struct soc_camera_host *soc_host = to_soc_camera_host(&pdev->dev); | 1782 | struct soc_camera_host *soc_host = to_soc_camera_host(&pdev->dev); |
1807 | struct pxa_camera_dev *pcdev = container_of(soc_host, | 1783 | struct pxa_camera_dev *pcdev = container_of(soc_host, |
1808 | struct pxa_camera_dev, soc_host); | 1784 | struct pxa_camera_dev, soc_host); |
1809 | struct resource *res; | ||
1810 | |||
1811 | clk_put(pcdev->clk); | ||
1812 | 1785 | ||
1813 | pxa_free_dma(pcdev->dma_chans[0]); | 1786 | pxa_free_dma(pcdev->dma_chans[0]); |
1814 | pxa_free_dma(pcdev->dma_chans[1]); | 1787 | pxa_free_dma(pcdev->dma_chans[1]); |
1815 | pxa_free_dma(pcdev->dma_chans[2]); | 1788 | pxa_free_dma(pcdev->dma_chans[2]); |
1816 | free_irq(pcdev->irq, pcdev); | ||
1817 | 1789 | ||
1818 | soc_camera_host_unregister(soc_host); | 1790 | soc_camera_host_unregister(soc_host); |
1819 | 1791 | ||
1820 | iounmap(pcdev->base); | ||
1821 | |||
1822 | res = pcdev->res; | ||
1823 | release_mem_region(res->start, resource_size(res)); | ||
1824 | |||
1825 | kfree(pcdev); | ||
1826 | |||
1827 | dev_info(&pdev->dev, "PXA Camera driver unloaded\n"); | 1792 | dev_info(&pdev->dev, "PXA Camera driver unloaded\n"); |
1828 | 1793 | ||
1829 | return 0; | 1794 | return 0; |