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;
return -EINVAL;
}
- fimc = kzalloc(sizeof(struct fimc_dev), GFP_KERNEL);
+ fimc = devm_kzalloc(&pdev->dev, sizeof(*fimc), GFP_KERNEL);
if (!fimc)
return -ENOMEM;
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;
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)) {
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;
}
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;
struct fimc_md *fmd;
int ret;
- fmd = kzalloc(sizeof(struct fimc_md), GFP_KERNEL);
+ fmd = devm_kzalloc(&pdev->dev, sizeof(*fmd), GFP_KERNEL);
if (!fmd)
return -ENOMEM;
ret = v4l2_device_register(&pdev->dev, &fmd->v4l2_dev);
if (ret < 0) {
v4l2_err(v4l2_dev, "Failed to register v4l2_device: %d\n", ret);
- goto err1;
+ return ret;
}
ret = media_device_register(&fmd->media_dev);
if (ret < 0) {
fimc_md_unregister_entities(fmd);
err2:
v4l2_device_unregister(&fmd->v4l2_dev);
-err1:
- kfree(fmd);
return ret;
}
fimc_md_unregister_entities(fmd);
media_device_unregister(&fmd->media_dev);
fimc_md_put_clocks(fmd);
- kfree(fmd);
return 0;
}