]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
media: i2c: imx319: Rectify runtime PM handling probe and remove
authorSakari Ailus <sakari.ailus@linux.intel.com>
Fri, 10 Jan 2025 12:55:59 +0000 (14:55 +0200)
committerHans Verkuil <hverkuil@xs4all.nl>
Sat, 15 Feb 2025 14:22:51 +0000 (15:22 +0100)
Idle the device only after the async sub-device has been successfully
registered. In error handling, set the device's runtime PM status to
suspended only if it has been set to active previously in probe.

Also set the device's runtime PM status to suspended in remove only if it
wasn't so already.

Fixes: 8a89dc62f28c ("media: add imx319 camera sensor driver")
Cc: stable@vger.kernel.org # for >= v6.12
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
drivers/media/i2c/imx319.c

index dd1b4ff983dcb1755adde2da1f92db7a2edf91e9..701840f4a5cc009675e9bec28c0fbc22b6367e83 100644 (file)
@@ -2442,17 +2442,19 @@ static int imx319_probe(struct i2c_client *client)
        if (full_power)
                pm_runtime_set_active(&client->dev);
        pm_runtime_enable(&client->dev);
-       pm_runtime_idle(&client->dev);
 
        ret = v4l2_async_register_subdev_sensor(&imx319->sd);
        if (ret < 0)
                goto error_media_entity_pm;
 
+       pm_runtime_idle(&client->dev);
+
        return 0;
 
 error_media_entity_pm:
        pm_runtime_disable(&client->dev);
-       pm_runtime_set_suspended(&client->dev);
+       if (full_power)
+               pm_runtime_set_suspended(&client->dev);
        media_entity_cleanup(&imx319->sd.entity);
 
 error_handler_free:
@@ -2474,7 +2476,8 @@ static void imx319_remove(struct i2c_client *client)
        v4l2_ctrl_handler_free(sd->ctrl_handler);
 
        pm_runtime_disable(&client->dev);
-       pm_runtime_set_suspended(&client->dev);
+       if (!pm_runtime_status_suspended(&client->dev))
+               pm_runtime_set_suspended(&client->dev);
 
        mutex_destroy(&imx319->mutex);
 }