linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Benoit Parrot <bparrot@ti.com>
To: Hans Verkuil <hverkuil@xs4all.nl>
Cc: <linux-media@vger.kernel.org>, <devicetree@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>, Benoit Parrot <bparrot@ti.com>
Subject: [Patch 03/16] media: ti-vpe: vpe: Remove unnecessary use of container_of
Date: Fri, 27 Sep 2019 13:36:37 -0500	[thread overview]
Message-ID: <20190927183650.31345-4-bparrot@ti.com> (raw)
In-Reply-To: <20190927183650.31345-1-bparrot@ti.com>

Instead of saving a pointer to the 'fh' member of struct vpe_ctx to
later have to use container_of to retrieve the actual pointer to the
context structure, which seems to confuse static code analysis tool
anyways, just save the pointer to the actual structure and then retrieve
it directly.

Signed-off-by: Benoit Parrot <bparrot@ti.com>
---
 drivers/media/platform/ti-vpe/vpe.c | 22 +++++++---------------
 1 file changed, 7 insertions(+), 15 deletions(-)

diff --git a/drivers/media/platform/ti-vpe/vpe.c b/drivers/media/platform/ti-vpe/vpe.c
index 56f60dbea15c..0e9cb0319a92 100644
--- a/drivers/media/platform/ti-vpe/vpe.c
+++ b/drivers/media/platform/ti-vpe/vpe.c
@@ -900,14 +900,6 @@ static int set_srcdst_params(struct vpe_ctx *ctx)
 	return 0;
 }
 
-/*
- * Return the vpe_ctx structure for a given struct file
- */
-static struct vpe_ctx *file2ctx(struct file *file)
-{
-	return container_of(file->private_data, struct vpe_ctx, fh);
-}
-
 /*
  * mem2mem callbacks
  */
