diff mbox series

[3/6] media: ov2680: get rid of extra ifdefs

Message ID 20190404074002.18730-4-m.felsch@pengutronix.de (mailing list archive)
State New, archived
Headers show
Series Avoid v4l2_subdev_get_try_ ifdef dance | expand

Commit Message

Marco Felsch April 4, 2019, 7:39 a.m. UTC
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(-)
diff mbox series

Patch

diff --git a/drivers/media/i2c/ov2680.c b/drivers/media/i2c/ov2680.c
index b10bcfabaeeb..ea750e8304fe 100644
--- a/drivers/media/i2c/ov2680.c
+++ b/drivers/media/i2c/ov2680.c
@@ -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;
 	}