[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <a3bcee14-f5d2-8648-a925-3dfd393e8f55@users.sourceforge.net>
Date: Sun, 24 Sep 2017 20:07:31 +0200
From: SF Markus Elfring <elfring@...rs.sourceforge.net>
To: linux-media@...r.kernel.org,
Laurent Pinchart <laurent.pinchart@...asonboard.com>,
Mauro Carvalho Chehab <mchehab@...nel.org>
Cc: LKML <linux-kernel@...r.kernel.org>,
kernel-janitors@...r.kernel.org
Subject: [PATCH 3/4] [media] omap3isp: Use common error handling code in
isp_video_open()
From: Markus Elfring <elfring@...rs.sourceforge.net>
Date: Sun, 24 Sep 2017 19:30:52 +0200
* Adjust jump targets so that a bit of exception handling can be better
reused at the end of this function.
This issue was detected by using the Coccinelle software.
* Delete a repeated check (for the variable "ret") which became unnecessary
with this refactoring.
Signed-off-by: Markus Elfring <elfring@...rs.sourceforge.net>
---
drivers/media/platform/omap3isp/ispvideo.c | 29 +++++++++++++----------------
1 file changed, 13 insertions(+), 16 deletions(-)
diff --git a/drivers/media/platform/omap3isp/ispvideo.c b/drivers/media/platform/omap3isp/ispvideo.c
index 7b9bd684337a..d4118466fc8a 100644
--- a/drivers/media/platform/omap3isp/ispvideo.c
+++ b/drivers/media/platform/omap3isp/ispvideo.c
@@ -1315,14 +1315,12 @@ static int isp_video_open(struct file *file)
/* If this is the first user, initialise the pipeline. */
if (omap3isp_get(video->isp) == NULL) {
ret = -EBUSY;
- goto done;
+ goto delete_fh;
}
ret = v4l2_pipeline_pm_use(&video->video.entity, 1);
- if (ret < 0) {
- omap3isp_put(video->isp);
- goto done;
- }
+ if (ret < 0)
+ goto put_isp;
queue = &handle->queue;
queue->type = video->type;
@@ -1335,10 +1333,8 @@ static int isp_video_open(struct file *file)
queue->dev = video->isp->dev;
ret = vb2_queue_init(&handle->queue);
- if (ret < 0) {
- omap3isp_put(video->isp);
- goto done;
- }
+ if (ret < 0)
+ goto put_isp;
memset(&handle->format, 0, sizeof(handle->format));
handle->format.type = video->type;
@@ -1346,14 +1342,15 @@ static int isp_video_open(struct file *file)
handle->video = video;
file->private_data = &handle->vfh;
+ goto exit;
-done:
- if (ret < 0) {
- v4l2_fh_del(&handle->vfh);
- v4l2_fh_exit(&handle->vfh);
- kfree(handle);
- }
-
+put_isp:
+ omap3isp_put(video->isp);
+delete_fh:
+ v4l2_fh_del(&handle->vfh);
+ v4l2_fh_exit(&handle->vfh);
+ kfree(handle);
+exit:
return ret;
}
--
2.14.1
Powered by blists - more mailing lists