提交 371376d2 编写于 作者: L Lad, Prabhakar 提交者: Mauro Carvalho Chehab

[media] media: davinci: vpbe_venc: convert to devm_* api

Replace existing resource handling in the driver with managed
device resource, this ensures more consistent error values and
simplifies error paths.
Signed-off-by: NLad, Prabhakar <prabhakar.csengg@gmail.com>
Signed-off-by: NHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: NMauro Carvalho Chehab <m.chehab@samsung.com>
上级 4b8a531e
...@@ -639,105 +639,46 @@ static int venc_probe(struct platform_device *pdev) ...@@ -639,105 +639,46 @@ static int venc_probe(struct platform_device *pdev)
const struct platform_device_id *pdev_id; const struct platform_device_id *pdev_id;
struct venc_state *venc; struct venc_state *venc;
struct resource *res; struct resource *res;
int ret;
venc = kzalloc(sizeof(struct venc_state), GFP_KERNEL); if (!pdev->dev.platform_data) {
dev_err(&pdev->dev, "No platform data for VENC sub device");
return -EINVAL;
}
pdev_id = platform_get_device_id(pdev);
if (!pdev_id)
return -EINVAL;
venc = devm_kzalloc(&pdev->dev, sizeof(struct venc_state), GFP_KERNEL);
if (venc == NULL) if (venc == NULL)
return -ENOMEM; return -ENOMEM;
pdev_id = platform_get_device_id(pdev);
if (!pdev_id) {
ret = -EINVAL;
goto free_mem;
}
venc->venc_type = pdev_id->driver_data; venc->venc_type = pdev_id->driver_data;
venc->pdev = &pdev->dev; venc->pdev = &pdev->dev;
venc->pdata = pdev->dev.platform_data; venc->pdata = pdev->dev.platform_data;
if (NULL == venc->pdata) {
dev_err(venc->pdev, "Unable to get platform data for"
" VENC sub device");
ret = -ENOENT;
goto free_mem;
}
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) {
dev_err(venc->pdev,
"Unable to get VENC register address map\n");
ret = -ENODEV;
goto free_mem;
}
if (!request_mem_region(res->start, resource_size(res), "venc")) { venc->venc_base = devm_ioremap_resource(&pdev->dev, res);
dev_err(venc->pdev, "Unable to reserve VENC MMIO region\n"); if (IS_ERR(venc->venc_base))
ret = -ENODEV; return PTR_ERR(venc->venc_base);
goto free_mem;
}
venc->venc_base = ioremap_nocache(res->start, resource_size(res));
if (!venc->venc_base) {
dev_err(venc->pdev, "Unable to map VENC IO space\n");
ret = -ENODEV;
goto release_venc_mem_region;
}
if (venc->venc_type != VPBE_VERSION_1) { if (venc->venc_type != VPBE_VERSION_1) {
res = platform_get_resource(pdev, IORESOURCE_MEM, 1); res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
if (!res) {
dev_err(venc->pdev, venc->vdaccfg_reg = devm_ioremap_resource(&pdev->dev, res);
"Unable to get VDAC_CONFIG address map\n"); if (IS_ERR(venc->vdaccfg_reg))
ret = -ENODEV; return PTR_ERR(venc->vdaccfg_reg);
goto unmap_venc_io;
}
if (!request_mem_region(res->start,
resource_size(res), "venc")) {
dev_err(venc->pdev,
"Unable to reserve VDAC_CONFIG MMIO region\n");
ret = -ENODEV;
goto unmap_venc_io;
}
venc->vdaccfg_reg = ioremap_nocache(res->start,
resource_size(res));
if (!venc->vdaccfg_reg) {
dev_err(venc->pdev,
"Unable to map VDAC_CONFIG IO space\n");
ret = -ENODEV;
goto release_vdaccfg_mem_region;
}
} }
spin_lock_init(&venc->lock); spin_lock_init(&venc->lock);
platform_set_drvdata(pdev, venc); platform_set_drvdata(pdev, venc);
dev_notice(venc->pdev, "VENC sub device probe success\n"); dev_notice(venc->pdev, "VENC sub device probe success\n");
return 0;
release_vdaccfg_mem_region: return 0;
release_mem_region(res->start, resource_size(res));
unmap_venc_io:
iounmap(venc->venc_base);
release_venc_mem_region:
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
release_mem_region(res->start, resource_size(res));
free_mem:
kfree(venc);
return ret;
} }
static int venc_remove(struct platform_device *pdev) static int venc_remove(struct platform_device *pdev)
{ {
struct venc_state *venc = platform_get_drvdata(pdev);
struct resource *res;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
iounmap((void *)venc->venc_base);
release_mem_region(res->start, resource_size(res));
if (venc->venc_type != VPBE_VERSION_1) {
res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
iounmap((void *)venc->vdaccfg_reg);
release_mem_region(res->start, resource_size(res));
}
kfree(venc);
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册