struct v4l2_subdev_format *format)
 {
        struct ov2680_dev *sensor = to_ov2680_dev(sd);
-       struct v4l2_mbus_framefmt *fmt = &format->format;
        struct v4l2_mbus_framefmt *try_fmt;
        const struct ov2680_mode_info *mode;
        int ret = 0;
                return -EINVAL;
 
        mode = v4l2_find_nearest_size(ov2680_mode_data,
-                                     ARRAY_SIZE(ov2680_mode_data), width,
-                                     height, fmt->width, fmt->height);
+                                     ARRAY_SIZE(ov2680_mode_data),
+                                     width, height,
+                                     format->format.width,
+                                     format->format.height);
        if (!mode)
                return -EINVAL;
 
+       ov2680_fill_format(sensor, &format->format, mode->width, mode->height);
+
        if (format->which == V4L2_SUBDEV_FORMAT_TRY) {
                try_fmt = v4l2_subdev_get_try_format(sd, sd_state, 0);
-               format->format = *try_fmt;
+               *try_fmt = format->format;
                return 0;
        }
 
                goto unlock;
        }
 
-       ov2680_fill_format(sensor, fmt, mode->width, mode->height);
-
        sensor->current_mode = mode;
        sensor->fmt = format->format;
        sensor->mode_pending_changes = true;