aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/platform
diff options
context:
space:
mode:
authorGuennadi Liakhovetski <g.liakhovetski@gmx.de>2013-07-29 11:18:04 -0400
committerMauro Carvalho Chehab <m.chehab@samsung.com>2013-08-18 08:05:17 -0400
commit72f2874411dff8d8ec424ecf7e2d1a3ebe0302f0 (patch)
treea37c5a00a8623bda2d557f0df4b7c98d0d19a22d /drivers/media/platform
parent23272427ccf70d40b3abb81ea92f505adc1bdcd1 (diff)
[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: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Diffstat (limited to 'drivers/media/platform')
-rw-r--r--drivers/media/platform/soc_camera/mx3_camera.c47
1 files changed, 10 insertions, 37 deletions
diff --git a/drivers/media/platform/soc_camera/mx3_camera.c b/drivers/media/platform/soc_camera/mx3_camera.c
index 1047e3e8db77..e52609652690 100644
--- a/drivers/media/platform/soc_camera/mx3_camera.c
+++ b/drivers/media/platform/soc_camera/mx3_camera.c
@@ -1151,23 +1151,19 @@ static int mx3_camera_probe(struct platform_device *pdev)
1151 struct soc_camera_host *soc_host; 1151 struct soc_camera_host *soc_host;
1152 1152
1153 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1153 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1154 if (!res) { 1154 base = devm_ioremap_resource(&pdev->dev, res);
1155 err = -ENODEV; 1155 if (IS_ERR(base))
1156 goto egetres; 1156 return PTR_ERR(base);
1157 }
1158 1157
1159 mx3_cam = vzalloc(sizeof(*mx3_cam)); 1158 mx3_cam = devm_kzalloc(&pdev->dev, sizeof(*mx3_cam), GFP_KERNEL);
1160 if (!mx3_cam) { 1159 if (!mx3_cam) {
1161 dev_err(&pdev->dev, "Could not allocate mx3 camera object\n"); 1160 dev_err(&pdev->dev, "Could not allocate mx3 camera object\n");
1162 err = -ENOMEM; 1161 return -ENOMEM;
1163 goto ealloc;
1164 } 1162 }
1165 1163
1166 mx3_cam->clk = clk_get(&pdev->dev, NULL); 1164 mx3_cam->clk = devm_clk_get(&pdev->dev, NULL);
1167 if (IS_ERR(mx3_cam->clk)) { 1165 if (IS_ERR(mx3_cam->clk))
1168 err = PTR_ERR(mx3_cam->clk); 1166 return PTR_ERR(mx3_cam->clk);
1169 goto eclkget;
1170 }
1171 1167
1172 mx3_cam->pdata = pdev->dev.platform_data; 1168 mx3_cam->pdata = pdev->dev.platform_data;
1173 mx3_cam->platform_flags = mx3_cam->pdata->flags; 1169 mx3_cam->platform_flags = mx3_cam->pdata->flags;
@@ -1201,13 +1197,6 @@ static int mx3_camera_probe(struct platform_device *pdev)
1201 INIT_LIST_HEAD(&mx3_cam->capture); 1197 INIT_LIST_HEAD(&mx3_cam->capture);
1202 spin_lock_init(&mx3_cam->lock); 1198 spin_lock_init(&mx3_cam->lock);
1203 1199
1204 base = ioremap(res->start, resource_size(res));
1205 if (!base) {
1206 pr_err("Couldn't map %x@%x\n", resource_size(res), res->start);
1207 err = -ENOMEM;
1208 goto eioremap;
1209 }
1210
1211 mx3_cam->base = base; 1200 mx3_cam->base = base;
1212 1201
1213 soc_host = &mx3_cam->soc_host; 1202 soc_host = &mx3_cam->soc_host;
@@ -1218,10 +1207,8 @@ static int mx3_camera_probe(struct platform_device *pdev)
1218 soc_host->nr = pdev->id; 1207 soc_host->nr = pdev->id;
1219 1208
1220 mx3_cam->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev); 1209 mx3_cam->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev);
1221 if (IS_ERR(mx3_cam->alloc_ctx)) { 1210 if (IS_ERR(mx3_cam->alloc_ctx))
1222 err = PTR_ERR(mx3_cam->alloc_ctx); 1211 return PTR_ERR(mx3_cam->alloc_ctx);
1223 goto eallocctx;
1224 }
1225 1212
1226 err = soc_camera_host_register(soc_host); 1213 err = soc_camera_host_register(soc_host);
1227 if (err) 1214 if (err)
@@ -1234,14 +1221,6 @@ static int mx3_camera_probe(struct platform_device *pdev)
1234 1221
1235ecamhostreg: 1222ecamhostreg:
1236 vb2_dma_contig_cleanup_ctx(mx3_cam->alloc_ctx); 1223 vb2_dma_contig_cleanup_ctx(mx3_cam->alloc_ctx);
1237eallocctx:
1238 iounmap(base);
1239eioremap:
1240 clk_put(mx3_cam->clk);
1241eclkget:
1242 vfree(mx3_cam);
1243ealloc:
1244egetres:
1245 return err; 1224 return err;
1246} 1225}
1247 1226
@@ -1251,12 +1230,8 @@ static int mx3_camera_remove(struct platform_device *pdev)
1251 struct mx3_camera_dev *mx3_cam = container_of(soc_host, 1230 struct mx3_camera_dev *mx3_cam = container_of(soc_host,
1252 struct mx3_camera_dev, soc_host); 1231 struct mx3_camera_dev, soc_host);
1253 1232
1254 clk_put(mx3_cam->clk);
1255
1256 soc_camera_host_unregister(soc_host); 1233 soc_camera_host_unregister(soc_host);
1257 1234
1258 iounmap(mx3_cam->base);
1259
1260 /* 1235 /*
1261 * The channel has either not been allocated, 1236 * The channel has either not been allocated,
1262 * or should have been released 1237 * or should have been released
@@ -1266,8 +1241,6 @@ static int mx3_camera_remove(struct platform_device *pdev)
1266 1241
1267 vb2_dma_contig_cleanup_ctx(mx3_cam->alloc_ctx); 1242 vb2_dma_contig_cleanup_ctx(mx3_cam->alloc_ctx);
1268 1243
1269 vfree(mx3_cam);
1270
1271 dmaengine_put(); 1244 dmaengine_put();
1272 1245
1273 return 0; 1246 return 0;