Stopping streaming on a camera pipeline at system suspend time, and restarting it at system resume time, requires coordinated action between the bridge driver and the camera sensor driver. This is handled by the bridge driver calling the sensor's .s_stream() handler at system suspend and resume time. There is thus no need for the sensor to independently implement system sleep PM operations. Drop them. The streaming field of the driver's private structure is now unused, drop it as well. Signed-off-by: Hans de Goede <hdegoede@xxxxxxxxxx> --- drivers/media/i2c/ov02c10.c | 53 +++---------------------------------- 1 file changed, 4 insertions(+), 49 deletions(-) diff --git a/drivers/media/i2c/ov02c10.c b/drivers/media/i2c/ov02c10.c index da727e18a282..09e70ffcf07a 100644 --- a/drivers/media/i2c/ov02c10.c +++ b/drivers/media/i2c/ov02c10.c @@ -393,9 +393,6 @@ struct ov02c10 { /* MIPI lane info */ u32 link_freq_index; u8 mipi_lanes; - - /* Streaming on/off */ - bool streaming; }; static inline struct ov02c10 *to_ov02c10(struct v4l2_subdev *subdev) @@ -618,9 +615,7 @@ static int ov02c10_enable_streams(struct v4l2_subdev *sd, return ret; ret = ov02c10_start_streaming(ov02c10); - if (ret == 0) - ov02c10->streaming = true; - else + if (ret) pm_runtime_put(&client->dev); return ret; @@ -636,7 +631,6 @@ static int ov02c10_disable_streams(struct v4l2_subdev *sd, guard(mutex)(&ov02c10->mutex); ov02c10_stop_streaming(ov02c10); - ov02c10->streaming = false; pm_runtime_put(&client->dev); return 0; @@ -711,43 +705,6 @@ static int ov02c10_power_on(struct device *dev) return 0; } -static int __maybe_unused ov02c10_suspend(struct device *dev) -{ - struct i2c_client *client = to_i2c_client(dev); - struct v4l2_subdev *sd = i2c_get_clientdata(client); - struct ov02c10 *ov02c10 = to_ov02c10(sd); - - mutex_lock(&ov02c10->mutex); - if (ov02c10->streaming) - ov02c10_stop_streaming(ov02c10); - - mutex_unlock(&ov02c10->mutex); - - return 0; -} - -static int __maybe_unused ov02c10_resume(struct device *dev) -{ - struct i2c_client *client = to_i2c_client(dev); - struct v4l2_subdev *sd = i2c_get_clientdata(client); - struct ov02c10 *ov02c10 = to_ov02c10(sd); - int ret = 0; - - mutex_lock(&ov02c10->mutex); - if (!ov02c10->streaming) - goto exit; - - ret = ov02c10_start_streaming(ov02c10); - if (ret) { - ov02c10->streaming = false; - ov02c10_stop_streaming(ov02c10); - } - -exit: - mutex_unlock(&ov02c10->mutex); - return ret; -} - static int ov02c10_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_state *sd_state, struct v4l2_subdev_format *fmt) @@ -1047,10 +1004,8 @@ static int ov02c10_probe(struct i2c_client *client) return ret; } -static const struct dev_pm_ops ov02c10_pm_ops = { - SET_SYSTEM_SLEEP_PM_OPS(ov02c10_suspend, ov02c10_resume) - SET_RUNTIME_PM_OPS(ov02c10_power_off, ov02c10_power_on, NULL) -}; +static DEFINE_RUNTIME_DEV_PM_OPS(ov02c10_pm_ops, ov02c10_power_off, + ov02c10_power_on, NULL); #ifdef CONFIG_ACPI static const struct acpi_device_id ov02c10_acpi_ids[] = { @@ -1064,7 +1019,7 @@ MODULE_DEVICE_TABLE(acpi, ov02c10_acpi_ids); static struct i2c_driver ov02c10_i2c_driver = { .driver = { .name = "ov02c10", - .pm = &ov02c10_pm_ops, + .pm = pm_sleep_ptr(&ov02c10_pm_ops), .acpi_match_table = ACPI_PTR(ov02c10_acpi_ids), }, .probe = ov02c10_probe, -- 2.48.1