Message ID | 20250116124118.42130-4-sakari.ailus@linux.intel.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | Camera sensor driver PM fixes | expand |
Reviewed-by: Bingbu Cao <bingbu.cao@intel.com> On 1/16/25 8:41 PM, Sakari Ailus wrote: > Set the device's runtime PM status and enable runtime PM before > registering the async sub-device. This is needed to avoid the case where > the device is runtime PM resumed while runtime PM has not been enabled > yet. > > Also set the device's runtime PM status to suspended in remove only if it > wasn't so already. > > Fixes: 1283b3b8f82b ("media: i2c: Add driver for Sony IMX219 sensor") > Cc: stable@vger.kernel.org # for >= v6.6 > Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> > --- > drivers/media/i2c/imx219.c | 13 ++++++++----- > 1 file changed, 8 insertions(+), 5 deletions(-) > > diff --git a/drivers/media/i2c/imx219.c b/drivers/media/i2c/imx219.c > index 2d54cea113e1..c6c30109225c 100644 > --- a/drivers/media/i2c/imx219.c > +++ b/drivers/media/i2c/imx219.c > @@ -1178,6 +1178,9 @@ static int imx219_probe(struct i2c_client *client) > goto error_media_entity; > } > > + pm_runtime_set_active(dev); > + pm_runtime_enable(dev); > + > ret = v4l2_async_register_subdev_sensor(&imx219->sd); > if (ret < 0) { > dev_err_probe(dev, ret, > @@ -1185,15 +1188,14 @@ static int imx219_probe(struct i2c_client *client) > goto error_subdev_cleanup; > } > > - /* Enable runtime PM and turn off the device */ > - pm_runtime_set_active(dev); > - pm_runtime_enable(dev); > pm_runtime_idle(dev); > > return 0; > > error_subdev_cleanup: > v4l2_subdev_cleanup(&imx219->sd); > + pm_runtime_disable(dev); > + pm_runtime_set_suspended(dev); > > error_media_entity: > media_entity_cleanup(&imx219->sd.entity); > @@ -1218,9 +1220,10 @@ static void imx219_remove(struct i2c_client *client) > imx219_free_controls(imx219); > > pm_runtime_disable(&client->dev); > - if (!pm_runtime_status_suspended(&client->dev)) > + if (!pm_runtime_status_suspended(&client->dev)) { > imx219_power_off(&client->dev); > - pm_runtime_set_suspended(&client->dev); > + pm_runtime_set_suspended(&client->dev); > + } > } > > static const struct of_device_id imx219_dt_ids[] = { >
diff --git a/drivers/media/i2c/imx219.c b/drivers/media/i2c/imx219.c index 2d54cea113e1..c6c30109225c 100644 --- a/drivers/media/i2c/imx219.c +++ b/drivers/media/i2c/imx219.c @@ -1178,6 +1178,9 @@ static int imx219_probe(struct i2c_client *client) goto error_media_entity; } + pm_runtime_set_active(dev); + pm_runtime_enable(dev); + ret = v4l2_async_register_subdev_sensor(&imx219->sd); if (ret < 0) { dev_err_probe(dev, ret, @@ -1185,15 +1188,14 @@ static int imx219_probe(struct i2c_client *client) goto error_subdev_cleanup; } - /* Enable runtime PM and turn off the device */ - pm_runtime_set_active(dev); - pm_runtime_enable(dev); pm_runtime_idle(dev); return 0; error_subdev_cleanup: v4l2_subdev_cleanup(&imx219->sd); + pm_runtime_disable(dev); + pm_runtime_set_suspended(dev); error_media_entity: media_entity_cleanup(&imx219->sd.entity); @@ -1218,9 +1220,10 @@ static void imx219_remove(struct i2c_client *client) imx219_free_controls(imx219); pm_runtime_disable(&client->dev); - if (!pm_runtime_status_suspended(&client->dev)) + if (!pm_runtime_status_suspended(&client->dev)) { imx219_power_off(&client->dev); - pm_runtime_set_suspended(&client->dev); + pm_runtime_set_suspended(&client->dev); + } } static const struct of_device_id imx219_dt_ids[] = {
Set the device's runtime PM status and enable runtime PM before registering the async sub-device. This is needed to avoid the case where the device is runtime PM resumed while runtime PM has not been enabled yet. Also set the device's runtime PM status to suspended in remove only if it wasn't so already. Fixes: 1283b3b8f82b ("media: i2c: Add driver for Sony IMX219 sensor") Cc: stable@vger.kernel.org # for >= v6.6 Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> --- drivers/media/i2c/imx219.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)