We can drop the ifdef dance since the v4l2_subdev_get_try_format return the correct value in both cases with or without CONFIG_VIDEO_V4L2_SUBDEV_API is enabled. The patch is based on Lubomir's series [1]. [1] https://patchwork.kernel.org/cover/10703017/ Signed-off-by: Marco Felsch <m.felsch@xxxxxxxxxxxxxx> --- drivers/media/i2c/ov5695.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/drivers/media/i2c/ov5695.c b/drivers/media/i2c/ov5695.c index 5d107c53364d..83fea416c75e 100644 --- a/drivers/media/i2c/ov5695.c +++ b/drivers/media/i2c/ov5695.c @@ -810,6 +810,7 @@ static int ov5695_set_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_format *fmt) { struct ov5695 *ov5695 = to_ov5695(sd); + struct v4l2_mbus_framefmt *try_fmt; const struct ov5695_mode *mode; s64 h_blank, vblank_def; @@ -821,12 +822,12 @@ static int ov5695_set_fmt(struct v4l2_subdev *sd, fmt->format.height = mode->height; fmt->format.field = V4L2_FIELD_NONE; if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) { -#ifdef CONFIG_VIDEO_V4L2_SUBDEV_API - *v4l2_subdev_get_try_format(sd, cfg, fmt->pad) = fmt->format; -#else - mutex_unlock(&ov5695->mutex); - return -ENOTTY; -#endif + try_fmt = v4l2_subdev_get_try_format(sd, cfg, fmt->pad); + if (IS_ERR(try_fmt)) { + mutex_unlock(&ov5695->mutex); + return PTR_ERR(try_fmt); + } + *try_fmt = fmt->format; } else { ov5695->cur_mode = mode; h_blank = mode->hts_def - mode->width; @@ -848,16 +849,17 @@ static int ov5695_get_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_format *fmt) { struct ov5695 *ov5695 = to_ov5695(sd); + struct v4l2_mbus_framefmt *try_fmt; const struct ov5695_mode *mode = ov5695->cur_mode; mutex_lock(&ov5695->mutex); if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) { -#ifdef CONFIG_VIDEO_V4L2_SUBDEV_API - fmt->format = *v4l2_subdev_get_try_format(sd, cfg, fmt->pad); -#else - mutex_unlock(&ov5695->mutex); - return -ENOTTY; -#endif + try_fmt = v4l2_subdev_get_try_format(sd, cfg, fmt->pad); + if (IS_ERR(try_fmt)) { + mutex_unlock(&ov5695->mutex); + return PTR_ERR(try_fmt); + } + fmt->format = *try_fmt; } else { fmt->format.width = mode->width; fmt->format.height = mode->height; -- 2.20.1