diff mbox

[20/24] V4L2: add a subdev pointer to struct v4l2_subdev_fh

Message ID 1366320945-21591-21-git-send-email-g.liakhovetski@gmx.de (mailing list archive)
State New, archived
Headers show

Commit Message

Guennadi Liakhovetski April 18, 2013, 9:35 p.m. UTC
This is useful for cases, when there's no video-device associated with a
V4L2 file-handle, e.g. in case of a dummy file-handle.

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
---
 drivers/media/v4l2-core/v4l2-subdev.c |    1 +
 include/media/v4l2-subdev.h           |    4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)
diff mbox

Patch

diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c
index 996c248..ec9f0d8 100644
--- a/drivers/media/v4l2-core/v4l2-subdev.c
+++ b/drivers/media/v4l2-core/v4l2-subdev.c
@@ -34,6 +34,7 @@ 
 
 static int subdev_fh_init(struct v4l2_subdev_fh *fh, struct v4l2_subdev *sd)
 {
+	fh->subdev = sd;
 #if defined(CONFIG_VIDEO_V4L2_SUBDEV_API)
 	fh->pad = kzalloc(sizeof(*fh->pad) * sd->entity.num_pads, GFP_KERNEL);
 	if (fh->pad == NULL)
diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
index 4424a7c..0581781 100644
--- a/include/media/v4l2-subdev.h
+++ b/include/media/v4l2-subdev.h
@@ -626,6 +626,7 @@  struct v4l2_subdev_try_buf {
 
 struct v4l2_subdev_fh {
 	struct v4l2_fh vfh;
+	struct v4l2_subdev *subdev;
 #if defined(CONFIG_VIDEO_V4L2_SUBDEV_API)
 	struct v4l2_subdev_try_buf *pad;
 #endif
@@ -640,8 +641,7 @@  struct v4l2_subdev_fh {
 	v4l2_subdev_get_try_##fun_name(struct v4l2_subdev_fh *fh,	\
 				       unsigned int pad)		\
 	{								\
-		BUG_ON(pad >= vdev_to_v4l2_subdev(			\
-					fh->vfh.vdev)->entity.num_pads); \
+		BUG_ON(pad >= fh->subdev->entity.num_pads);		\
 		return &fh->pad[pad].field_name;			\
 	}