diff options
author | Sachin Kamat <sachin.kamat@linaro.org> | 2012-05-14 06:33:34 -0300 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-05-20 09:05:44 -0300 |
commit | 5b58b95405aafbaf7362564dbcf6231836f1433c (patch) | |
tree | c4d30a8f68c93c0dfae21591afb472e7e14cb525 /drivers/media/video | |
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/media/video')
-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 2d7dd8ac73f..28b5225d94f 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) int ret; /* JPEG IP abstraction struct */ - jpeg = kzalloc(sizeof(struct s5p_jpeg), GFP_KERNEL); + jpeg = devm_kzalloc(&pdev->dev, sizeof(struct s5p_jpeg), GFP_KERNEL); if (!jpeg) return -ENOMEM; @@ -1300,43 +1300,25 @@ static int s5p_jpeg_probe(struct platform_device *pdev) /* memory-mapped registers */ res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!res) { - dev_err(&pdev->dev, "cannot find IO resource\n"); - ret = -ENOENT; - goto jpeg_alloc_rollback; - } - - jpeg->ioarea = request_mem_region(res->start, resource_size(res), - pdev->name); - if (!jpeg->ioarea) { - dev_err(&pdev->dev, "cannot request IO\n"); - ret = -ENXIO; - goto jpeg_alloc_rollback; - } - jpeg->regs = ioremap(res->start, resource_size(res)); - if (!jpeg->regs) { - dev_err(&pdev->dev, "cannot map IO\n"); - ret = -ENXIO; - goto mem_region_rollback; + jpeg->regs = devm_request_and_ioremap(&pdev->dev, res); + if (jpeg->regs == NULL) { + dev_err(&pdev->dev, "Failed to obtain io memory\n"); + return -ENOENT; } - dev_dbg(&pdev->dev, "registers %p (%p, %p)\n", - jpeg->regs, jpeg->ioarea, res); - /* interrupt service routine registration */ jpeg->irq = ret = platform_get_irq(pdev, 0); if (ret < 0) { dev_err(&pdev->dev, "cannot find IRQ\n"); - goto ioremap_rollback; + return ret; } - ret = request_irq(jpeg->irq, s5p_jpeg_irq, 0, - dev_name(&pdev->dev), jpeg); - + ret = devm_request_irq(&pdev->dev, jpeg->irq, s5p_jpeg_irq, 0, + dev_name(&pdev->dev), jpeg); if (ret) { dev_err(&pdev->dev, "cannot claim IRQ %d\n", jpeg->irq); - goto ioremap_rollback; + return ret; } /* clocks */ @@ -1344,7 +1326,7 @@ static int s5p_jpeg_probe(struct platform_device *pdev) if (IS_ERR(jpeg->clk)) { dev_err(&pdev->dev, "cannot get clock\n"); ret = PTR_ERR(jpeg->clk); - goto request_irq_rollback; + return ret; } dev_dbg(&pdev->dev, "clock source %p\n", jpeg->clk); clk_enable(jpeg->clk); @@ -1464,18 +1446,6 @@ clk_get_rollback: clk_disable(jpeg->clk); clk_put(jpeg->clk); -request_irq_rollback: - free_irq(jpeg->irq, jpeg); - -ioremap_rollback: - iounmap(jpeg->regs); - -mem_region_rollback: - release_resource(jpeg->ioarea); - release_mem_region(jpeg->ioarea->start, resource_size(jpeg->ioarea)); - -jpeg_alloc_rollback: - kfree(jpeg); return ret; } @@ -1496,14 +1466,6 @@ static int s5p_jpeg_remove(struct platform_device *pdev) clk_disable(jpeg->clk); clk_put(jpeg->clk); - free_irq(jpeg->irq, jpeg); - - iounmap(jpeg->regs); - - release_resource(jpeg->ioarea); - release_mem_region(jpeg->ioarea->start, resource_size(jpeg->ioarea)); - kfree(jpeg); - return 0; } diff --git a/drivers/media/video/s5p-jpeg/jpeg-core.h b/drivers/media/video/s5p-jpeg/jpeg-core.h index 38d7367f7a6..9d0cd2b76f6 100644 --- a/drivers/media/video/s5p-jpeg/jpeg-core.h +++ b/drivers/media/video/s5p-jpeg/jpeg-core.h @@ -54,7 +54,6 @@ * @vfd_encoder: video device node for encoder mem2mem mode * @vfd_decoder: video device node for decoder mem2mem mode * @m2m_dev: v4l2 mem2mem device data - * @ioarea: JPEG IP memory region * @regs: JPEG IP registers mapping * @irq: JPEG IP irq * @clk: JPEG IP clock @@ -70,7 +69,6 @@ struct s5p_jpeg { struct video_device *vfd_decoder; struct v4l2_m2m_dev *m2m_dev; - struct resource *ioarea; void __iomem *regs; unsigned int irq; struct clk *clk; |