@@ -1527,7 +1519,7 @@ static int vpe_enum_fmt(struct file *file, void *priv,
 static int vpe_g_fmt(struct file *file, void *priv, struct v4l2_format *f)
 {
 	struct v4l2_pix_format_mplane *pix = &f->fmt.pix_mp;
-	struct vpe_ctx *ctx = file2ctx(file);
+	struct vpe_ctx *ctx = file->private_data;
 	struct vb2_queue *vq;
 	struct vpe_q_data *q_data;
 	int i;
@@ -1689,7 +1681,7 @@ static int __vpe_try_fmt(struct vpe_ctx *ctx, struct v4l2_format *f,
 
 static int vpe_try_fmt(struct file *file, void *priv, struct v4l2_format *f)
 {
-	struct vpe_ctx *ctx = file2ctx(file);
+	struct vpe_ctx *ctx = file->private_data;
 	struct vpe_fmt *fmt = find_format(f);
 
 	if (V4L2_TYPE_IS_OUTPUT(f->type))
@@ -1762,7 +1754,7 @@ static int __vpe_s_fmt(struct vpe_ctx *ctx, struct v4l2_format *f)
 static int vpe_s_fmt(struct file *file, void *priv, struct v4l2_format *f)
 {
 	int ret;
-	struct vpe_ctx *ctx = file2ctx(file);
+	struct vpe_ctx *ctx = file->private_data;
 
 	ret = vpe_try_fmt(file, priv, f);
 	if (ret)
@@ -1847,7 +1839,7 @@ static int __vpe_try_selection(struct vpe_ctx *ctx, struct v4l2_selection *s)
 static int vpe_g_selection(struct file *file, void *fh,
 		struct v4l2_selection *s)
 {
-	struct vpe_ctx *ctx = file2ctx(file);
+	struct vpe_ctx *ctx = file->private_data;
 	struct vpe_q_data *q_data;
 	bool use_c_rect = false;
 
@@ -1908,7 +1900,7 @@ static int vpe_g_selection(struct file *file, void *fh,
 static int vpe_s_selection(struct file *file, void *fh,
 		struct v4l2_selection *s)
 {
-	struct vpe_ctx *ctx = file2ctx(file);
+	struct vpe_ctx *ctx = file->private_data;
 	struct vpe_q_data *q_data;
 	struct v4l2_selection sel = *s;
 	int ret;
@@ -2275,7 +2267,7 @@ static int vpe_open(struct file *file)
 	init_adb_hdrs(ctx);
 
 	v4l2_fh_init(&ctx->fh, video_devdata(file));
-	file->private_data = &ctx->fh;
+	file->private_data = ctx;
 
 	hdl = &ctx->hdl;
 	v4l2_ctrl_handler_init(hdl, 1);
@@ -2360,7 +2352,7 @@ static int vpe_open(struct file *file)
 static int vpe_release(struct file *file)
 {
 	struct vpe_dev *dev = video_drvdata(file);
-	struct vpe_ctx *ctx = file2ctx(file);
+	struct vpe_ctx *ctx = file->private_data;
 
 	vpe_dbg(dev, "releasing instance %p\n", ctx);
 
-- 
2.17.1


  parent reply	other threads:[~2019-09-27 18:34 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-27 18:36 [Patch 00/16] media: vpe: maintenance Benoit Parrot
2019-09-27 18:36 ` [Patch 01/16] media: ti-vpe: vpe: Fix Motion Vector vpdma stride Benoit Parrot
2019-09-27 18:36 ` [Patch 02/16] media: ti-vpe: vpe: Add missing null pointer checks Benoit Parrot
2019-09-29  0:08   ` Austin Kim
2019-09-30 15:58     ` Benoit Parrot
2019-10-03 12:37       ` Austin Kim
2019-09-27 18:36 ` Benoit Parrot [this message]
2019-09-27 18:36 ` [Patch 04/16] media: ti-vpe: Add support for SEQ_BT Benoit Parrot
2019-09-27 18:36 ` [Patch 05/16] media: ti-vpe: Add support for NV21 format Benoit Parrot
2019-09-27 18:36 ` [Patch 06/16] media: ti-vpe: Set MAX height supported to 2048 pixels Benoit Parrot
2019-09-27 18:36 ` [Patch 07/16] media: ti-vpe: vpe: fix a v4l2-compliance failure causing a kernel panic Benoit Parrot
2019-09-30  8:35   ` Hans Verkuil
2019-09-30 16:04     ` Benoit Parrot
2019-09-27 18:36 ` [Patch 08/16] media: ti-vpe: vpe: fix a v4l2-compliance warning about invalid pixel format Benoit Parrot
2019-09-27 18:36 ` [Patch 09/16] media: ti-vpe: vpe: Make sure YUYV is set as default format Benoit Parrot
2019-09-27 18:36 ` [Patch 10/16] media: ti-vpe: vpe: fix a v4l2-compliance failure about invalid sizeimage Benoit Parrot
2019-09-27 18:36 ` [Patch 11/16] media: ti-vpe: vpe: fix a v4l2-compliance failure about frame sequence number Benoit Parrot
2019-09-27 18:36 ` [Patch 12/16] media: ti-vpe: vpe: ensure buffers are cleaned up properly in abort cases Benoit Parrot
2019-09-27 18:36 ` [Patch 13/16] media: ti-vpe: vpdma: Use fixed type for address in descriptor Benoit Parrot
2019-09-27 18:36 ` [Patch 14/16] media: ti-vpe: Set the DMA mask and coherent mask Benoit Parrot
2019-09-27 18:36 ` [Patch 15/16] media: ti-vpe: vpe: fix v4l2_compliance issue related to xfer_func Benoit Parrot
2019-09-27 18:36 ` [Patch 16/16] media: ti-vpe: vpe: don't rely on colorspace member for conversion Benoit Parrot
2019-09-30  9:05   ` Hans Verkuil
2019-09-30 20:24     ` Benoit Parrot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190927183650.31345-4-bparrot@ti.com \
    --to=bparrot@ti.com \
    --cc=devicetree@vger.kernel.org \
    --cc=hverkuil@xs4all.nl \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).