@@ -672,11 +672,11 @@ static int ov2680_get_fmt(struct v4l2_subdev *sd,
mutex_lock(&sensor->lock);
if (format->which == V4L2_SUBDEV_FORMAT_TRY) {
-#ifdef CONFIG_VIDEO_V4L2_SUBDEV_API
fmt = v4l2_subdev_get_try_format(&sensor->sd, cfg, format->pad);
-#else
- ret = -ENOTTY;
-#endif
+ if (IS_ERR(fmt)) {
+ ret = PTR_ERR(fmt);
+ goto unlock;
+ }
} else {
fmt = &sensor->fmt;
}
@@ -684,6 +684,7 @@ static int ov2680_get_fmt(struct v4l2_subdev *sd,
if (fmt)
format->format = *fmt;
+unlock:
mutex_unlock(&sensor->lock);
return ret;
@@ -695,9 +696,7 @@ static int ov2680_set_fmt(struct v4l2_subdev *sd,
{
struct ov2680_dev *sensor = to_ov2680_dev(sd);
struct v4l2_mbus_framefmt *fmt = &format->format;
-#ifdef CONFIG_VIDEO_V4L2_SUBDEV_API
struct v4l2_mbus_framefmt *try_fmt;
-#endif
const struct ov2680_mode_info *mode;
int ret = 0;
@@ -720,13 +719,12 @@ static int ov2680_set_fmt(struct v4l2_subdev *sd,
}
if (format->which == V4L2_SUBDEV_FORMAT_TRY) {
-#ifdef CONFIG_VIDEO_V4L2_SUBDEV_API
try_fmt = v4l2_subdev_get_try_format(sd, cfg, 0);
+ if (IS_ERR(try_fmt)) {
+ ret = PTR_ERR(try_fmt);
+ goto unlock;
+ }
format->format = *try_fmt;
-#else
- ret = -ENOTTY;
-#endif
-
goto unlock;
}
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@pengutronix.de> --- drivers/media/i2c/ov2680.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-)