Skip to contentSkip to conversation

media: i2c: ov5647: fix power cleanup on remove

PATCH In review Guangshuo Li 2 participants 2 messages Sep 22

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 media: i2c: ov5647: fix power cleanup on remove

ov5647_remove() disables runtime PM without powering off the sensor if it is still runtime active. pm_runtime_disable() does not invoke the runtime suspend callback, so the sensor can remain powered on.

If the device is not already runtime suspended, call ov5647_power_off() and mark the runtime PM state as suspended.

This issue was found by manual code inspection.

Fixes 089b7c70f0d8 ("media: ov5647: Use pm_runtime infrastructure")

---
v2 :
- Move pm_runtime_set_suspended() into the conditional so it is only called when the sensor is explicitly powered off.

 drivers/media/i2c/ov5647.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/media/i2c/ov5647.c +4 -0
index 3facf92b3841..3b3e5653a0c6 100644
@@ -1271,6 +1271,10 @@ static void ov5647_remove(struct i2c_client *client)
 	v4l2_ctrl_handler_free(&sensor->ctrls);
 	v4l2_device_unregister_subdev(sd);
 	pm_runtime_disable(&client->dev);
+	if (!pm_runtime_status_suspended(&client->dev)) {
+		ov5647_power_off(&client->dev);
+		pm_runtime_set_suspended(&client->dev);
+	}
 }
 
 static const struct dev_pm_ops ov5647_pm_ops = {
Signature · 1 line
2.43.0
maintainer Reviewed-by on v2 1/1
#1 lore raw

Thanks Guangshuo

Quoted 5 lines · Guangshuo Li

ov5647_remove() disables runtime PM without powering off the sensor if it is still runtime active. pm_runtime_disable() does not invoke the runtime suspend callback, so the sensor can remain powered on.

Quoted 8 lines

If the device is not already runtime suspended, call ov5647_power_off() and mark the runtime PM state as suspended.

This issue was found by manual code inspection.

Fixes 089b7c70f0d8 ("media: ov5647: Use pm_runtime infrastructure")
Quoted 26 lines

---
v2 :
- Move pm_runtime_set_suspended() into the conditional so it is only called when the sensor is explicitly powered off.

 drivers/media/i2c/ov5647.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/media/i2c/ov5647.c +4 -1
index 3facf92b3841..3b3e5653a0c6 100644
@@ -1271,6 +1271,10 @@ static void ov5647_remove(struct i2c_client *client)
        v4l2_ctrl_handler_free(&sensor->ctrls);
        v4l2_device_unregister_subdev(sd);
        pm_runtime_disable(&client->dev);
+       if (!pm_runtime_status_suspended(&client->dev)) {
+               ov5647_power_off(&client->dev);
+               pm_runtime_set_suspended(&client->dev);
+       }
 }
 
 static const struct dev_pm_ops ov5647_pm_ops = {
--

2.43.0