diff options
author | Sylwester Nawrocki <s.nawrocki@samsung.com> | 2012-01-30 11:37:59 -0300 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-03-08 07:40:40 -0300 |
commit | 6d91a51ae1cb597100e17a75370bb2ad9c7da6d6 (patch) | |
tree | 38c4466f473c3d600850be2b9c9d15631b3daaea /drivers/media/video/s5p-fimc/fimc-core.c | |
parent | 2def9946c3dfb7fd8ff47af7499bb3f6b5a5743f (diff) | |
download | talos-op-linux-6d91a51ae1cb597100e17a75370bb2ad9c7da6d6.tar.gz talos-op-linux-6d91a51ae1cb597100e17a75370bb2ad9c7da6d6.zip |
[media] s5p-fimc: Convert to the device managed resources
The devm_* functions are used in the platform device probe() for data
that is freed on driver removal. The managed device layer takes care
of undoing actions taken in the probe callback() and freeing resources
on driver detach. This eliminates the need for manually releasing
resources and simplifies error handling.
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/s5p-fimc/fimc-core.c')
-rw-r--r-- | drivers/media/video/s5p-fimc/fimc-core.c | 56 |
1 files changed, 12 insertions, 44 deletions
diff --git a/drivers/media/video/s5p-fimc/fimc-core.c b/drivers/media/video/s5p-fimc/fimc-core.c index a6b4580edd77..e184e650022a 100644 --- a/drivers/media/video/s5p-fimc/fimc-core.c +++ b/drivers/media/video/s5p-fimc/fimc-core.c @@ -1678,8 +1678,6 @@ static int fimc_probe(struct platform_device *pdev) struct s5p_platform_fimc *pdata; int ret = 0; - dev_dbg(&pdev->dev, "%s():\n", __func__); - drv_data = (struct samsung_fimc_driverdata *) platform_get_device_id(pdev)->driver_data; @@ -1689,7 +1687,7 @@ static int fimc_probe(struct platform_device *pdev) return -EINVAL; } - fimc = kzalloc(sizeof(struct fimc_dev), GFP_KERNEL); + fimc = devm_kzalloc(&pdev->dev, sizeof(*fimc), GFP_KERNEL); if (!fimc) return -ENOMEM; @@ -1700,51 +1698,35 @@ static int fimc_probe(struct platform_device *pdev) pdata = pdev->dev.platform_data; fimc->pdata = pdata; - init_waitqueue_head(&fimc->irq_queue); spin_lock_init(&fimc->slock); mutex_init(&fimc->lock); res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!res) { - dev_err(&pdev->dev, "failed to find the registers\n"); - ret = -ENOENT; - goto err_info; - } - - fimc->regs_res = request_mem_region(res->start, resource_size(res), - dev_name(&pdev->dev)); - if (!fimc->regs_res) { - dev_err(&pdev->dev, "failed to obtain register region\n"); - ret = -ENOENT; - goto err_info; - } - - fimc->regs = ioremap(res->start, resource_size(res)); - if (!fimc->regs) { - dev_err(&pdev->dev, "failed to map registers\n"); - ret = -ENXIO; - goto err_req_region; + fimc->regs = devm_request_and_ioremap(&pdev->dev, res); + if (fimc->regs == NULL) { + dev_err(&pdev->dev, "Failed to obtain io memory\n"); + return -ENOENT; } res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); - if (!res) { - dev_err(&pdev->dev, "failed to get IRQ resource\n"); - ret = -ENXIO; - goto err_regs_unmap; + if (res == NULL) { + dev_err(&pdev->dev, "Failed to get IRQ resource\n"); + return -ENXIO; } fimc->irq = res->start; fimc->num_clocks = MAX_FIMC_CLOCKS; ret = fimc_clk_get(fimc); if (ret) - goto err_regs_unmap; + return ret; clk_set_rate(fimc->clock[CLK_BUS], drv_data->lclk_frequency); clk_enable(fimc->clock[CLK_BUS]); platform_set_drvdata(pdev, fimc); - ret = request_irq(fimc->irq, fimc_irq_handler, 0, pdev->name, fimc); + ret = devm_request_irq(&pdev->dev, fimc->irq, fimc_irq_handler, + 0, pdev->name, fimc); if (ret) { dev_err(&pdev->dev, "failed to install irq (%d)\n", ret); goto err_clk; @@ -1753,7 +1735,7 @@ static int fimc_probe(struct platform_device *pdev) pm_runtime_enable(&pdev->dev); ret = pm_runtime_get_sync(&pdev->dev); if (ret < 0) - goto err_irq; + goto err_clk; /* Initialize contiguous memory allocator */ fimc->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev); if (IS_ERR(fimc->alloc_ctx)) { @@ -1768,17 +1750,8 @@ static int fimc_probe(struct platform_device *pdev) err_pm: pm_runtime_put(&pdev->dev); -err_irq: - free_irq(fimc->irq, fimc); err_clk: fimc_clk_put(fimc); -err_regs_unmap: - iounmap(fimc->regs); -err_req_region: - release_resource(fimc->regs_res); - kfree(fimc->regs_res); -err_info: - kfree(fimc); return ret; } @@ -1865,11 +1838,6 @@ static int __devexit fimc_remove(struct platform_device *pdev) clk_disable(fimc->clock[CLK_BUS]); fimc_clk_put(fimc); - free_irq(fimc->irq, fimc); - iounmap(fimc->regs); - release_resource(fimc->regs_res); - kfree(fimc->regs_res); - kfree(fimc); dev_info(&pdev->dev, "driver unloaded\n"); return 0; |