1
0
Fork 0

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>
pull/10/head
Guoniu.Zhou 2018-11-12 16:17:44 +08:00
parent c9357f5816
commit 4aee62ccc3
1 changed files with 9 additions and 4 deletions

View File

@ -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);