diff mbox series

[v2,6/9] media: i2c: imx334: Fix runtime PM handling in remove function

Message ID 20250329054335.19931-7-tarang.raval@siliconsignals.io (mailing list archive)
State New
Headers show
Series media: i2c: imx334: Miscellaneous cleanups and improvements | expand

Commit Message

Tarang Raval March 29, 2025, 5:43 a.m. UTC
pm_runtime_suspended() only checks the current runtime PM status and does
not modify it, making it ineffective in this context. This could result in
improper power management if the device remains active when removed.

This patch fixes the issue by introducing a check with
pm_runtime_status_suspended() to determine if the device is already 
suspended. If it is not, it calls imx334_power_off() to power down the 
device and then uses pm_runtime_set_suspended() to correctly update the 
runtime PM status to suspended.

Signed-off-by: Tarang Raval <tarang.raval@siliconsignals.io>
---
 drivers/media/i2c/imx334.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/drivers/media/i2c/imx334.c b/drivers/media/i2c/imx334.c
index 56d5576ccf94..ad28f12c29b3 100644
--- a/drivers/media/i2c/imx334.c
+++ b/drivers/media/i2c/imx334.c
@@ -1328,7 +1328,10 @@  static void imx334_remove(struct i2c_client *client)
 	v4l2_ctrl_handler_free(sd->ctrl_handler);
 
 	pm_runtime_disable(&client->dev);
-	pm_runtime_suspended(&client->dev);
+	if (!pm_runtime_status_suspended(&client->dev)) {
+		imx334_power_off(&client->dev);
+		pm_runtime_set_suspended(&client->dev);
+	}
 
 	mutex_destroy(&imx334->mutex);
 }