media: i2c: adv748x: Fix lookup of DV timings
authorNiklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Wed, 22 Feb 2023 22:12:47 +0000 (23:12 +0100)
committerHans Verkuil <hverkuil-cisco@xs4all.nl>
Tue, 11 Apr 2023 15:10:10 +0000 (17:10 +0200)
The loop to match the requested timings with the ones supported by the
driver is incorrect. It always iterates thru the whole array of
supported modes. The bounds check after the loop always triggers
resulting in adv748x_hdmi_set_video_timings() always returning -EINVAL.

Fix this by correcting the lookup to break the loop when a match is
found.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
drivers/media/i2c/adv748x/adv748x-hdmi.c

index 52fa7bd75660515b939c7d98dd72cef2c883018a..1d62e05572cd424455ca865064707e29b493e6d3 100644 (file)
@@ -176,9 +176,9 @@ static int adv748x_hdmi_set_video_timings(struct adv748x_state *state,
        unsigned int i;
 
        for (i = 0; i < ARRAY_SIZE(adv748x_hdmi_video_standards); i++) {
-               if (!v4l2_match_dv_timings(timings, &stds[i].timings, 250000,
-                                          false))
-                       continue;
+               if (v4l2_match_dv_timings(timings, &stds[i].timings, 250000,
+                                         false))
+                       break;
        }
 
        if (i >= ARRAY_SIZE(adv748x_hdmi_video_standards))