[media] media: sh_mobile_csi2: use managed memory and resource allocations
Use managed allocations to simplify error handling and clean up paths. Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
This commit is contained in:
parent
cea4c9e46c
commit
f8cabc3628
1 changed files with 4 additions and 19 deletions
|
@ -318,23 +318,16 @@ static __devinit int sh_csi2_probe(struct platform_device *pdev)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
priv = kzalloc(sizeof(struct sh_csi2), GFP_KERNEL);
|
priv = devm_kzalloc(&pdev->dev, sizeof(struct sh_csi2), GFP_KERNEL);
|
||||||
if (!priv)
|
if (!priv)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
priv->irq = irq;
|
priv->irq = irq;
|
||||||
|
|
||||||
if (!request_mem_region(res->start, resource_size(res), pdev->name)) {
|
priv->base = devm_request_and_ioremap(&pdev->dev, res);
|
||||||
dev_err(&pdev->dev, "CSI2 register region already claimed\n");
|
|
||||||
ret = -EBUSY;
|
|
||||||
goto ereqreg;
|
|
||||||
}
|
|
||||||
|
|
||||||
priv->base = ioremap(res->start, resource_size(res));
|
|
||||||
if (!priv->base) {
|
if (!priv->base) {
|
||||||
ret = -ENXIO;
|
|
||||||
dev_err(&pdev->dev, "Unable to ioremap CSI2 registers.\n");
|
dev_err(&pdev->dev, "Unable to ioremap CSI2 registers.\n");
|
||||||
goto eremap;
|
return -ENXIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
priv->pdev = pdev;
|
priv->pdev = pdev;
|
||||||
|
@ -357,11 +350,7 @@ static __devinit int sh_csi2_probe(struct platform_device *pdev)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
esdreg:
|
esdreg:
|
||||||
iounmap(priv->base);
|
platform_set_drvdata(pdev, NULL);
|
||||||
eremap:
|
|
||||||
release_mem_region(res->start, resource_size(res));
|
|
||||||
ereqreg:
|
|
||||||
kfree(priv);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -369,14 +358,10 @@ ereqreg:
|
||||||
static __devexit int sh_csi2_remove(struct platform_device *pdev)
|
static __devexit int sh_csi2_remove(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct sh_csi2 *priv = platform_get_drvdata(pdev);
|
struct sh_csi2 *priv = platform_get_drvdata(pdev);
|
||||||
struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
|
||||||
|
|
||||||
v4l2_device_unregister_subdev(&priv->subdev);
|
v4l2_device_unregister_subdev(&priv->subdev);
|
||||||
pm_runtime_disable(&pdev->dev);
|
pm_runtime_disable(&pdev->dev);
|
||||||
iounmap(priv->base);
|
|
||||||
release_mem_region(res->start, resource_size(res));
|
|
||||||
platform_set_drvdata(pdev, NULL);
|
platform_set_drvdata(pdev, NULL);
|
||||||
kfree(priv);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue