media: atomisp-ov2680: properly set the vts value
authorMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Wed, 10 Nov 2021 10:55:39 +0000 (10:55 +0000)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Mon, 15 Nov 2021 08:11:58 +0000 (08:11 +0000)
The vts value should be set before being checked, as otherwise a
warning will arise:

drivers/staging/media/atomisp/i2c/atomisp-ov2680.c: In function 'ov2680_set_fmt':
drivers/staging/media/atomisp/i2c/atomisp-ov2680.c:873:33: warning: 'vts' may be used uninitialized
[-Wmaybe-uninitialized]
  873 |         if (dev->exposure > vts - OV2680_INTEGRATION_TIME_MARGIN)

Reported-by: Hans Verkuil <hverkuil@xs4all.nl>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Fixes: 62b984359b6f ("media: atomisp-ov2680: Fix ov2680_set_fmt() messing up high exposure settings")
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
drivers/staging/media/atomisp/i2c/atomisp-ov2680.c

index 497884d..d24f883 100644 (file)
@@ -869,11 +869,11 @@ static int ov2680_set_fmt(struct v4l2_subdev *sd,
                dev_err(&client->dev,
                        "ov2680 write resolution register err: %d\n", ret);
 
+       vts = dev->res->lines_per_frame;
+
        /* If necessary increase the VTS to match exposure + MARGIN */
        if (dev->exposure > vts - OV2680_INTEGRATION_TIME_MARGIN)
                vts = dev->exposure + OV2680_INTEGRATION_TIME_MARGIN;
-       else
-               vts = dev->res->lines_per_frame;
 
        ret = ov2680_write_reg(client, 2, OV2680_TIMING_VTS_H, vts);
        if (ret)