Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

media: adv7180: Only validate format in s_std

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>

authored by

Niklas Söderlund and committed by
Hans Verkuil
df2cd073 46c1e781

+4 -8
+4 -8
drivers/media/i2c/adv7180.c
··· 468 468 static int adv7180_s_std(struct v4l2_subdev *sd, v4l2_std_id std) 469 469 { 470 470 struct adv7180_state *state = to_state(sd); 471 - int ret = mutex_lock_interruptible(&state->mutex); 471 + int ret; 472 472 473 - if (ret) 474 - return ret; 473 + guard(mutex)(&state->mutex); 475 474 476 475 /* Make sure we can support this std */ 477 476 ret = v4l2_std_to_adv7180(std); 478 477 if (ret < 0) 479 - goto out; 478 + return ret; 480 479 481 480 state->curr_norm = std; 482 481 483 - ret = adv7180_program_std(state); 484 - out: 485 - mutex_unlock(&state->mutex); 486 - return ret; 482 + return 0; 487 483 } 488 484 489 485 static int adv7180_g_std(struct v4l2_subdev *sd, v4l2_std_id *norm)