Commit 8fd390b8 authored by Ezequiel Garcia's avatar Ezequiel Garcia Committed by Mauro Carvalho Chehab
Browse files

media: Split v4l2_pipeline_pm_use into v4l2_pipeline_pm_{get, put}



Currently, v4l2_pipeline_pm_use() prototype is:

  int v4l2_pipeline_pm_use(struct media_entity *entity, int use)

Where the 'use' argument shall only be set to '1' for enable/power-on,
or to '0' for disable/power-off. The integer return is specified
as only meaningful when 'use' is set to '1'.

Let's enforce this semantic by splitting the function in two:
v4l2_pipeline_pm_get and v4l2_pipeline_pm_put. This is done
for several reasons.

It makes the API easier to use (or harder to misuse).
It removes the constraint on the values the 'use' argument
shall take. Also, it removes the need to constraint
the return value, by making v4l2_pipeline_pm_put void return.

And last, it's more consistent with other kernel APIs, such
as the runtime pm APIs, which makes the code more symmetric.

Signed-off-by: default avatarEzequiel Garcia <ezequiel@collabora.com>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent 8fb12ce2
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -74,7 +74,7 @@ Before the receiver driver may enable the CSI-2 transmitter by using
the :c:type:`v4l2_subdev_video_ops`->s_stream(), it must have powered
the transmitter up by using the
:c:type:`v4l2_subdev_core_ops`->s_power() callback. This may take
place either indirectly by using :c:func:`v4l2_pipeline_pm_use` or
place either indirectly by using :c:func:`v4l2_pipeline_pm_get` or
directly.

Formats
+2 −2
Original line number Diff line number Diff line
@@ -1311,7 +1311,7 @@ static int isp_video_open(struct file *file)
		goto done;
	}

	ret = v4l2_pipeline_pm_use(&video->video.entity, 1);
	ret = v4l2_pipeline_pm_get(&video->video.entity);
	if (ret < 0) {
		omap3isp_put(video->isp);
		goto done;
@@ -1363,7 +1363,7 @@ static int isp_video_release(struct file *file)
	vb2_queue_release(&handle->queue);
	mutex_unlock(&video->queue_lock);

	v4l2_pipeline_pm_use(&video->video.entity, 0);
	v4l2_pipeline_pm_put(&video->video.entity);

	/* Release the file handle. */
	v4l2_fh_del(vfh);
+2 −2
Original line number Diff line number Diff line
@@ -745,7 +745,7 @@ static int video_open(struct file *file)

	file->private_data = vfh;

	ret = v4l2_pipeline_pm_use(&vdev->entity, 1);
	ret = v4l2_pipeline_pm_get(&vdev->entity);
	if (ret < 0) {
		dev_err(video->camss->dev, "Failed to power up pipeline: %d\n",
			ret);
@@ -771,7 +771,7 @@ static int video_release(struct file *file)

	vb2_fop_release(file);

	v4l2_pipeline_pm_use(&vdev->entity, 0);
	v4l2_pipeline_pm_put(&vdev->entity);

	file->private_data = NULL;

+3 −3
Original line number Diff line number Diff line
@@ -842,7 +842,7 @@ static int rvin_open(struct file *file)
		goto err_unlock;

	if (vin->info->use_mc)
		ret = v4l2_pipeline_pm_use(&vin->vdev.entity, 1);
		ret = v4l2_pipeline_pm_get(&vin->vdev.entity);
	else if (v4l2_fh_is_singular_file(file))
		ret = rvin_power_parallel(vin, true);

@@ -858,7 +858,7 @@ static int rvin_open(struct file *file)
	return 0;
err_power:
	if (vin->info->use_mc)
		v4l2_pipeline_pm_use(&vin->vdev.entity, 0);
		v4l2_pipeline_pm_put(&vin->vdev.entity);
	else if (v4l2_fh_is_singular_file(file))
		rvin_power_parallel(vin, false);
err_open:
@@ -886,7 +886,7 @@ static int rvin_release(struct file *file)
	ret = _vb2_fop_release(file, NULL);

	if (vin->info->use_mc) {
		v4l2_pipeline_pm_use(&vin->vdev.entity, 0);
		v4l2_pipeline_pm_put(&vin->vdev.entity);
	} else {
		if (fh_singular)
			rvin_power_parallel(vin, false);
+3 −3
Original line number Diff line number Diff line
@@ -214,7 +214,7 @@ static int sun4i_csi_open(struct file *file)
	if (ret < 0)
		goto err_pm_put;

	ret = v4l2_pipeline_pm_use(&csi->vdev.entity, 1);
	ret = v4l2_pipeline_pm_get(&csi->vdev.entity);
	if (ret)
		goto err_pm_put;

@@ -227,7 +227,7 @@ static int sun4i_csi_open(struct file *file)
	return 0;

err_pipeline_pm_put:
	v4l2_pipeline_pm_use(&csi->vdev.entity, 0);
	v4l2_pipeline_pm_put(&csi->vdev.entity);

err_pm_put:
	pm_runtime_put(csi->dev);
@@ -243,7 +243,7 @@ static int sun4i_csi_release(struct file *file)
	mutex_lock(&csi->lock);

	v4l2_fh_release(file);
	v4l2_pipeline_pm_use(&csi->vdev.entity, 0);
	v4l2_pipeline_pm_put(&csi->vdev.entity);
	pm_runtime_put(csi->dev);

	mutex_unlock(&csi->lock);
Loading