summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarco Felsch <m.felsch@pengutronix.de>2019-04-03 11:16:05 +0200
committerMarco Felsch <m.felsch@pengutronix.de>2019-04-03 13:35:42 +0200
commit080c3e533f38a2e765a7287ec9d7af5cf579a5d0 (patch)
treeb0ed87d4ea623d304ffd0b087bc3880a34e3f58b
parent4ee8fb25de956c006c2cd217f17f073a917bd7bf (diff)
downloadlinux-0-day-080c3e533f38a2e765a7287ec9d7af5cf579a5d0.tar.gz
linux-0-day-080c3e533f38a2e765a7287ec9d7af5cf579a5d0.tar.xz
media: ov5695: get rid of extra ifdefs
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/ Cc: Lubomir Rintel <lkundrak@v3.sk> Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
-rw-r--r--drivers/media/i2c/ov5695.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/drivers/media/i2c/ov5695.c b/drivers/media/i2c/ov5695.c
index 5d107c53364d6..83fea416c75e1 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;