coda: Call v4l2_device_unregister() from a single location
PATCH 1/3 coda: Call v4l2_device_unregister() from a single location
From: Fabio Estevam <[email protected]>
Instead of calling v4l2_device_unregister() in multiple locations within the error paths, let's call it from a single location to make the error handling simpler.
--- drivers/media/platform/coda/coda-common.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
drivers/media/platform/coda/coda-common.c +8 -6
@@ -1926,8 +1926,8 @@ static int coda_probe(struct platform_device *pdev) }else if (pdev_id) { dev->devtype = &coda_devdata[pdev_id->driver_data]; }else { -v4l2_device_unregister (&dev->v4l2_dev); -return -EINVAL ; + ret = -EINVAL ; + goto err_v4l2_register; } dev->debugfs_root =debugfs_create_dir ("coda" ,NULL );
@@ -1941,8 +1941,7 @@ static int coda_probe(struct platform_device *pdev) dev->debugfs_root);if (ret <0 ) {dev_err (&pdev->dev,"failed to allocate work buffer\n" ); -v4l2_device_unregister (&dev->v4l2_dev); -return ret; + goto err_v4l2_register; } }
@@ -1952,8 +1951,7 @@ static int coda_probe(struct platform_device *pdev) dev->debugfs_root);if (ret <0 ) {dev_err (&pdev->dev,"failed to allocate temp buffer\n" ); -v4l2_device_unregister (&dev->v4l2_dev); -return ret; + goto err_v4l2_register; } }
@@ -1988,6 +1986,10 @@ static int coda_probe(struct platform_device *pdev)pm_runtime_enable (&pdev->dev);return coda_firmware_request (dev); + +err_v4l2_register: +v4l2_device_unregister (&dev->v4l2_dev); +return ret; }static int coda_remove (struct platform_device *pdev)
Signature · 1 line
1.9.1
PATCH 2/3 coda: Unregister v4l2 upon alloc_workqueue() error
From: Fabio Estevam <[email protected]>
If alloc_workqueue() fails, we should go to the 'err_v4l2_register' label, which will unregister the v4l2 device.
--- drivers/media/platform/coda/coda-common.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/media/platform/coda/coda-common.c +2 -1
@@ -1971,7 +1971,8 @@ static int coda_probe(struct platform_device *pdev) dev->workqueue =alloc_workqueue ("coda" ,WQ_UNBOUND |WQ_MEM_RECLAIM ,1 );if (!dev->workqueue) {dev_err (&pdev->dev,"unable to alloc workqueue\n" ); -return -ENOMEM ; + ret = -ENOMEM ; + goto err_v4l2_register; }platform_set_drvdata (pdev, dev);
Signature · 1 line
1.9.1
Re: [PATCH 2/3] [media] coda: Unregister v4l2 upon alloc_workqueue() error
Quoted 6 lines · Fabio Estevam
From: Fabio Estevam <[email protected]>
If
alloc_workqueue()fails, we should go to the 'err_v4l2_register' label, which will unregister the v4l2 device.Signed-off-by Fabio Estevam <[email protected]>
regards
Philipp
PATCH 3/3 coda: Remove devm_kzalloc() error message
In reply to Fabio EstevamFrom: Fabio Estevam <[email protected]>
Core code already prints on OOM errors, so no need to keep this here.
--- drivers/media/platform/coda/coda-common.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/media/platform/coda/coda-common.c +1 -4
@@ -1846,11 +1846,8 @@ static int coda_probe(struct platform_device *pdev)int ret, irq; dev =devm_kzalloc (&pdev->dev,sizeof (*dev),GFP_KERNEL ); -if (!dev) { -dev_err (&pdev->dev,"Not enough memory for %s\n" , -CODA_NAME ); +if (!dev)return -ENOMEM ; - }spin_lock_init (&dev->irqlock);INIT_LIST_HEAD (&dev->instances);
Signature · 1 line
1.9.1
Re: [PATCH 3/3] [media] coda: Remove devm_kzalloc() error message
Hi Fabio,
Quoted 5 lines · Fabio Estevam
From: Fabio Estevam <[email protected]>
Core code already prints on OOM errors, so no need to keep this here.
Signed-off-by Fabio Estevam <[email protected]>
I already have sent this patch:
https://www.mail-archive.com/[email protected]/msg80093.html
regards
Philipp
Quoted 7 lines · Fabio Estevam
From: Fabio Estevam <[email protected]>
Instead of calling
v4l2_device_unregister()in multiple locations within the error paths, let's call it from a single location to make the error handling simpler.Signed-off-by Fabio Estevam <[email protected]>
regards
Philipp