Commit e9174a64 authored by Hans de Goede's avatar Hans de Goede Committed by Mauro Carvalho Chehab

media: atomisp-ov2680: Push the input_lock taking up into ov2680_s_power()

ov2680_s_power() is the only caller of ov2680_init(), push the input_lock
taking from ov2680_init() up into ov2680_s_power(), this way the new
power_on bool is also protected by it.

Link: https://lore.kernel.org/linux-media/20211107171549.267583-4-hdegoede@redhat.comSigned-off-by: default avatarHans de Goede <hdegoede@redhat.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent 12350633
...@@ -655,21 +655,11 @@ static int ov2680_init_registers(struct v4l2_subdev *sd) ...@@ -655,21 +655,11 @@ static int ov2680_init_registers(struct v4l2_subdev *sd)
static int ov2680_init(struct v4l2_subdev *sd) static int ov2680_init(struct v4l2_subdev *sd)
{ {
struct ov2680_device *dev = to_ov2680_sensor(sd);
int ret;
mutex_lock(&dev->input_lock);
/* restore settings */ /* restore settings */
ov2680_res = ov2680_res_preview; ov2680_res = ov2680_res_preview;
N_RES = N_RES_PREVIEW; N_RES = N_RES_PREVIEW;
ret = ov2680_init_registers(sd); return ov2680_init_registers(sd);
mutex_unlock(&dev->input_lock);
return ret;
} }
static int power_ctrl(struct v4l2_subdev *sd, bool flag) static int power_ctrl(struct v4l2_subdev *sd, bool flag)
...@@ -817,15 +807,21 @@ static int power_down(struct v4l2_subdev *sd) ...@@ -817,15 +807,21 @@ static int power_down(struct v4l2_subdev *sd)
static int ov2680_s_power(struct v4l2_subdev *sd, int on) static int ov2680_s_power(struct v4l2_subdev *sd, int on)
{ {
struct ov2680_device *dev = to_ov2680_sensor(sd);
int ret; int ret;
mutex_lock(&dev->input_lock);
if (on == 0) { if (on == 0) {
ret = power_down(sd); ret = power_down(sd);
} else { } else {
ret = power_up(sd); ret = power_up(sd);
if (!ret) if (!ret)
return ov2680_init(sd); ret = ov2680_init(sd);
} }
mutex_unlock(&dev->input_lock);
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment