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

[media] V4L2: mx3_camera: convert to managed resource allocation

Use devm_* resource allocators to simplify the driver's probe and clean up
paths.
Signed-off-by: default avatarGuennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: default avatarMauro Carvalho Chehab <m.chehab@samsung.com>
parent 23272427
...@@ -1151,23 +1151,19 @@ static int mx3_camera_probe(struct platform_device *pdev) ...@@ -1151,23 +1151,19 @@ static int mx3_camera_probe(struct platform_device *pdev)
struct soc_camera_host *soc_host; struct soc_camera_host *soc_host;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) { base = devm_ioremap_resource(&pdev->dev, res);
err = -ENODEV; if (IS_ERR(base))
goto egetres; return PTR_ERR(base);
}
mx3_cam = vzalloc(sizeof(*mx3_cam)); mx3_cam = devm_kzalloc(&pdev->dev, sizeof(*mx3_cam), GFP_KERNEL);
if (!mx3_cam) { if (!mx3_cam) {
dev_err(&pdev->dev, "Could not allocate mx3 camera object\n"); dev_err(&pdev->dev, "Could not allocate mx3 camera object\n");
err = -ENOMEM; return -ENOMEM;
goto ealloc;
} }
mx3_cam->clk = clk_get(&pdev->dev, NULL); mx3_cam->clk = devm_clk_get(&pdev->dev, NULL);
if (IS_ERR(mx3_cam->clk)) { if (IS_ERR(mx3_cam->clk))
err = PTR_ERR(mx3_cam->clk); return PTR_ERR(mx3_cam->clk);
goto eclkget;
}
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;
...@@ -1201,13 +1197,6 @@ static int mx3_camera_probe(struct platform_device *pdev) ...@@ -1201,13 +1197,6 @@ static int mx3_camera_probe(struct platform_device *pdev)
INIT_LIST_HEAD(&mx3_cam->capture); INIT_LIST_HEAD(&mx3_cam->capture);
spin_lock_init(&mx3_cam->lock); spin_lock_init(&mx3_cam->lock);
base = ioremap(res->start, resource_size(res));
if (!base) {
pr_err("Couldn't map %x@%x\n", resource_size(res), res->start);
err = -ENOMEM;
goto eioremap;
}
mx3_cam->base = base; mx3_cam->base = base;
soc_host = &mx3_cam->soc_host; soc_host = &mx3_cam->soc_host;
...@@ -1218,10 +1207,8 @@ static int mx3_camera_probe(struct platform_device *pdev) ...@@ -1218,10 +1207,8 @@ static int mx3_camera_probe(struct platform_device *pdev)
soc_host->nr = pdev->id; soc_host->nr = pdev->id;
mx3_cam->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev); mx3_cam->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev);
if (IS_ERR(mx3_cam->alloc_ctx)) { if (IS_ERR(mx3_cam->alloc_ctx))
err = PTR_ERR(mx3_cam->alloc_ctx); return PTR_ERR(mx3_cam->alloc_ctx);
goto eallocctx;
}
err = soc_camera_host_register(soc_host); err = soc_camera_host_register(soc_host);
if (err) if (err)
...@@ -1234,14 +1221,6 @@ static int mx3_camera_probe(struct platform_device *pdev) ...@@ -1234,14 +1221,6 @@ static int mx3_camera_probe(struct platform_device *pdev)
ecamhostreg: ecamhostreg:
vb2_dma_contig_cleanup_ctx(mx3_cam->alloc_ctx); vb2_dma_contig_cleanup_ctx(mx3_cam->alloc_ctx);
eallocctx:
iounmap(base);
eioremap:
clk_put(mx3_cam->clk);
eclkget:
vfree(mx3_cam);
ealloc:
egetres:
return err; return err;
} }
...@@ -1251,12 +1230,8 @@ static int mx3_camera_remove(struct platform_device *pdev) ...@@ -1251,12 +1230,8 @@ static int mx3_camera_remove(struct platform_device *pdev)
struct mx3_camera_dev *mx3_cam = container_of(soc_host, struct mx3_camera_dev *mx3_cam = container_of(soc_host,
struct mx3_camera_dev, soc_host); struct mx3_camera_dev, soc_host);
clk_put(mx3_cam->clk);
soc_camera_host_unregister(soc_host); soc_camera_host_unregister(soc_host);
iounmap(mx3_cam->base);
/* /*
* The channel has either not been allocated, * The channel has either not been allocated,
* or should have been released * or should have been released
...@@ -1266,8 +1241,6 @@ static int mx3_camera_remove(struct platform_device *pdev) ...@@ -1266,8 +1241,6 @@ static int mx3_camera_remove(struct platform_device *pdev)
vb2_dma_contig_cleanup_ctx(mx3_cam->alloc_ctx); vb2_dma_contig_cleanup_ctx(mx3_cam->alloc_ctx);
vfree(mx3_cam);
dmaengine_put(); dmaengine_put();
return 0; return 0;
......
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