Commit 59f96244 authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab
Browse files

media: exynos4-is: fix pm_runtime_get_sync() usage count



The pm_runtime_get_sync() internally increments the
dev->power.usage_count without decrementing it, even on errors.

On some places, this is ok, but on others the usage count
ended being unbalanced on failures.

Replace it by the new pm_runtime_resume_and_get(), introduced by:
commit dd8088d5 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter")
in order to properly decrement the usage counter, avoiding
a potential PM usage counter leak.

As a bonus, such function always return zero on success. So,
some code can be simplified.

Reviewed-by: default avatarSylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent c44eac5b
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -478,11 +478,9 @@ static int fimc_capture_open(struct file *file)
		goto unlock;

	set_bit(ST_CAPT_BUSY, &fimc->state);
	ret = pm_runtime_get_sync(&fimc->pdev->dev);
	if (ret < 0) {
		pm_runtime_put_sync(&fimc->pdev->dev);
	ret = pm_runtime_resume_and_get(&fimc->pdev->dev);
	if (ret < 0)
		goto unlock;
	}

	ret = v4l2_fh_open(file);
	if (ret) {
+2 −2
Original line number Diff line number Diff line
@@ -828,9 +828,9 @@ static int fimc_is_probe(struct platform_device *pdev)
			goto err_irq;
	}

	ret = pm_runtime_get_sync(dev);
	ret = pm_runtime_resume_and_get(dev);
	if (ret < 0)
		goto err_pm;
		goto err_irq;

	vb2_dma_contig_set_max_seg_size(dev, DMA_BIT_MASK(32));

+1 −2
Original line number Diff line number Diff line
@@ -275,7 +275,7 @@ static int isp_video_open(struct file *file)
	if (ret < 0)
		goto unlock;

	ret = pm_runtime_get_sync(&isp->pdev->dev);
	ret = pm_runtime_resume_and_get(&isp->pdev->dev);
	if (ret < 0)
		goto rel_fh;

@@ -293,7 +293,6 @@ static int isp_video_open(struct file *file)
	if (!ret)
		goto unlock;
rel_fh:
	pm_runtime_put_noidle(&isp->pdev->dev);
	v4l2_fh_release(file);
unlock:
	mutex_unlock(&isp->video_lock);
+3 −4
Original line number Diff line number Diff line
@@ -304,11 +304,10 @@ static int fimc_isp_subdev_s_power(struct v4l2_subdev *sd, int on)
	pr_debug("on: %d\n", on);

	if (on) {
		ret = pm_runtime_get_sync(&is->pdev->dev);
		if (ret < 0) {
			pm_runtime_put(&is->pdev->dev);
		ret = pm_runtime_resume_and_get(&is->pdev->dev);
		if (ret < 0)
			return ret;
		}

		set_bit(IS_ST_PWR_ON, &is->state);

		ret = fimc_is_start_firmware(is);
+3 −2
Original line number Diff line number Diff line
@@ -469,9 +469,9 @@ static int fimc_lite_open(struct file *file)
	}

	set_bit(ST_FLITE_IN_USE, &fimc->state);
	ret = pm_runtime_get_sync(&fimc->pdev->dev);
	ret = pm_runtime_resume_and_get(&fimc->pdev->dev);
	if (ret < 0)
		goto err_pm;
		goto err_in_use;

	ret = v4l2_fh_open(file);
	if (ret < 0)
@@ -499,6 +499,7 @@ static int fimc_lite_open(struct file *file)
	v4l2_fh_release(file);
err_pm:
	pm_runtime_put_sync(&fimc->pdev->dev);
err_in_use:
	clear_bit(ST_FLITE_IN_USE, &fimc->state);
unlock:
	mutex_unlock(&fimc->lock);
Loading