Commit eb6c8558 authored by Guennadi Liakhovetski's avatar Guennadi Liakhovetski Committed by Mauro Carvalho Chehab

V4L/DVB (11608): soc-camera: host-driver cleanup

Embed struct soc_camera_host in platform-specific per host instance objects
instead of allocating them statically in drivers, use platform_[gs]et_drvdata
consistently, use resource_size().
Signed-off-by: default avatarGuennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 594bb46d
...@@ -102,6 +102,7 @@ struct mx1_buffer { ...@@ -102,6 +102,7 @@ struct mx1_buffer {
* Interface. If anyone ever builds hardware to enable more than * Interface. If anyone ever builds hardware to enable more than
* one camera, they will have to modify this driver too */ * one camera, they will have to modify this driver too */
struct mx1_camera_dev { struct mx1_camera_dev {
struct soc_camera_host soc_host;
struct soc_camera_device *icd; struct soc_camera_device *icd;
struct mx1_camera_pdata *pdata; struct mx1_camera_pdata *pdata;
struct mx1_buffer *active; struct mx1_buffer *active;
...@@ -633,12 +634,6 @@ static struct soc_camera_host_ops mx1_soc_camera_host_ops = { ...@@ -633,12 +634,6 @@ static struct soc_camera_host_ops mx1_soc_camera_host_ops = {
.querycap = mx1_camera_querycap, .querycap = mx1_camera_querycap,
}; };
/* Should be allocated dynamically too, but we have only one. */
static struct soc_camera_host mx1_soc_camera_host = {
.drv_name = DRIVER_NAME,
.ops = &mx1_soc_camera_host_ops,
};
static struct fiq_handler fh = { static struct fiq_handler fh = {
.name = "csi_sof" .name = "csi_sof"
}; };
...@@ -673,7 +668,7 @@ static int __init mx1_camera_probe(struct platform_device *pdev) ...@@ -673,7 +668,7 @@ static int __init mx1_camera_probe(struct platform_device *pdev)
goto exit_put_clk; goto exit_put_clk;
} }
dev_set_drvdata(&pdev->dev, pcdev); platform_set_drvdata(pdev, pcdev);
pcdev->res = res; pcdev->res = res;
pcdev->clk = clk; pcdev->clk = clk;
...@@ -746,10 +741,12 @@ static int __init mx1_camera_probe(struct platform_device *pdev) ...@@ -746,10 +741,12 @@ static int __init mx1_camera_probe(struct platform_device *pdev)
mxc_set_irq_fiq(irq, 1); mxc_set_irq_fiq(irq, 1);
enable_fiq(irq); enable_fiq(irq);
mx1_soc_camera_host.priv = pcdev; pcdev->soc_host.drv_name = DRIVER_NAME;
mx1_soc_camera_host.dev.parent = &pdev->dev; pcdev->soc_host.ops = &mx1_soc_camera_host_ops;
mx1_soc_camera_host.nr = pdev->id; pcdev->soc_host.priv = pcdev;
err = soc_camera_host_register(&mx1_soc_camera_host); pcdev->soc_host.dev.parent = &pdev->dev;
pcdev->soc_host.nr = pdev->id;
err = soc_camera_host_register(&pcdev->soc_host);
if (err) if (err)
goto exit_free_irq; goto exit_free_irq;
...@@ -787,7 +784,7 @@ static int __exit mx1_camera_remove(struct platform_device *pdev) ...@@ -787,7 +784,7 @@ static int __exit mx1_camera_remove(struct platform_device *pdev)
clk_put(pcdev->clk); clk_put(pcdev->clk);
soc_camera_host_unregister(&mx1_soc_camera_host); soc_camera_host_unregister(&pcdev->soc_host);
iounmap(pcdev->base); iounmap(pcdev->base);
......
...@@ -1102,7 +1102,7 @@ static int mx3_camera_probe(struct platform_device *pdev) ...@@ -1102,7 +1102,7 @@ static int mx3_camera_probe(struct platform_device *pdev)
goto eclkget; goto eclkget;
} }
dev_set_drvdata(&pdev->dev, mx3_cam); platform_set_drvdata(pdev, mx3_cam);
mx3_cam->pdata = pdev->dev.platform_data; mx3_cam->pdata = pdev->dev.platform_data;
mx3_cam->platform_flags = mx3_cam->pdata->flags; mx3_cam->platform_flags = mx3_cam->pdata->flags;
......
...@@ -202,6 +202,7 @@ struct pxa_buffer { ...@@ -202,6 +202,7 @@ struct pxa_buffer {
}; };
struct pxa_camera_dev { struct pxa_camera_dev {
struct soc_camera_host soc_host;
struct device *dev; struct device *dev;
/* PXA27x is only supposed to handle one camera on its Quick Capture /* PXA27x is only supposed to handle one camera on its Quick Capture
* interface. If anyone ever builds hardware to enable more than * interface. If anyone ever builds hardware to enable more than
...@@ -1552,12 +1553,6 @@ static struct soc_camera_host_ops pxa_soc_camera_host_ops = { ...@@ -1552,12 +1553,6 @@ static struct soc_camera_host_ops pxa_soc_camera_host_ops = {
.set_bus_param = pxa_camera_set_bus_param, .set_bus_param = pxa_camera_set_bus_param,
}; };
/* Should be allocated dynamically too, but we have only one. */
static struct soc_camera_host pxa_soc_camera_host = {
.drv_name = PXA_CAM_DRV_NAME,
.ops = &pxa_soc_camera_host_ops,
};
static int pxa_camera_probe(struct platform_device *pdev) static int pxa_camera_probe(struct platform_device *pdev)
{ {
struct pxa_camera_dev *pcdev; struct pxa_camera_dev *pcdev;
...@@ -1586,7 +1581,7 @@ static int pxa_camera_probe(struct platform_device *pdev) ...@@ -1586,7 +1581,7 @@ static int pxa_camera_probe(struct platform_device *pdev)
goto exit_kfree; goto exit_kfree;
} }
dev_set_drvdata(&pdev->dev, pcdev); platform_set_drvdata(pdev, pcdev);
pcdev->res = res; pcdev->res = res;
pcdev->pdata = pdev->dev.platform_data; pcdev->pdata = pdev->dev.platform_data;
...@@ -1616,13 +1611,13 @@ static int pxa_camera_probe(struct platform_device *pdev) ...@@ -1616,13 +1611,13 @@ static int pxa_camera_probe(struct platform_device *pdev)
/* /*
* Request the regions. * Request the regions.
*/ */
if (!request_mem_region(res->start, res->end - res->start + 1, if (!request_mem_region(res->start, resource_size(res),
PXA_CAM_DRV_NAME)) { PXA_CAM_DRV_NAME)) {
err = -EBUSY; err = -EBUSY;
goto exit_clk; goto exit_clk;
} }
base = ioremap(res->start, res->end - res->start + 1); base = ioremap(res->start, resource_size(res));
if (!base) { if (!base) {
err = -ENOMEM; err = -ENOMEM;
goto exit_release; goto exit_release;
...@@ -1670,10 +1665,12 @@ static int pxa_camera_probe(struct platform_device *pdev) ...@@ -1670,10 +1665,12 @@ static int pxa_camera_probe(struct platform_device *pdev)
goto exit_free_dma; goto exit_free_dma;
} }
pxa_soc_camera_host.priv = pcdev; pcdev->soc_host.drv_name = PXA_CAM_DRV_NAME;
pxa_soc_camera_host.dev.parent = &pdev->dev; pcdev->soc_host.ops = &pxa_soc_camera_host_ops;
pxa_soc_camera_host.nr = pdev->id; pcdev->soc_host.priv = pcdev;
err = soc_camera_host_register(&pxa_soc_camera_host); pcdev->soc_host.dev.parent = &pdev->dev;
pcdev->soc_host.nr = pdev->id;
err = soc_camera_host_register(&pcdev->soc_host);
if (err) if (err)
goto exit_free_irq; goto exit_free_irq;
...@@ -1690,7 +1687,7 @@ static int pxa_camera_probe(struct platform_device *pdev) ...@@ -1690,7 +1687,7 @@ static int pxa_camera_probe(struct platform_device *pdev)
exit_iounmap: exit_iounmap:
iounmap(base); iounmap(base);
exit_release: exit_release:
release_mem_region(res->start, res->end - res->start + 1); release_mem_region(res->start, resource_size(res));
exit_clk: exit_clk:
clk_put(pcdev->clk); clk_put(pcdev->clk);
exit_kfree: exit_kfree:
...@@ -1711,12 +1708,12 @@ static int __devexit pxa_camera_remove(struct platform_device *pdev) ...@@ -1711,12 +1708,12 @@ static int __devexit pxa_camera_remove(struct platform_device *pdev)
pxa_free_dma(pcdev->dma_chans[2]); pxa_free_dma(pcdev->dma_chans[2]);
free_irq(pcdev->irq, pcdev); free_irq(pcdev->irq, pcdev);
soc_camera_host_unregister(&pxa_soc_camera_host); soc_camera_host_unregister(&pcdev->soc_host);
iounmap(pcdev->base); iounmap(pcdev->base);
res = pcdev->res; res = pcdev->res;
release_mem_region(res->start, res->end - res->start + 1); release_mem_region(res->start, resource_size(res));
kfree(pcdev); kfree(pcdev);
......
...@@ -840,7 +840,7 @@ static int sh_mobile_ceu_probe(struct platform_device *pdev) ...@@ -840,7 +840,7 @@ static int sh_mobile_ceu_probe(struct platform_device *pdev)
goto exit_kfree; goto exit_kfree;
} }
base = ioremap_nocache(res->start, res->end - res->start + 1); base = ioremap_nocache(res->start, resource_size(res));
if (!base) { if (!base) {
err = -ENXIO; err = -ENXIO;
dev_err(&pdev->dev, "Unable to ioremap CEU registers.\n"); dev_err(&pdev->dev, "Unable to ioremap CEU registers.\n");
...@@ -856,7 +856,7 @@ static int sh_mobile_ceu_probe(struct platform_device *pdev) ...@@ -856,7 +856,7 @@ static int sh_mobile_ceu_probe(struct platform_device *pdev)
if (res) { if (res) {
err = dma_declare_coherent_memory(&pdev->dev, res->start, err = dma_declare_coherent_memory(&pdev->dev, res->start,
res->start, res->start,
(res->end - res->start) + 1, resource_size(res),
DMA_MEMORY_MAP | DMA_MEMORY_MAP |
DMA_MEMORY_EXCLUSIVE); DMA_MEMORY_EXCLUSIVE);
if (!err) { if (!err) {
...@@ -865,7 +865,7 @@ static int sh_mobile_ceu_probe(struct platform_device *pdev) ...@@ -865,7 +865,7 @@ static int sh_mobile_ceu_probe(struct platform_device *pdev)
goto exit_iounmap; goto exit_iounmap;
} }
pcdev->video_limit = (res->end - res->start) + 1; pcdev->video_limit = resource_size(res);
} }
/* request irq */ /* request irq */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment