[media] soc_camera: Use devm_kzalloc function
devm_kzalloc() has been used to simplify error handling. While at it, the soc_camera_device_register function has been moved to save a few lines of code and a variable. Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org> [g.liakhovetski@gmx.de: remove a superfluous empty line] Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
This commit is contained in:
parent
ec0341b3b7
commit
0224936935
1 changed files with 2 additions and 14 deletions
|
@ -1529,12 +1529,11 @@ static int __devinit soc_camera_pdrv_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct soc_camera_link *icl = pdev->dev.platform_data;
|
struct soc_camera_link *icl = pdev->dev.platform_data;
|
||||||
struct soc_camera_device *icd;
|
struct soc_camera_device *icd;
|
||||||
int ret;
|
|
||||||
|
|
||||||
if (!icl)
|
if (!icl)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
icd = kzalloc(sizeof(*icd), GFP_KERNEL);
|
icd = devm_kzalloc(&pdev->dev, sizeof(*icd), GFP_KERNEL);
|
||||||
if (!icd)
|
if (!icd)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
|
@ -1543,19 +1542,10 @@ static int __devinit soc_camera_pdrv_probe(struct platform_device *pdev)
|
||||||
icd->pdev = &pdev->dev;
|
icd->pdev = &pdev->dev;
|
||||||
platform_set_drvdata(pdev, icd);
|
platform_set_drvdata(pdev, icd);
|
||||||
|
|
||||||
ret = soc_camera_device_register(icd);
|
|
||||||
if (ret < 0)
|
|
||||||
goto escdevreg;
|
|
||||||
|
|
||||||
icd->user_width = DEFAULT_WIDTH;
|
icd->user_width = DEFAULT_WIDTH;
|
||||||
icd->user_height = DEFAULT_HEIGHT;
|
icd->user_height = DEFAULT_HEIGHT;
|
||||||
|
|
||||||
return 0;
|
return soc_camera_device_register(icd);
|
||||||
|
|
||||||
escdevreg:
|
|
||||||
kfree(icd);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1572,8 +1562,6 @@ static int __devexit soc_camera_pdrv_remove(struct platform_device *pdev)
|
||||||
|
|
||||||
list_del(&icd->list);
|
list_del(&icd->list);
|
||||||
|
|
||||||
kfree(icd);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue