summaryrefslogtreecommitdiff
path: root/drivers/media/platform/imx8/mxc-isi-cap.c
diff options
context:
space:
mode:
authorGuoniu.Zhou <guoniu.zhou@nxp.com>2018-11-12 16:17:44 +0800
committerJason Liu <jason.hui.liu@nxp.com>2019-02-12 10:35:13 +0800
commit0723572decd4f81ec3d955592d236619d559b7e5 (patch)
treed0c2f340649b77681a02a2489a7dd35ed4935f04 /drivers/media/platform/imx8/mxc-isi-cap.c
parentaf0b4e25216bff819f2ae91915998edc7e626730 (diff)
MLK-20325: ISI: fix reference count error when camera is not connected
If camera is not connected and user try to use mem2mem function, driver will return error but isi channel0 reference counter is still increased by one. This will lead to mem2mem driver return EBUSY error when user open mem2mem device, so correct this bug in this patch. Signed-off-by: Guoniu.Zhou <guoniu.zhou@nxp.com>
Diffstat (limited to 'drivers/media/platform/imx8/mxc-isi-cap.c')
-rw-r--r--drivers/media/platform/imx8/mxc-isi-cap.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/drivers/media/platform/imx8/mxc-isi-cap.c b/drivers/media/platform/imx8/mxc-isi-cap.c
index 7378136d5a02..da90c91cf880 100644
--- a/drivers/media/platform/imx8/mxc-isi-cap.c
+++ b/drivers/media/platform/imx8/mxc-isi-cap.c
@@ -664,14 +664,14 @@ static int mxc_isi_capture_open(struct file *file)
source_pad = mxc_isi_get_remote_source_pad(mxc_isi);
if (source_pad == NULL) {
v4l2_err(mxc_isi->v4l2_dev, "%s, No remote pad found!\n", __func__);
- return -EINVAL;
+ goto fail;
}
/* Get remote source pad subdev */
sd = media_entity_to_v4l2_subdev(source_pad->entity);
if (sd == NULL) {
v4l2_err(mxc_isi->v4l2_dev, "%s, No remote subdev found!\n", __func__);
- return -EINVAL;
+ goto fail;
}
mutex_lock(&mxc_isi->lock);
@@ -684,10 +684,14 @@ static int mxc_isi_capture_open(struct file *file)
if (ret) {
v4l2_err(mxc_isi->v4l2_dev, "%s, Call subdev s_power fail!\n", __func__);
pm_runtime_put(dev);
- return ret;
+ goto fail;
}
return 0;
+
+fail:
+ atomic_dec(&mxc_isi->open_count);
+ return -EINVAL;
}
static int mxc_isi_capture_release(struct file *file)
@@ -725,7 +729,8 @@ static int mxc_isi_capture_release(struct file *file)
}
mutex_unlock(&mxc_isi->lock);
- if (atomic_dec_and_test(&mxc_isi->open_count))
+ if (atomic_read(&mxc_isi->open_count) > 0 &&
+ atomic_dec_and_test(&mxc_isi->open_count))
mxc_isi_channel_deinit(mxc_isi);
ret = v4l2_subdev_call(sd, core, s_power, 0);