summaryrefslogtreecommitdiff
path: root/drivers/media/platform/nxp
diff options
context:
space:
mode:
authorJacopo Mondi <jacopo@jmondi.org>2022-03-14 13:39:37 +0300
committerMauro Carvalho Chehab <mchehab@kernel.org>2022-04-24 11:05:56 +0300
commitdf4167d9c5af4d07cab71bde3a88f35c57dd319f (patch)
treec9f605de512544615b7ecd0dd41af25392f1323f /drivers/media/platform/nxp
parentc22afddcf7c5001c00010c38f67689cf19e5fb65 (diff)
downloadlinux-df4167d9c5af4d07cab71bde3a88f35c57dd319f.tar.xz
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: Jacopo Mondi <jacopo@jmondi.org> Acked-by: Rui Miguel Silva <rmfrfs@gmail.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Diffstat (limited to 'drivers/media/platform/nxp')
-rw-r--r--drivers/media/platform/nxp/imx-mipi-csis.c58
1 files changed, 33 insertions, 25 deletions
diff --git a/drivers/media/platform/nxp/imx-mipi-csis.c b/drivers/media/platform/nxp/imx-mipi-csis.c
index f4b32edd8dfd..8a2250684913 100644
--- a/drivers/media/platform/nxp/imx-mipi-csis.c
+++ b/drivers/media/platform/nxp/imx-mipi-csis.c
@@ -926,43 +926,51 @@ 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) {
- ret = mipi_csis_calculate_params(csis);
- if (ret < 0)
- return ret;
+ if (!enable) {
+ mutex_lock(&csis->lock);
- mipi_csis_clear_counters(csis);
+ v4l2_subdev_call(csis->src_sd, video, s_stream, 0);
- ret = pm_runtime_resume_and_get(csis->dev);
- if (ret < 0)
- return ret;
+ 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;
}
- mutex_lock(&csis->lock);
+ ret = mipi_csis_calculate_params(csis);
+ if (ret < 0)
+ return ret;
- if (enable) {
- mipi_csis_start_stream(csis);
- ret = v4l2_subdev_call(csis->src_sd, video, s_stream, 1);
- if (ret < 0)
- goto unlock;
+ mipi_csis_clear_counters(csis);
- mipi_csis_log_counters(csis, true);
- } else {
- v4l2_subdev_call(csis->src_sd, video, s_stream, 0);
+ ret = pm_runtime_resume_and_get(csis->dev);
+ if (ret < 0)
+ return ret;
- mipi_csis_stop_stream(csis);
+ mutex_lock(&csis->lock);
- if (csis->debug.enable)
- mipi_csis_log_counters(csis, true);
- }
+ mipi_csis_start_stream(csis);
+ ret = v4l2_subdev_call(csis->src_sd, video, s_stream, 1);
+ if (ret < 0)
+ goto error;
+
+ mipi_csis_log_counters(csis, true);
-unlock:
mutex_unlock(&csis->lock);
- if (!enable || ret < 0)
- pm_runtime_put(csis->dev);
+ return 0;
+
+error:
+ mipi_csis_stop_stream(csis);
+ mutex_unlock(&csis->lock);
+ pm_runtime_put(csis->dev);
return ret;
}