diff mbox series

[3/4] media: ov5640: Don't access ctrl regs when off

Message ID 1539067682-60604-4-git-send-email-sam@elite-embedded.com (mailing list archive)
State New, archived
Headers show
Series ov5640: small fixes for compatibility | expand

Commit Message

Samuel Bobrowicz Oct. 9, 2018, 6:48 a.m. UTC
Add a check to g_volatile_ctrl to prevent trying to read
registers when the sensor is not powered.

Signed-off-by: Sam Bobrowicz <sam@elite-embedded.com>
---
 drivers/media/i2c/ov5640.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Jacopo Mondi Oct. 10, 2018, 8:48 a.m. UTC | #1
Hi Sam,
   thanks for the patch.

On Mon, Oct 08, 2018 at 11:48:01PM -0700, Sam Bobrowicz wrote:
> Add a check to g_volatile_ctrl to prevent trying to read
> registers when the sensor is not powered.
>
> Signed-off-by: Sam Bobrowicz <sam@elite-embedded.com>

I've been carrying a similar patch in my tree. I found it is required
when the sensor control handler is add to the receiver driver control
handler, and thus g_voltaile_ctrl can be called when the sensor is
powered off.

Please add my:
Acked-by: Jacopo Mondi <jacopo@jmondi.org>

Thanks
   j

> ---
>  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
>
diff mbox series

Patch

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);