Commit 92afdc1b authored by Kiran Padwal's avatar Kiran Padwal Committed by Mauro Carvalho Chehab

[media] staging: dt3155v4l: Switch to using managed resource with devm_

This patch uses managed resource APIs to allocate memory
in order to simplify the driver unload or failure cases
Signed-off-by: default avatarKiran Padwal <kiran.padwal@smartplayin.com>
Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent 50d8e46f
...@@ -901,14 +901,13 @@ dt3155_probe(struct pci_dev *pdev, const struct pci_device_id *id) ...@@ -901,14 +901,13 @@ dt3155_probe(struct pci_dev *pdev, const struct pci_device_id *id)
err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
if (err) if (err)
return -ENODEV; return -ENODEV;
pd = kzalloc(sizeof(*pd), GFP_KERNEL); pd = devm_kzalloc(&pdev->dev, sizeof(*pd), GFP_KERNEL);
if (!pd) if (!pd)
return -ENOMEM; return -ENOMEM;
pd->vdev = video_device_alloc(); pd->vdev = video_device_alloc();
if (!pd->vdev) { if (!pd->vdev)
err = -ENOMEM; return -ENOMEM;
goto err_video_device_alloc;
}
*pd->vdev = dt3155_vdev; *pd->vdev = dt3155_vdev;
pci_set_drvdata(pdev, pd); /* for use in dt3155_remove() */ pci_set_drvdata(pdev, pd); /* for use in dt3155_remove() */
video_set_drvdata(pd->vdev, pd); /* for use in video_fops */ video_set_drvdata(pd->vdev, pd); /* for use in video_fops */
...@@ -951,8 +950,7 @@ dt3155_probe(struct pci_dev *pdev, const struct pci_device_id *id) ...@@ -951,8 +950,7 @@ dt3155_probe(struct pci_dev *pdev, const struct pci_device_id *id)
pci_disable_device(pdev); pci_disable_device(pdev);
err_enable_dev: err_enable_dev:
video_device_release(pd->vdev); video_device_release(pd->vdev);
err_video_device_alloc:
kfree(pd);
return err; return err;
} }
...@@ -970,7 +968,6 @@ dt3155_remove(struct pci_dev *pdev) ...@@ -970,7 +968,6 @@ dt3155_remove(struct pci_dev *pdev)
* video_device_release() is invoked automatically * video_device_release() is invoked automatically
* see: struct video_device dt3155_vdev * see: struct video_device dt3155_vdev
*/ */
kfree(pd);
} }
static const struct pci_device_id pci_ids[] = { static const struct pci_device_id pci_ids[] = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment