From: Kieran Bingham <kbingham@kernel.org>
To: sakari.ailus@iki.fi, linux-media@vger.kernel.org
Cc: laurent.pinchart@ideasonboard.com, niklas.soderlund@ragnatech.se,
linux-renesas-soc@vger.kernel.org,
kieran.bingham@ideasonboard.com,
Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Subject: [PATCH v4] v4l: subdev: tolerate null in media_entity_to_v4l2_subdev
Date: Wed, 7 Jun 2017 10:52:07 +0100 [thread overview]
Message-ID: <1496829127-28375-1-git-send-email-kbingham@kernel.org> (raw)
From: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Return NULL, if a null entity is parsed for it's v4l2_subdev
Signed-off-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
---
Not sure if this patch ever made it out of my mailbox:
Here's the respin with the parameter evaluated only once.
v4:
- Improve macro usage to evaluate ent only once
include/media/v4l2-subdev.h | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
index a40760174797..0f92ebd2d710 100644
--- a/include/media/v4l2-subdev.h
+++ b/include/media/v4l2-subdev.h
@@ -826,8 +826,15 @@ struct v4l2_subdev {
struct v4l2_subdev_platform_data *pdata;
};
-#define media_entity_to_v4l2_subdev(ent) \
- container_of(ent, struct v4l2_subdev, entity)
+#define media_entity_to_v4l2_subdev(ent) \
+({ \
+ typeof(ent) __me_sd_ent = (ent); \
+ \
+ __me_sd_ent ? \
+ container_of(__me_sd_ent, struct v4l2_subdev, entity) : \
+ NULL; \
+})
+
#define vdev_to_v4l2_subdev(vdev) \
((struct v4l2_subdev *)video_get_drvdata(vdev))
--
2.7.4
next reply other threads:[~2017-06-07 9:52 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-07 9:52 Kieran Bingham [this message]
2017-06-07 11:16 ` [PATCH v4] v4l: subdev: tolerate null in media_entity_to_v4l2_subdev Sakari Ailus
2017-06-08 18:00 ` Mauro Carvalho Chehab
2017-06-08 19:32 ` Sakari Ailus
2017-06-08 20:10 ` Mauro Carvalho Chehab
2017-06-09 10:03 ` Kieran Bingham
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=1496829127-28375-1-git-send-email-kbingham@kernel.org \
--to=kbingham@kernel.org \
--cc=kieran.bingham+renesas@ideasonboard.com \
--cc=kieran.bingham@ideasonboard.com \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-media@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=niklas.soderlund@ragnatech.se \
--cc=sakari.ailus@iki.fi \
/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