media: media/i2c: don't return ENOTTY if SUBDEV_API is not set
authorHans Verkuil <hverkuil@xs4all.nl>
Wed, 17 Jul 2019 09:24:13 +0000 (05:24 -0400)
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>
Tue, 23 Jul 2019 15:47:09 +0000 (11:47 -0400)
If CONFIG_VIDEO_V4L2_SUBDEV_API is not set, then it is still possible
to call set_fmt for V4L2_SUBDEV_FORMAT_TRY, the result is just not
stored. So return 0 instead of -ENOTTY.

Calling get_fmt with V4L2_SUBDEV_FORMAT_TRY should return -EINVAL
instead of -ENOTTY, after all the get_fmt functionality is still
present, just not supported for TRY.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Acked-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
drivers/media/i2c/mt9m111.c
drivers/media/i2c/ov2640.c
drivers/media/i2c/ov2659.c
drivers/media/i2c/ov2680.c
drivers/media/i2c/ov5695.c
drivers/media/i2c/ov7740.c

index 12cb012d91f71160c911d5dcc216dcfb8c3b3317..3e01d1b86a252ddec63bb8ca36cee0c86b7782a5 100644 (file)
@@ -533,7 +533,7 @@ static int mt9m111_get_fmt(struct v4l2_subdev *sd,
                format->format = *mf;
                return 0;
 #else
-               return -ENOTTY;
+               return -EINVAL;
 #endif
        }
 
index ecd167d7c4d265234292f395f4138f2c9e037a6d..8fd17661dd78c917560b9c043cbe41542d82b703 100644 (file)
@@ -929,7 +929,7 @@ static int ov2640_get_fmt(struct v4l2_subdev *sd,
                format->format = *mf;
                return 0;
 #else
-               return -ENOTTY;
+               return -EINVAL;
 #endif
        }
 
index 5ed2413eac8a1ebb817cf644f4a3008e7df1faf5..a71277e361ffd43baae82611b873feaa87f149c0 100644 (file)
@@ -1055,7 +1055,7 @@ static int ov2659_get_fmt(struct v4l2_subdev *sd,
                mutex_unlock(&ov2659->lock);
                return 0;
 #else
-       return -ENOTTY;
+               return -EINVAL;
 #endif
        }
 
@@ -1131,8 +1131,6 @@ static int ov2659_set_fmt(struct v4l2_subdev *sd,
 #ifdef CONFIG_VIDEO_V4L2_SUBDEV_API
                mf = v4l2_subdev_get_try_format(sd, cfg, fmt->pad);
                *mf = fmt->format;
-#else
-               ret = -ENOTTY;
 #endif
        } else {
                s64 val;
index b10bcfabaeeb05a2bc21283408b4f00062b7d116..164f983c18147796a3dbff27e1e0f6e5a0fef17e 100644 (file)
@@ -675,7 +675,7 @@ static int ov2680_get_fmt(struct v4l2_subdev *sd,
 #ifdef CONFIG_VIDEO_V4L2_SUBDEV_API
                fmt = v4l2_subdev_get_try_format(&sensor->sd, cfg, format->pad);
 #else
-               ret = -ENOTTY;
+               ret = -EINVAL;
 #endif
        } else {
                fmt = &sensor->fmt;
@@ -723,10 +723,7 @@ static int ov2680_set_fmt(struct v4l2_subdev *sd,
 #ifdef CONFIG_VIDEO_V4L2_SUBDEV_API
                try_fmt = v4l2_subdev_get_try_format(sd, cfg, 0);
                format->format = *try_fmt;
-#else
-               ret = -ENOTTY;
 #endif
-
                goto unlock;
        }
 
index e65a94353175d26f06ee5f25702aa4274e1d74df..34b7046d970215b6242220e56a0cf38fd8eec8e8 100644 (file)
@@ -823,9 +823,6 @@ static int ov5695_set_fmt(struct v4l2_subdev *sd,
        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
        } else {
                ov5695->cur_mode = mode;
@@ -856,7 +853,7 @@ static int ov5695_get_fmt(struct v4l2_subdev *sd,
                fmt->format = *v4l2_subdev_get_try_format(sd, cfg, fmt->pad);
 #else
                mutex_unlock(&ov5695->mutex);
-               return -ENOTTY;
+               return -EINVAL;
 #endif
        } else {
                fmt->format.width = mode->width;
index 70bb870b1d08767f38af63c6948642a95f670586..a2f8f19bca7c472056f8b6753fc2edfed4f5d0d1 100644 (file)
@@ -827,13 +827,9 @@ static int ov7740_set_fmt(struct v4l2_subdev *sd,
 #ifdef CONFIG_VIDEO_V4L2_SUBDEV_API
                mbus_fmt = v4l2_subdev_get_try_format(sd, cfg, format->pad);
                *mbus_fmt = format->format;
-
+#endif
                mutex_unlock(&ov7740->mutex);
                return 0;
-#else
-               ret = -ENOTTY;
-               goto error;
-#endif
        }
 
        ret = ov7740_try_fmt_internal(sd, &format->format, &ovfmt, &fsize);
@@ -868,7 +864,7 @@ static int ov7740_get_fmt(struct v4l2_subdev *sd,
                format->format = *mbus_fmt;
                ret = 0;
 #else
-               ret = -ENOTTY;
+               ret = -EINVAL;
 #endif
        } else {
                format->format = ov7740->format;