aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/platform/soc_camera/pxa_camera.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/platform/soc_camera/pxa_camera.c')
-rw-r--r--drivers/media/platform/soc_camera/pxa_camera.c73
1 files changed, 19 insertions, 54 deletions
diff --git a/drivers/media/platform/soc_camera/pxa_camera.c b/drivers/media/platform/soc_camera/pxa_camera.c
index 523330d00dee..395e2e043615 100644
--- a/drivers/media/platform/soc_camera/pxa_camera.c
+++ b/drivers/media/platform/soc_camera/pxa_camera.c
@@ -681,7 +681,7 @@ static void pxa_camera_wakeup(struct pxa_camera_dev *pcdev,
681 /* _init is used to debug races, see comment in pxa_camera_reqbufs() */ 681 /* _init is used to debug races, see comment in pxa_camera_reqbufs() */
682 list_del_init(&vb->queue); 682 list_del_init(&vb->queue);
683 vb->state = VIDEOBUF_DONE; 683 vb->state = VIDEOBUF_DONE;
684 do_gettimeofday(&vb->ts); 684 v4l2_get_timestamp(&vb->ts);
685 vb->field_count++; 685 vb->field_count++;
686 wake_up(&vb->done); 686 wake_up(&vb->done);
687 dev_dbg(pcdev->soc_host.v4l2_dev.dev, "%s dequeud buffer (vb=0x%p)\n", 687 dev_dbg(pcdev->soc_host.v4l2_dev.dev, "%s dequeud buffer (vb=0x%p)\n",
@@ -842,7 +842,7 @@ static void pxa_camera_init_videobuf(struct videobuf_queue *q,
842 */ 842 */
843 videobuf_queue_sg_init(q, &pxa_videobuf_ops, NULL, &pcdev->lock, 843 videobuf_queue_sg_init(q, &pxa_videobuf_ops, NULL, &pcdev->lock,
844 V4L2_BUF_TYPE_VIDEO_CAPTURE, V4L2_FIELD_NONE, 844 V4L2_BUF_TYPE_VIDEO_CAPTURE, V4L2_FIELD_NONE,
845 sizeof(struct pxa_buffer), icd, &icd->video_lock); 845 sizeof(struct pxa_buffer), icd, &ici->host_lock);
846} 846}
847 847
848static u32 mclk_get_divisor(struct platform_device *pdev, 848static u32 mclk_get_divisor(struct platform_device *pdev,
@@ -958,7 +958,7 @@ static irqreturn_t pxa_camera_irq(int irq, void *data)
958/* 958/*
959 * The following two functions absolutely depend on the fact, that 959 * The following two functions absolutely depend on the fact, that
960 * there can be only one camera on PXA quick capture interface 960 * there can be only one camera on PXA quick capture interface
961 * Called with .video_lock held 961 * Called with .host_lock held
962 */ 962 */
963static int pxa_camera_add_device(struct soc_camera_device *icd) 963static int pxa_camera_add_device(struct soc_camera_device *icd)
964{ 964{
@@ -978,7 +978,7 @@ static int pxa_camera_add_device(struct soc_camera_device *icd)
978 return 0; 978 return 0;
979} 979}
980 980
981/* Called with .video_lock held */ 981/* Called with .host_lock held */
982static void pxa_camera_remove_device(struct soc_camera_device *icd) 982static void pxa_camera_remove_device(struct soc_camera_device *icd)
983{ 983{
984 struct soc_camera_host *ici = to_soc_camera_host(icd->parent); 984 struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
@@ -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
1784exit_free_irq:
1785 free_irq(pcdev->irq, pcdev);
1786exit_free_dma: 1771exit_free_dma:
1787 pxa_free_dma(pcdev->dma_chans[2]); 1772 pxa_free_dma(pcdev->dma_chans[2]);
1788exit_free_dma_u: 1773exit_free_dma_u:
1789 pxa_free_dma(pcdev->dma_chans[1]); 1774 pxa_free_dma(pcdev->dma_chans[1]);
1790exit_free_dma_y: 1775exit_free_dma_y:
1791 pxa_free_dma(pcdev->dma_chans[0]); 1776 pxa_free_dma(pcdev->dma_chans[0]);
1792exit_iounmap:
1793 iounmap(base);
1794exit_release:
1795 release_mem_region(res->start, resource_size(res));
1796exit_clk:
1797 clk_put(pcdev->clk);
1798exit_kfree:
1799 kfree(pcdev);
1800exit:
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;