[PATCH 15/21] media: i2c: it6625: use early returns in it6625_update_timings_if_changed()

From: Hermes Wu via B4 Relay

Date: Fri Sep 18 2026 - 05:14:21 EST


From: Hermes Wu <Hermes.wu@xxxxxxxxxx>

Convert the if/else if/else chain that only ever assigns a single
ret value to early returns. guard(mutex)(...) is scoped to the whole
function body, so an early return still unlocks correctly.

Signed-off-by: Hermes Wu <Hermes.wu@xxxxxxxxxx>
---
drivers/media/i2c/it6625.c | 21 +++++++++------------
1 file changed, 9 insertions(+), 12 deletions(-)

diff --git a/drivers/media/i2c/it6625.c b/drivers/media/i2c/it6625.c
index 882eda8b836d655585ba45b0a33d1c068bb3a8ee..db962bc100cad9f4d71fa4156b10ff5b4c952a7c 100644
--- a/drivers/media/i2c/it6625.c
+++ b/drivers/media/i2c/it6625.c
@@ -1431,20 +1431,17 @@ static int
it6625_update_timings_if_changed(struct it6625 *it6625,
const struct v4l2_dv_timings *timings)
{
- int ret;
-
guard(mutex)(&it6625->it6625_lock);
- if (v4l2_match_dv_timings(&it6625->timings, timings, 0, false)) {
- ret = 0;
- } else if (!v4l2_valid_dv_timings(timings, it6625_get_timings_cap(it6625),
- NULL, NULL)) {
- ret = -ERANGE;
- } else {
- it6625->timings = *timings;
- ret = 1;
- }

- return ret;
+ if (v4l2_match_dv_timings(&it6625->timings, timings, 0, false))
+ return 0;
+
+ if (!v4l2_valid_dv_timings(timings, it6625_get_timings_cap(it6625), NULL, NULL))
+ return -ERANGE;
+
+ it6625->timings = *timings;
+
+ return 1;
}

static int it6625_enum_dv_timings(struct v4l2_subdev *sd,

--
2.34.1