From 2c675cca6e3600f6d4811e0fe3f3860d3b093d49 Mon Sep 17 00:00:00 2001 From: Sam Bobrowicz Date: Thu, 11 Oct 2018 09:23:28 -0700 Subject: [PATCH] media: ov5640: Don't access ctrl regs when off Add a check to g_volatile_ctrl to prevent trying to read registers when the sensor is not powered. Signed-off-by: Sam Bobrowicz Signed-off-by: Michal Simek --- drivers/media/i2c/ov5640.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/media/i2c/ov5640.c b/drivers/media/i2c/ov5640.c index 1186254e7fdf..bee303b17cf8 100644 --- a/drivers/media/i2c/ov5640.c +++ b/drivers/media/i2c/ov5640.c @@ -2556,6 +2556,13 @@ static int ov5640_g_volatile_ctrl(struct v4l2_ctrl *ctrl) /* v4l2_ctrl_lock() locks our own mutex */ + /* + * If the sensor is not powered up by the host driver, do + * not try to access it to update the volatile controls. + */ + if (sensor->power_count == 0) + return 0; + switch (ctrl->id) { case V4L2_CID_AUTOGAIN: val = ov5640_get_gain(sensor); -- 2.39.2