media: i2c: dw9768: Use runtime PM autosuspend
authorZhi Mao <zhi.mao@mediatek.com>
Sat, 12 Oct 2024 03:25:53 +0000 (11:25 +0800)
committerHans Verkuil <hverkuil@xs4all.nl>
Thu, 7 Nov 2024 08:05:59 +0000 (09:05 +0100)
Use runtime PM autosuspend function to avoid rapid power state bouncing.

Signed-off-by: Zhi Mao <zhi.mao@mediatek.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
drivers/media/i2c/dw9768.c

index 87a7c3ceeb119ef0408212f6cf5899c1e6a54801..3a4d100b9199f3dfab2c9750789a62938662f054 100644 (file)
@@ -374,7 +374,8 @@ static int dw9768_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
 
 static int dw9768_close(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
 {
-       pm_runtime_put(sd->dev);
+       pm_runtime_mark_last_busy(sd->dev);
+       pm_runtime_put_autosuspend(sd->dev);
 
        return 0;
 }
@@ -490,6 +491,8 @@ static int dw9768_probe(struct i2c_client *client)
                goto err_power_off;
        }
 
+       pm_runtime_set_autosuspend_delay(dev, 1000);
+       pm_runtime_use_autosuspend(dev);
        pm_runtime_idle(dev);
 
        return 0;