diff mbox series

[1/3] media: i2c: adv748x: Fix lookup of DV timings

Message ID 20230222221249.1324102-2-niklas.soderlund+renesas@ragnatech.se (mailing list archive)
State Mainlined
Commit 1e293874fabf41fb34d58e22153766fd2bf8c6aa
Delegated to: Kieran Bingham
Headers show
Series media: i2c: adv748x: Enable pattern generator without external HDMI source | expand

Commit Message

Niklas Söderlund Feb. 22, 2023, 10:12 p.m. UTC
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>
---
 drivers/media/i2c/adv748x/adv748x-hdmi.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Geert Uytterhoeven Feb. 23, 2023, 10:05 a.m. UTC | #1
Hi Niklas,

On Wed, Feb 22, 2023 at 11:15 PM Niklas Söderlund
<niklas.soderlund+renesas@ragnatech.se> wrote:
> 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.

Nice catch!

> Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>

Fixes: 3e89586a64dfd286 ("media: i2c: adv748x: add adv748x driver")
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

Gr{oetje,eeting}s,

                        Geert
diff mbox series

Patch

diff --git a/drivers/media/i2c/adv748x/adv748x-hdmi.c b/drivers/media/i2c/adv748x/adv748x-hdmi.c
index 52fa7bd75660..1d62e05572cd 100644
--- a/drivers/media/i2c/adv748x/adv748x-hdmi.c
+++ b/drivers/media/i2c/adv748x/adv748x-hdmi.c
@@ -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))