Add a check to g_volatile_ctrl to prevent trying to read
registers when the sensor is not powered.

Signed-off-by: Sam Bobrowicz <[email protected]>
---
 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 f183222..a50d884 100644
--- a/drivers/media/i2c/ov5640.c
+++ b/drivers/media/i2c/ov5640.c
@@ -2336,6 +2336,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.7.4

Reply via email to