[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>
This commit is contained in:
Sachin Kamat 2012-05-14 06:33:34 -03:00 committed by Mauro Carvalho Chehab
parent 32fced05ad
commit 5b58b95405
2 changed files with 10 additions and 50 deletions

View File

@ -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 = devm_request_and_ioremap(&pdev->dev, res);
if (jpeg->regs == NULL) {
dev_err(&pdev->dev, "Failed to obtain io memory\n");
return -ENOENT;
}
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;
}
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;
}

View File

@ -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;