aboutsummaryrefslogtreecommitdiffstats
path: root/include/media/v4l2-subdev.h
diff options
context:
space:
mode:
authorSakari Ailus <sakari.ailus@iki.fi>2012-02-15 20:57:22 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-04-10 14:01:49 -0400
commit5e6ff7c17bf468b8bc012e49174771e5f718e72c (patch)
treeb75a7c592122a606bc4a9e74fbea1dc9b5148031 /include/media/v4l2-subdev.h
parentc5a766ceb497078459115fcbd1412917083aa4a5 (diff)
[media] v4l: Check pad number in get try pointer functions
Unify functions to get try pointers and validate the pad number accessed by the user. Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi> Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'include/media/v4l2-subdev.h')
-rw-r--r--include/media/v4l2-subdev.h30
1 files changed, 13 insertions, 17 deletions
diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
index bcaf6b80bb20..7e850355a6f0 100644
--- a/include/media/v4l2-subdev.h
+++ b/include/media/v4l2-subdev.h
@@ -565,23 +565,19 @@ struct v4l2_subdev_fh {
565 container_of(fh, struct v4l2_subdev_fh, vfh) 565 container_of(fh, struct v4l2_subdev_fh, vfh)
566 566
567#if defined(CONFIG_VIDEO_V4L2_SUBDEV_API) 567#if defined(CONFIG_VIDEO_V4L2_SUBDEV_API)
568static inline struct v4l2_mbus_framefmt * 568#define __V4L2_SUBDEV_MK_GET_TRY(rtype, fun_name, field_name) \
569v4l2_subdev_get_try_format(struct v4l2_subdev_fh *fh, unsigned int pad) 569 static inline struct rtype * \
570{ 570 v4l2_subdev_get_try_##fun_name(struct v4l2_subdev_fh *fh, \
571 return &fh->pad[pad].try_fmt; 571 unsigned int pad) \
572} 572 { \
573 573 BUG_ON(unlikely(pad >= vdev_to_v4l2_subdev( \
574static inline struct v4l2_rect * 574 fh->vfh.vdev)->entity.num_pads)); \
575v4l2_subdev_get_try_crop(struct v4l2_subdev_fh *fh, unsigned int pad) 575 return &fh->pad[pad].field_name; \
576{ 576 }
577 return &fh->pad[pad].try_crop; 577
578} 578__V4L2_SUBDEV_MK_GET_TRY(v4l2_mbus_framefmt, format, try_fmt)
579 579__V4L2_SUBDEV_MK_GET_TRY(v4l2_rect, crop, try_compose)
580static inline struct v4l2_rect * 580__V4L2_SUBDEV_MK_GET_TRY(v4l2_rect, compose, try_compose)
581v4l2_subdev_get_try_compose(struct v4l2_subdev_fh *fh, unsigned int pad)
582{
583 return &fh->pad[pad].try_compose;
584}
585#endif 581#endif
586 582
587extern const struct v4l2_file_operations v4l2_subdev_fops; 583extern const struct v4l2_file_operations v4l2_subdev_fops;