media: ov5640: Update last busy timestamp to reset autosuspend timer
authorAndrey Skvortsov <andrej.skvortzov@gmail.com>
Sun, 15 Jan 2023 17:30:10 +0000 (18:30 +0100)
committerMauro Carvalho Chehab <mchehab@kernel.org>
Mon, 6 Feb 2023 07:27:00 +0000 (08:27 +0100)
Otherwise autosuspend delay doesn't work and power is cut off
immediately as device is freed.

Signed-off-by: Andrey Skvortsov <andrej.skvortzov@gmail.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
drivers/media/i2c/ov5640.c

index 2c37ed7b75d37b533a5be359241f1dc65cb4a911..34687ab23d77aaf49f70d1582129eb7774089ce2 100644 (file)
@@ -3327,6 +3327,7 @@ static int ov5640_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
                break;
        }
 
+       pm_runtime_mark_last_busy(&sensor->i2c_client->dev);
        pm_runtime_put_autosuspend(&sensor->i2c_client->dev);
 
        return 0;
@@ -3402,6 +3403,7 @@ static int ov5640_s_ctrl(struct v4l2_ctrl *ctrl)
                break;
        }
 
+       pm_runtime_mark_last_busy(&sensor->i2c_client->dev);
        pm_runtime_put_autosuspend(&sensor->i2c_client->dev);
 
        return ret;
@@ -3721,8 +3723,10 @@ static int ov5640_s_stream(struct v4l2_subdev *sd, int enable)
 out:
        mutex_unlock(&sensor->lock);
 
-       if (!enable || ret)
+       if (!enable || ret) {
+               pm_runtime_mark_last_busy(&sensor->i2c_client->dev);
                pm_runtime_put_autosuspend(&sensor->i2c_client->dev);
+       }
 
        return ret;
 }
@@ -3927,6 +3931,7 @@ static int ov5640_probe(struct i2c_client *client)
 
        pm_runtime_set_autosuspend_delay(dev, 1000);
        pm_runtime_use_autosuspend(dev);
+       pm_runtime_mark_last_busy(dev);
        pm_runtime_put_autosuspend(dev);
 
        return 0;