Commit b92f8f35 authored by Laurent Pinchart's avatar Laurent Pinchart Committed by Hans Verkuil

media: i2c: Use pm_runtime_resume_and_get()

Simplify error handling by using pm_runtime_resume_and_get() instead of
pm_runtime_get_sync() with a put call in the error path.
Signed-off-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Benjamin Mugnier <benjamin.mugnier@foss.st.com> (st-vgxy61)
Signed-off-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
parent 20290fea
...@@ -1893,9 +1893,9 @@ static int ccs_pm_get_init(struct ccs_sensor *sensor) ...@@ -1893,9 +1893,9 @@ static int ccs_pm_get_init(struct ccs_sensor *sensor)
* relies at the returned value to detect if the device was already * relies at the returned value to detect if the device was already
* active or not. * active or not.
*/ */
rval = pm_runtime_get_sync(&client->dev); rval = pm_runtime_resume_and_get(&client->dev);
if (rval < 0) if (rval)
goto error; return rval;
/* Device was already active, so don't set controls */ /* Device was already active, so don't set controls */
if (rval == 1) if (rval == 1)
......
...@@ -1613,11 +1613,9 @@ static int hi846_set_stream(struct v4l2_subdev *sd, int enable) ...@@ -1613,11 +1613,9 @@ static int hi846_set_stream(struct v4l2_subdev *sd, int enable)
mutex_lock(&hi846->mutex); mutex_lock(&hi846->mutex);
if (enable) { if (enable) {
ret = pm_runtime_get_sync(&client->dev); ret = pm_runtime_resume_and_get(&client->dev);
if (ret < 0) { if (ret)
pm_runtime_put_noidle(&client->dev);
goto out; goto out;
}
ret = hi846_start_streaming(hi846); ret = hi846_start_streaming(hi846);
} }
......
...@@ -2623,9 +2623,8 @@ static int hi847_set_stream(struct v4l2_subdev *sd, int enable) ...@@ -2623,9 +2623,8 @@ static int hi847_set_stream(struct v4l2_subdev *sd, int enable)
mutex_lock(&hi847->mutex); mutex_lock(&hi847->mutex);
if (enable) { if (enable) {
ret = pm_runtime_get_sync(&client->dev); ret = pm_runtime_resume_and_get(&client->dev);
if (ret < 0) { if (ret) {
pm_runtime_put_noidle(&client->dev);
mutex_unlock(&hi847->mutex); mutex_unlock(&hi847->mutex);
return ret; return ret;
} }
......
...@@ -720,9 +720,11 @@ static int imx208_set_stream(struct v4l2_subdev *sd, int enable) ...@@ -720,9 +720,11 @@ static int imx208_set_stream(struct v4l2_subdev *sd, int enable)
} }
if (enable) { if (enable) {
ret = pm_runtime_get_sync(&client->dev); ret = pm_runtime_resume_and_get(&client->dev);
if (ret < 0) if (ret) {
goto err_rpm_put; mutex_unlock(&imx208->imx208_mx);
return ret;
}
/* /*
* Apply default & customized values * Apply default & customized values
...@@ -819,11 +821,9 @@ static int imx208_read_otp(struct imx208 *imx208) ...@@ -819,11 +821,9 @@ static int imx208_read_otp(struct imx208 *imx208)
if (imx208->otp_read) if (imx208->otp_read)
goto out_unlock; goto out_unlock;
ret = pm_runtime_get_sync(&client->dev); ret = pm_runtime_resume_and_get(&client->dev);
if (ret < 0) { if (ret)
pm_runtime_put_noidle(&client->dev);
goto out_unlock; goto out_unlock;
}
ret = imx208_identify_module(imx208); ret = imx208_identify_module(imx208);
if (ret) if (ret)
......
...@@ -737,9 +737,8 @@ static int og01a1b_set_stream(struct v4l2_subdev *sd, int enable) ...@@ -737,9 +737,8 @@ static int og01a1b_set_stream(struct v4l2_subdev *sd, int enable)
mutex_lock(&og01a1b->mutex); mutex_lock(&og01a1b->mutex);
if (enable) { if (enable) {
ret = pm_runtime_get_sync(&client->dev); ret = pm_runtime_resume_and_get(&client->dev);
if (ret < 0) { if (ret) {
pm_runtime_put_noidle(&client->dev);
mutex_unlock(&og01a1b->mutex); mutex_unlock(&og01a1b->mutex);
return ret; return ret;
} }
......
...@@ -975,9 +975,9 @@ static int ov5693_s_stream(struct v4l2_subdev *sd, int enable) ...@@ -975,9 +975,9 @@ static int ov5693_s_stream(struct v4l2_subdev *sd, int enable)
int ret; int ret;
if (enable) { if (enable) {
ret = pm_runtime_get_sync(ov5693->dev); ret = pm_runtime_resume_and_get(ov5693->dev);
if (ret < 0) if (ret)
goto err_power_down; return ret;
mutex_lock(&ov5693->lock); mutex_lock(&ov5693->lock);
ret = __v4l2_ctrl_handler_setup(&ov5693->ctrls.handler); ret = __v4l2_ctrl_handler_setup(&ov5693->ctrls.handler);
......
...@@ -1340,9 +1340,11 @@ static int ov7251_s_stream(struct v4l2_subdev *subdev, int enable) ...@@ -1340,9 +1340,11 @@ static int ov7251_s_stream(struct v4l2_subdev *subdev, int enable)
mutex_lock(&ov7251->lock); mutex_lock(&ov7251->lock);
if (enable) { if (enable) {
ret = pm_runtime_get_sync(ov7251->dev); ret = pm_runtime_resume_and_get(ov7251->dev);
if (ret < 0) if (ret) {
goto err_power_down; mutex_unlock(&ov7251->lock);
return ret;
}
ret = ov7251_pll_configure(ov7251); ret = ov7251_pll_configure(ov7251);
if (ret) { if (ret) {
......
...@@ -1170,14 +1170,9 @@ static int vgxy61_stream_enable(struct vgxy61_dev *sensor) ...@@ -1170,14 +1170,9 @@ static int vgxy61_stream_enable(struct vgxy61_dev *sensor)
if (ret) if (ret)
return ret; return ret;
ret = pm_runtime_get_sync(&client->dev); ret = pm_runtime_resume_and_get(&client->dev);
if (ret < 0) { if (ret)
pm_runtime_put_autosuspend(&client->dev);
return ret; return ret;
}
/* pm_runtime_get_sync() can return 1 as a valid return code */
ret = 0;
vgxy61_write_reg(sensor, VGXY61_REG_FORMAT_CTRL, vgxy61_write_reg(sensor, VGXY61_REG_FORMAT_CTRL,
get_bpp_by_code(sensor->fmt.code), &ret); get_bpp_by_code(sensor->fmt.code), &ret);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment