Commit df4167d9 authored by Jacopo Mondi's avatar Jacopo Mondi Committed by Mauro Carvalho Chehab

media: imx: imx-mipi-csis: Simplify mipi_csis_s_stream()

Simplify the mipi_csis_s_stream() function.

This actually fixes a bug, as if calling the subdev's s_stream(1) fails,
mipi_csis_stop_stream() was not called.
Signed-off-by: default avatarJacopo Mondi <jacopo@jmondi.org>
Acked-by: default avatarRui Miguel Silva <rmfrfs@gmail.com>
Signed-off-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
parent c22afddc
......@@ -926,9 +926,24 @@ static struct mipi_csis_device *sd_to_mipi_csis_device(struct v4l2_subdev *sdev)
static int mipi_csis_s_stream(struct v4l2_subdev *sd, int enable)
{
struct mipi_csis_device *csis = sd_to_mipi_csis_device(sd);
int ret = 0;
int ret;
if (!enable) {
mutex_lock(&csis->lock);
v4l2_subdev_call(csis->src_sd, video, s_stream, 0);
mipi_csis_stop_stream(csis);
if (csis->debug.enable)
mipi_csis_log_counters(csis, true);
mutex_unlock(&csis->lock);
pm_runtime_put(csis->dev);
return 0;
}
if (enable) {
ret = mipi_csis_calculate_params(csis);
if (ret < 0)
return ret;
......@@ -938,30 +953,23 @@ static int mipi_csis_s_stream(struct v4l2_subdev *sd, int enable)
ret = pm_runtime_resume_and_get(csis->dev);
if (ret < 0)
return ret;
}
mutex_lock(&csis->lock);
if (enable) {
mipi_csis_start_stream(csis);
ret = v4l2_subdev_call(csis->src_sd, video, s_stream, 1);
if (ret < 0)
goto unlock;
goto error;
mipi_csis_log_counters(csis, true);
} else {
v4l2_subdev_call(csis->src_sd, video, s_stream, 0);
mipi_csis_stop_stream(csis);
mutex_unlock(&csis->lock);
if (csis->debug.enable)
mipi_csis_log_counters(csis, true);
}
return 0;
unlock:
error:
mipi_csis_stop_stream(csis);
mutex_unlock(&csis->lock);
if (!enable || ret < 0)
pm_runtime_put(csis->dev);
return 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