diff options
author | Sachin Kamat <sachin.kamat@linaro.org> | 2012-05-14 05:33:34 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-05-20 08:05:44 -0400 |
commit | 5b58b95405aafbaf7362564dbcf6231836f1433c (patch) | |
tree | c4d30a8f68c93c0dfae21591afb472e7e14cb525 /drivers | |
parent | 32fced05ad9ef4736e4a89b2361cccf56227529b (diff) |
[media] s5p-jpeg: Use devm_* functions in jpeg-core.c file
devm_* functions are used to replace kzalloc, request_mem_region, ioremap
and request_irq functions in probe call. With the usage of devm_* functions
explicit freeing and unmapping is not required.
Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/media/video/s5p-jpeg/jpeg-core.c | 58 | ||||
-rw-r--r-- | drivers/media/video/s5p-jpeg/jpeg-core.h | 2 |
2 files changed, 10 insertions, 50 deletions
diff --git a/drivers/media/video/s5p-jpeg/jpeg-core.c b/drivers/media/video/s5p-jpeg/jpeg-core.c index 2d7dd8ac73f3..28b5225d94f5 100644 --- a/drivers/media/video/s5p-jpeg/jpeg-core.c +++ b/drivers/media/video/s5p-jpeg/jpeg-core.c | |||
@@ -1290,7 +1290,7 @@ static int s5p_jpeg_probe(struct platform_device *pdev) | |||
1290 | int ret; | 1290 | int ret; |
1291 | 1291 | ||
1292 | /* JPEG IP abstraction struct */ | 1292 | /* JPEG IP abstraction struct */ |
1293 | jpeg = kzalloc(sizeof(struct s5p_jpeg), GFP_KERNEL); | 1293 | jpeg = devm_kzalloc(&pdev->dev, sizeof(struct s5p_jpeg), GFP_KERNEL); |
1294 | if (!jpeg) | 1294 | if (!jpeg) |
1295 | return -ENOMEM; | 1295 | return -ENOMEM; |
1296 | 1296 | ||
@@ -1300,43 +1300,25 @@ static int s5p_jpeg_probe(struct platform_device *pdev) | |||
1300 | 1300 | ||
1301 | /* memory-mapped registers */ | 1301 | /* memory-mapped registers */ |
1302 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 1302 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
1303 | if (!res) { | ||
1304 | dev_err(&pdev->dev, "cannot find IO resource\n"); | ||
1305 | ret = -ENOENT; | ||
1306 | goto jpeg_alloc_rollback; | ||
1307 | } | ||
1308 | |||
1309 | jpeg->ioarea = request_mem_region(res->start, resource_size(res), | ||
1310 | pdev->name); | ||
1311 | if (!jpeg->ioarea) { | ||
1312 | dev_err(&pdev->dev, "cannot request IO\n"); | ||
1313 | ret = -ENXIO; | ||
1314 | goto jpeg_alloc_rollback; | ||
1315 | } | ||
1316 | 1303 | ||
1317 | jpeg->regs = ioremap(res->start, resource_size(res)); | 1304 | jpeg->regs = devm_request_and_ioremap(&pdev->dev, res); |
1318 | if (!jpeg->regs) { | 1305 | if (jpeg->regs == NULL) { |
1319 | dev_err(&pdev->dev, "cannot map IO\n"); | 1306 | dev_err(&pdev->dev, "Failed to obtain io memory\n"); |
1320 | ret = -ENXIO; | 1307 | return -ENOENT; |
1321 | goto mem_region_rollback; | ||
1322 | } | 1308 | } |
1323 | 1309 | ||
1324 | dev_dbg(&pdev->dev, "registers %p (%p, %p)\n", | ||
1325 | jpeg->regs, jpeg->ioarea, res); | ||
1326 | |||
1327 | /* interrupt service routine registration */ | 1310 | /* interrupt service routine registration */ |
1328 | jpeg->irq = ret = platform_get_irq(pdev, 0); | 1311 | jpeg->irq = ret = platform_get_irq(pdev, 0); |
1329 | if (ret < 0) { | 1312 | if (ret < 0) { |
1330 | dev_err(&pdev->dev, "cannot find IRQ\n"); | 1313 | dev_err(&pdev->dev, "cannot find IRQ\n"); |
1331 | goto ioremap_rollback; | 1314 | return ret; |
1332 | } | 1315 | } |
1333 | 1316 | ||
1334 | ret = request_irq(jpeg->irq, s5p_jpeg_irq, 0, | 1317 | ret = devm_request_irq(&pdev->dev, jpeg->irq, s5p_jpeg_irq, 0, |
1335 | dev_name(&pdev->dev), jpeg); | 1318 | dev_name(&pdev->dev), jpeg); |
1336 | |||
1337 | if (ret) { | 1319 | if (ret) { |
1338 | dev_err(&pdev->dev, "cannot claim IRQ %d\n", jpeg->irq); | 1320 | dev_err(&pdev->dev, "cannot claim IRQ %d\n", jpeg->irq); |
1339 | goto ioremap_rollback; | 1321 | return ret; |
1340 | } | 1322 | } |
1341 | 1323 | ||
1342 | /* clocks */ | 1324 | /* clocks */ |
@@ -1344,7 +1326,7 @@ static int s5p_jpeg_probe(struct platform_device *pdev) | |||
1344 | if (IS_ERR(jpeg->clk)) { | 1326 | if (IS_ERR(jpeg->clk)) { |
1345 | dev_err(&pdev->dev, "cannot get clock\n"); | 1327 | dev_err(&pdev->dev, "cannot get clock\n"); |
1346 | ret = PTR_ERR(jpeg->clk); | 1328 | ret = PTR_ERR(jpeg->clk); |
1347 | goto request_irq_rollback; | 1329 | return ret; |
1348 | } | 1330 | } |
1349 | dev_dbg(&pdev->dev, "clock source %p\n", jpeg->clk); | 1331 | dev_dbg(&pdev->dev, "clock source %p\n", jpeg->clk); |
1350 | clk_enable(jpeg->clk); | 1332 | clk_enable(jpeg->clk); |
@@ -1464,18 +1446,6 @@ clk_get_rollback: | |||
1464 | clk_disable(jpeg->clk); | 1446 | clk_disable(jpeg->clk); |
1465 | clk_put(jpeg->clk); | 1447 | clk_put(jpeg->clk); |
1466 | 1448 | ||
1467 | request_irq_rollback: | ||
1468 | free_irq(jpeg->irq, jpeg); | ||
1469 | |||
1470 | ioremap_rollback: | ||
1471 | iounmap(jpeg->regs); | ||
1472 | |||
1473 | mem_region_rollback: | ||
1474 | release_resource(jpeg->ioarea); | ||
1475 | release_mem_region(jpeg->ioarea->start, resource_size(jpeg->ioarea)); | ||
1476 | |||
1477 | jpeg_alloc_rollback: | ||
1478 | kfree(jpeg); | ||
1479 | return ret; | 1449 | return ret; |
1480 | } | 1450 | } |
1481 | 1451 | ||
@@ -1496,14 +1466,6 @@ static int s5p_jpeg_remove(struct platform_device *pdev) | |||
1496 | clk_disable(jpeg->clk); | 1466 | clk_disable(jpeg->clk); |
1497 | clk_put(jpeg->clk); | 1467 | clk_put(jpeg->clk); |
1498 | 1468 | ||
1499 | free_irq(jpeg->irq, jpeg); | ||
1500 | |||
1501 | iounmap(jpeg->regs); | ||
1502 | |||
1503 | release_resource(jpeg->ioarea); | ||
1504 | release_mem_region(jpeg->ioarea->start, resource_size(jpeg->ioarea)); | ||
1505 | kfree(jpeg); | ||
1506 | |||
1507 | return 0; | 1469 | return 0; |
1508 | } | 1470 | } |
1509 | 1471 | ||
diff --git a/drivers/media/video/s5p-jpeg/jpeg-core.h b/drivers/media/video/s5p-jpeg/jpeg-core.h index 38d7367f7a6d..9d0cd2b76f61 100644 --- a/drivers/media/video/s5p-jpeg/jpeg-core.h +++ b/drivers/media/video/s5p-jpeg/jpeg-core.h | |||
@@ -54,7 +54,6 @@ | |||
54 | * @vfd_encoder: video device node for encoder mem2mem mode | 54 | * @vfd_encoder: video device node for encoder mem2mem mode |
55 | * @vfd_decoder: video device node for decoder mem2mem mode | 55 | * @vfd_decoder: video device node for decoder mem2mem mode |
56 | * @m2m_dev: v4l2 mem2mem device data | 56 | * @m2m_dev: v4l2 mem2mem device data |
57 | * @ioarea: JPEG IP memory region | ||
58 | * @regs: JPEG IP registers mapping | 57 | * @regs: JPEG IP registers mapping |
59 | * @irq: JPEG IP irq | 58 | * @irq: JPEG IP irq |
60 | * @clk: JPEG IP clock | 59 | * @clk: JPEG IP clock |
@@ -70,7 +69,6 @@ struct s5p_jpeg { | |||
70 | struct video_device *vfd_decoder; | 69 | struct video_device *vfd_decoder; |
71 | struct v4l2_m2m_dev *m2m_dev; | 70 | struct v4l2_m2m_dev *m2m_dev; |
72 | 71 | ||
73 | struct resource *ioarea; | ||
74 | void __iomem *regs; | 72 | void __iomem *regs; |
75 | unsigned int irq; | 73 | unsigned int irq; |
76 | struct clk *clk; | 74 | struct clk *clk; |