media: i2c: imx214: Rectify probe error handling related to runtime PM
commit ccc888d1698b6f42d52ddf5cecfe50fe925c95e5 upstream.
There were multiple issues in the driver's probe function related to
error handling:
- Device's PM runtime status wasn't reverted to suspended on some errors
in probe.
- Runtime PM was left enabled for the device on some probe errors.
- Device was left powered on if a probe failure happened or when it
was removed when it was powered on.
- An extra pm_runtime_set_suspended() was issued in driver's remove
function when the device was suspended.
Fix these bugs.
Fixes: 4361905962 ("media: imx214: Add imx214 camera sensor driver")
Cc: stable@vger.kernel.org # for >= v6.12
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Acked-by: André Apitzsch <git@apitzsch.eu>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
8dd2d1561c
commit
6f77a6d2ea
@@ -1075,10 +1075,6 @@ static int imx214_probe(struct i2c_client *client)
|
||||
*/
|
||||
imx214_power_on(imx214->dev);
|
||||
|
||||
pm_runtime_set_active(imx214->dev);
|
||||
pm_runtime_enable(imx214->dev);
|
||||
pm_runtime_idle(imx214->dev);
|
||||
|
||||
ret = imx214_ctrls_init(imx214);
|
||||
if (ret < 0)
|
||||
goto error_power_off;
|
||||
@@ -1099,21 +1095,30 @@ static int imx214_probe(struct i2c_client *client)
|
||||
|
||||
imx214_entity_init_state(&imx214->sd, NULL);
|
||||
|
||||
pm_runtime_set_active(imx214->dev);
|
||||
pm_runtime_enable(imx214->dev);
|
||||
|
||||
ret = v4l2_async_register_subdev_sensor(&imx214->sd);
|
||||
if (ret < 0) {
|
||||
dev_err(dev, "could not register v4l2 device\n");
|
||||
goto free_entity;
|
||||
}
|
||||
|
||||
pm_runtime_idle(imx214->dev);
|
||||
|
||||
return 0;
|
||||
|
||||
free_entity:
|
||||
pm_runtime_disable(imx214->dev);
|
||||
pm_runtime_set_suspended(&client->dev);
|
||||
media_entity_cleanup(&imx214->sd.entity);
|
||||
|
||||
free_ctrl:
|
||||
mutex_destroy(&imx214->mutex);
|
||||
v4l2_ctrl_handler_free(&imx214->ctrls);
|
||||
|
||||
error_power_off:
|
||||
pm_runtime_disable(imx214->dev);
|
||||
imx214_power_off(imx214->dev);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -1126,11 +1131,12 @@ static void imx214_remove(struct i2c_client *client)
|
||||
v4l2_async_unregister_subdev(&imx214->sd);
|
||||
media_entity_cleanup(&imx214->sd.entity);
|
||||
v4l2_ctrl_handler_free(&imx214->ctrls);
|
||||
|
||||
pm_runtime_disable(&client->dev);
|
||||
pm_runtime_set_suspended(&client->dev);
|
||||
|
||||
mutex_destroy(&imx214->mutex);
|
||||
pm_runtime_disable(&client->dev);
|
||||
if (!pm_runtime_status_suspended(&client->dev)) {
|
||||
imx214_power_off(imx214->dev);
|
||||
pm_runtime_set_suspended(&client->dev);
|
||||
}
|
||||
}
|
||||
|
||||
static const struct of_device_id imx214_of_match[] = {
|
||||
|
||||
Reference in New Issue
Block a user