[PATCH v2 06/16] media: i2c: ak7375: power off the lens driver on remove
From: Cong Nguyen
Date: Mon Nov 23 2026 - 10:40:05 EST
ak7375_open() takes a runtime PM reference with
pm_runtime_resume_and_get() and ak7375_close() drops it. ak7375_remove()
only calls pm_runtime_disable() and pm_runtime_set_suspended(), which
neither run the runtime suspend callback nor release the supplies, so a
device that is still runtime active when the driver is unbound, for
example because the subdev node is still open, can keep its regulators
enabled.
After disabling runtime PM, call ak7375_vcm_suspend() if the device is
not already runtime suspended. Do this before ak7375_subdev_cleanup(),
because the suspend callback reads the focus control that the cleanup
frees.
This issue was found by auditing the driver with an LLM coding assistant.
Fixes: 90ee26fb2f50 ("media: ak7375: Add ak7375 lens voice coil driver")
Signed-off-by: Cong Nguyen <congnt264@xxxxxxxxx>
---
drivers/media/i2c/ak7375.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/media/i2c/ak7375.c b/drivers/media/i2c/ak7375.c
index 2827fdb29298..a81cc1df81e7 100644
--- a/drivers/media/i2c/ak7375.c
+++ b/drivers/media/i2c/ak7375.c
@@ -329,9 +329,11 @@ static void ak7375_remove(struct i2c_client *client)
struct v4l2_subdev *sd = i2c_get_clientdata(client);
struct ak7375_device *ak7375_dev = sd_to_ak7375_vcm(sd);
- ak7375_subdev_cleanup(ak7375_dev);
pm_runtime_disable(&client->dev);
+ if (!pm_runtime_status_suspended(&client->dev))
+ ak7375_vcm_suspend(&client->dev);
pm_runtime_set_suspended(&client->dev);
+ ak7375_subdev_cleanup(ak7375_dev);
}
static const struct dev_pm_ops ak7375_pm_ops = {
--
2.25.1