]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
media: adv7180: Only validate format in s_std
authorNiklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Thu, 28 Aug 2025 16:06:53 +0000 (18:06 +0200)
committerHans Verkuil <hverkuil+cisco@kernel.org>
Thu, 4 Sep 2025 08:06:13 +0000 (10:06 +0200)
The .s_std callback should not write the new format directly do the
device, it should only store it and have it applied by .s_stream.

As .s_stream already calls adv7180_program_std() all that is needed
is to check the standard is valid, and store it for .s_stream to
program.

While at it add a scoped guard to simplify the error handling.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
drivers/media/i2c/adv7180.c

index 444857c6015d6602bcae40dd2a20ba8fc313a073..75d453ab169126520aa9931017f76893ef8da24f 100644 (file)
@@ -468,22 +468,18 @@ static int adv7180_program_std(struct adv7180_state *state)
 static int adv7180_s_std(struct v4l2_subdev *sd, v4l2_std_id std)
 {
        struct adv7180_state *state = to_state(sd);
-       int ret = mutex_lock_interruptible(&state->mutex);
+       int ret;
 
-       if (ret)
-               return ret;
+       guard(mutex)(&state->mutex);
 
        /* Make sure we can support this std */
        ret = v4l2_std_to_adv7180(std);
        if (ret < 0)
-               goto out;
+               return ret;
 
        state->curr_norm = std;
 
-       ret = adv7180_program_std(state);
-out:
-       mutex_unlock(&state->mutex);
-       return ret;
+       return 0;
 }
 
 static int adv7180_g_std(struct v4l2_subdev *sd, v4l2_std_id *norm)