Skip to content

Commit ab9bb73

Browse files
committed
media: v4l2-subdev: get rid of __V4L2_SUBDEV_MK_GET_TRY() macro
X-Virus-Scanned: Debian amavisd-new at dev.s-opensource.com media: v4l2-subdev: get rid of __V4L2_SUBDEV_MK_GET_TRY() macro The __V4L2_SUBDEV_MK_GET_TRY() macro is used to define 3 functions that have the same arguments. The code of those functions is simple enough to just declare them, de-obfuscating the code. While here, replace BUG_ON() by WARN_ON() as there's no reason why to panic the Kernel if this fails. Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
1 parent 39ad07b commit ab9bb73

1 file changed

Lines changed: 28 additions & 12 deletions

File tree

‎include/media/v4l2-subdev.h‎

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -890,19 +890,35 @@ struct v4l2_subdev_fh {
890890
container_of(fh, struct v4l2_subdev_fh, vfh)
891891

892892
#if defined(CONFIG_VIDEO_V4L2_SUBDEV_API)
893-
#define __V4L2_SUBDEV_MK_GET_TRY(rtype, fun_name, field_name) \
894-
static inline struct rtype * \
895-
fun_name(struct v4l2_subdev *sd, \
896-
struct v4l2_subdev_pad_config *cfg, \
897-
unsigned int pad) \
898-
{ \
899-
BUG_ON(pad >= sd->entity.num_pads); \
900-
return &cfg[pad].field_name; \
901-
}
893+
static inline struct v4l2_mbus_framefmt
894+
*v4l2_subdev_get_try_format(struct v4l2_subdev *sd,
895+
struct v4l2_subdev_pad_config *cfg,
896+
unsigned int pad)
897+
{
898+
if (WARN_ON(pad >= sd->entity.num_pads))
899+
pad = 0;
900+
return &cfg[pad].try_fmt;
901+
}
902+
903+
static inline struct v4l2_rect
904+
*v4l2_subdev_get_try_crop(struct v4l2_subdev *sd,
905+
struct v4l2_subdev_pad_config *cfg,
906+
unsigned int pad)
907+
{
908+
if (WARN_ON(pad >= sd->entity.num_pads))
909+
pad = 0;
910+
return &cfg[pad].try_crop;
911+
}
902912

903-
__V4L2_SUBDEV_MK_GET_TRY(v4l2_mbus_framefmt, v4l2_subdev_get_try_format, try_fmt)
904-
__V4L2_SUBDEV_MK_GET_TRY(v4l2_rect, v4l2_subdev_get_try_crop, try_crop)
905-
__V4L2_SUBDEV_MK_GET_TRY(v4l2_rect, v4l2_subdev_get_try_compose, try_compose)
913+
static inline struct v4l2_rect
914+
*v4l2_subdev_get_try_compose(struct v4l2_subdev *sd,
915+
struct v4l2_subdev_pad_config *cfg,
916+
unsigned int pad)
917+
{
918+
if (WARN_ON(pad >= sd->entity.num_pads))
919+
pad = 0;
920+
return &cfg[pad].try_compose;
921+
}
906922
#endif
907923

908924
extern const struct v4l2_file_operations v4l2_subdev_fops;

0 commit comments

Comments
 (0)