* [PATCH 1/3] [media] coda: Call v4l2_device_unregister() from a single location
@ 2014-10-04 19:40 Fabio Estevam
2014-10-04 19:40 ` [PATCH 2/3] [media] coda: Unregister v4l2 upon alloc_workqueue() error Fabio Estevam
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Fabio Estevam @ 2014-10-04 19:40 UTC (permalink / raw)
To: m.chehab; +Cc: p.zabel, linux-media, Fabio Estevam
From: Fabio Estevam <fabio.estevam@freescale.com>
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 <fabio.estevam@freescale.com>
---
drivers/media/platform/coda/coda-common.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/drivers/media/platform/coda/coda-common.c b/drivers/media/platform/coda/coda-common.c
index ced4760..7cd82e8 100644
--- a/drivers/media/platform/coda/coda-common.c
+++ b/drivers/media/platform/coda/coda-common.c
@@ -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)
--
1.9.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/3] [media] coda: Unregister v4l2 upon alloc_workqueue() error
2014-10-04 19:40 [PATCH 1/3] [media] coda: Call v4l2_device_unregister() from a single location Fabio Estevam
@ 2014-10-04 19:40 ` Fabio Estevam
2014-10-05 7:33 ` Philipp Zabel
2014-10-04 19:40 ` [PATCH 3/3] [media] coda: Remove devm_kzalloc() error message Fabio Estevam
2014-10-05 7:32 ` [PATCH 1/3] [media] coda: Call v4l2_device_unregister() from a single location Philipp Zabel
2 siblings, 1 reply; 6+ messages in thread
From: Fabio Estevam @ 2014-10-04 19:40 UTC (permalink / raw)
To: m.chehab; +Cc: p.zabel, linux-media, Fabio Estevam
From: Fabio Estevam <fabio.estevam@freescale.com>
If alloc_workqueue() fails, we should go to the 'err_v4l2_register' label, which
will unregister the v4l2 device.
Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
drivers/media/platform/coda/coda-common.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/media/platform/coda/coda-common.c b/drivers/media/platform/coda/coda-common.c
index 7cd82e8..951f1d4 100644
--- a/drivers/media/platform/coda/coda-common.c
+++ b/drivers/media/platform/coda/coda-common.c
@@ -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);
--
1.9.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 3/3] [media] coda: Remove devm_kzalloc() error message
2014-10-04 19:40 [PATCH 1/3] [media] coda: Call v4l2_device_unregister() from a single location Fabio Estevam
2014-10-04 19:40 ` [PATCH 2/3] [media] coda: Unregister v4l2 upon alloc_workqueue() error Fabio Estevam
@ 2014-10-04 19:40 ` Fabio Estevam
2014-10-05 7:37 ` Philipp Zabel
2014-10-05 7:32 ` [PATCH 1/3] [media] coda: Call v4l2_device_unregister() from a single location Philipp Zabel
2 siblings, 1 reply; 6+ messages in thread
From: Fabio Estevam @ 2014-10-04 19:40 UTC (permalink / raw)
To: m.chehab; +Cc: p.zabel, linux-media, Fabio Estevam
From: Fabio Estevam <fabio.estevam@freescale.com>
Core code already prints on OOM errors, so no need to keep this here.
Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
drivers/media/platform/coda/coda-common.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/drivers/media/platform/coda/coda-common.c b/drivers/media/platform/coda/coda-common.c
index 951f1d4..72b624e 100644
--- a/drivers/media/platform/coda/coda-common.c
+++ b/drivers/media/platform/coda/coda-common.c
@@ -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);
--
1.9.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/3] [media] coda: Call v4l2_device_unregister() from a single location
2014-10-04 19:40 [PATCH 1/3] [media] coda: Call v4l2_device_unregister() from a single location Fabio Estevam
2014-10-04 19:40 ` [PATCH 2/3] [media] coda: Unregister v4l2 upon alloc_workqueue() error Fabio Estevam
2014-10-04 19:40 ` [PATCH 3/3] [media] coda: Remove devm_kzalloc() error message Fabio Estevam
@ 2014-10-05 7:32 ` Philipp Zabel
2 siblings, 0 replies; 6+ messages in thread
From: Philipp Zabel @ 2014-10-05 7:32 UTC (permalink / raw)
To: Fabio Estevam; +Cc: m.chehab, p.zabel, linux-media, Fabio Estevam
On Sat, Oct 04, 2014 at 04:40:50PM -0300, Fabio Estevam wrote:
> From: Fabio Estevam <fabio.estevam@freescale.com>
>
> 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 <fabio.estevam@freescale.com>
Acked-by: Philipp Zabel <p.zabel@pengutronix.de>
regards
Philipp
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/3] [media] coda: Unregister v4l2 upon alloc_workqueue() error
2014-10-04 19:40 ` [PATCH 2/3] [media] coda: Unregister v4l2 upon alloc_workqueue() error Fabio Estevam
@ 2014-10-05 7:33 ` Philipp Zabel
0 siblings, 0 replies; 6+ messages in thread
From: Philipp Zabel @ 2014-10-05 7:33 UTC (permalink / raw)
To: Fabio Estevam; +Cc: m.chehab, p.zabel, linux-media, Fabio Estevam
On Sat, Oct 04, 2014 at 04:40:51PM -0300, Fabio Estevam wrote:
> From: Fabio Estevam <fabio.estevam@freescale.com>
>
> If alloc_workqueue() fails, we should go to the 'err_v4l2_register' label, which
> will unregister the v4l2 device.
>
> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
Acked-by: Philipp Zabel <p.zabel@pengutronix.de>
regards
Philipp
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 3/3] [media] coda: Remove devm_kzalloc() error message
2014-10-04 19:40 ` [PATCH 3/3] [media] coda: Remove devm_kzalloc() error message Fabio Estevam
@ 2014-10-05 7:37 ` Philipp Zabel
0 siblings, 0 replies; 6+ messages in thread
From: Philipp Zabel @ 2014-10-05 7:37 UTC (permalink / raw)
To: Fabio Estevam; +Cc: m.chehab, p.zabel, linux-media, Fabio Estevam
Hi Fabio,
On Sat, Oct 04, 2014 at 04:40:52PM -0300, Fabio Estevam wrote:
> From: Fabio Estevam <fabio.estevam@freescale.com>
>
> Core code already prints on OOM errors, so no need to keep this here.
>
> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
I already have sent this patch:
https://www.mail-archive.com/linux-media@vger.kernel.org/msg80093.html
regards
Philipp
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2014-10-05 7:37 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-04 19:40 [PATCH 1/3] [media] coda: Call v4l2_device_unregister() from a single location Fabio Estevam
2014-10-04 19:40 ` [PATCH 2/3] [media] coda: Unregister v4l2 upon alloc_workqueue() error Fabio Estevam
2014-10-05 7:33 ` Philipp Zabel
2014-10-04 19:40 ` [PATCH 3/3] [media] coda: Remove devm_kzalloc() error message Fabio Estevam
2014-10-05 7:37 ` Philipp Zabel
2014-10-05 7:32 ` [PATCH 1/3] [media] coda: Call v4l2_device_unregister() from a single location Philipp Zabel
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.