Commit 4bae5db2 authored by Corentin Labbe's avatar Corentin Labbe Committed by Mauro Carvalho Chehab

media: zoran: use devm for videocodec_master alloc

Let's use devm allocations for videocodec, this simplify code.
Signed-off-by: default avatarCorentin Labbe <clabbe@baylibre.com>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent af71064b
...@@ -996,18 +996,10 @@ static void zoran_remove(struct pci_dev *pdev) ...@@ -996,18 +996,10 @@ static void zoran_remove(struct pci_dev *pdev)
goto exit_free; goto exit_free;
/* unregister videocodec bus */ /* unregister videocodec bus */
if (zr->codec) { if (zr->codec)
struct videocodec_master *master = zr->codec->master_data;
videocodec_detach(zr->codec); videocodec_detach(zr->codec);
kfree(master); if (zr->vfe)
}
if (zr->vfe) {
struct videocodec_master *master = zr->vfe->master_data;
videocodec_detach(zr->vfe); videocodec_detach(zr->vfe);
kfree(master);
}
/* unregister i2c bus */ /* unregister i2c bus */
zoran_unregister_i2c(zr); zoran_unregister_i2c(zr);
...@@ -1036,7 +1028,7 @@ static struct videocodec_master *zoran_setup_videocodec(struct zoran *zr, ...@@ -1036,7 +1028,7 @@ static struct videocodec_master *zoran_setup_videocodec(struct zoran *zr,
{ {
struct videocodec_master *m = NULL; struct videocodec_master *m = NULL;
m = kmalloc(sizeof(*m), GFP_KERNEL); m = devm_kmalloc(&zr->pci_dev->dev, sizeof(*m), GFP_KERNEL);
if (!m) if (!m)
return m; return m;
...@@ -1245,7 +1237,7 @@ static int zoran_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -1245,7 +1237,7 @@ static int zoran_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
zr->codec = videocodec_attach(master_codec); zr->codec = videocodec_attach(master_codec);
if (!zr->codec) { if (!zr->codec) {
pci_err(pdev, "%s - no codec found\n", __func__); pci_err(pdev, "%s - no codec found\n", __func__);
goto zr_free_codec; goto zr_unreg_i2c;
} }
if (zr->codec->type != zr->card.video_codec) { if (zr->codec->type != zr->card.video_codec) {
pci_err(pdev, "%s - wrong codec\n", __func__); pci_err(pdev, "%s - wrong codec\n", __func__);
...@@ -1259,7 +1251,7 @@ static int zoran_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -1259,7 +1251,7 @@ static int zoran_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
zr->vfe = videocodec_attach(master_vfe); zr->vfe = videocodec_attach(master_vfe);
if (!zr->vfe) { if (!zr->vfe) {
pci_err(pdev, "%s - no VFE found\n", __func__); pci_err(pdev, "%s - no VFE found\n", __func__);
goto zr_free_vfe; goto zr_detach_codec;
} }
if (zr->vfe->type != zr->card.video_vfe) { if (zr->vfe->type != zr->card.video_vfe) {
pci_err(pdev, "%s = wrong VFE\n", __func__); pci_err(pdev, "%s = wrong VFE\n", __func__);
...@@ -1280,12 +1272,8 @@ static int zoran_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -1280,12 +1272,8 @@ static int zoran_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
zr_detach_vfe: zr_detach_vfe:
videocodec_detach(zr->vfe); videocodec_detach(zr->vfe);
zr_free_vfe:
kfree(master_vfe);
zr_detach_codec: zr_detach_codec:
videocodec_detach(zr->codec); videocodec_detach(zr->codec);
zr_free_codec:
kfree(master_codec);
zr_unreg_i2c: zr_unreg_i2c:
zoran_unregister_i2c(zr); zoran_unregister_i2c(zr);
zr_free_irq: zr_free_irq:
......
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