@@ -595,24 +595,22 @@ static int ov2680_set_fmt(struct v4l2_subdev *sd,
if (format->pad != 0)
return -EINVAL;
- mutex_lock(&sensor->lock);
-
- if (sensor->is_streaming) {
- ret = -EBUSY;
- goto unlock;
- }
-
mode = v4l2_find_nearest_size(ov2680_mode_data,
ARRAY_SIZE(ov2680_mode_data), width,
height, fmt->width, fmt->height);
- if (!mode) {
- ret = -EINVAL;
- goto unlock;
- }
+ if (!mode)
+ return -EINVAL;
if (format->which == V4L2_SUBDEV_FORMAT_TRY) {
try_fmt = v4l2_subdev_get_try_format(sd, sd_state, 0);
format->format = *try_fmt;
+ return 0;
+ }
+
+ mutex_lock(&sensor->lock);
+
+ if (sensor->is_streaming) {
+ ret = -EBUSY;
goto unlock;
}