diff options
author | Hans Verkuil <hans.verkuil@cisco.com> | 2012-06-24 06:29:33 -0300 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-08-09 19:51:17 -0300 |
commit | 954f5bcb390c8d8a7357fe4f5e0ba264058574fb (patch) | |
tree | e020e0d4f1bf521528ae321998ee14c06cb11dcd /drivers/media/video | |
parent | cbc807dc8a53b997eb8cd8ddbea42b9077a6640f (diff) |
[media] mx2_emmaprp: remove V4L2_FL_LOCK_ALL_FOPS
Add proper locking to the file operations, allowing for the removal
of the V4L2_FL_LOCK_ALL_FOPS flag.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video')
-rw-r--r-- | drivers/media/video/mx2_emmaprp.c | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/drivers/media/video/mx2_emmaprp.c b/drivers/media/video/mx2_emmaprp.c index 728cac339d1a..2810015d78f4 100644 --- a/drivers/media/video/mx2_emmaprp.c +++ b/drivers/media/video/mx2_emmaprp.c @@ -795,11 +795,17 @@ static int emmaprp_open(struct file *file) file->private_data = ctx; ctx->dev = pcdev; + if (mutex_lock_interruptible(&pcdev->dev_mutex)) { + kfree(ctx); + return -ERESTARTSYS; + } + ctx->m2m_ctx = v4l2_m2m_ctx_init(pcdev->m2m_dev, ctx, &queue_init); if (IS_ERR(ctx->m2m_ctx)) { int ret = PTR_ERR(ctx->m2m_ctx); + mutex_unlock(&pcdev->dev_mutex); kfree(ctx); return ret; } @@ -808,6 +814,7 @@ static int emmaprp_open(struct file *file) clk_prepare_enable(pcdev->clk_emma_ahb); ctx->q_data[V4L2_M2M_SRC].fmt = &formats[1]; ctx->q_data[V4L2_M2M_DST].fmt = &formats[0]; + mutex_unlock(&pcdev->dev_mutex); dprintk(pcdev, "Created instance %p, m2m_ctx: %p\n", ctx, ctx->m2m_ctx); @@ -821,9 +828,11 @@ static int emmaprp_release(struct file *file) dprintk(pcdev, "Releasing instance %p\n", ctx); + mutex_lock(&pcdev->dev_mutex); clk_disable_unprepare(pcdev->clk_emma_ahb); clk_disable_unprepare(pcdev->clk_emma_ipg); v4l2_m2m_ctx_release(ctx->m2m_ctx); + mutex_unlock(&pcdev->dev_mutex); kfree(ctx); return 0; @@ -832,16 +841,27 @@ static int emmaprp_release(struct file *file) static unsigned int emmaprp_poll(struct file *file, struct poll_table_struct *wait) { + struct emmaprp_dev *pcdev = video_drvdata(file); struct emmaprp_ctx *ctx = file->private_data; + unsigned int res; - return v4l2_m2m_poll(file, ctx->m2m_ctx, wait); + mutex_lock(&pcdev->dev_mutex); + res = v4l2_m2m_poll(file, ctx->m2m_ctx, wait); + mutex_unlock(&pcdev->dev_mutex); + return res; } static int emmaprp_mmap(struct file *file, struct vm_area_struct *vma) { + struct emmaprp_dev *pcdev = video_drvdata(file); struct emmaprp_ctx *ctx = file->private_data; + int ret; - return v4l2_m2m_mmap(file, ctx->m2m_ctx, vma); + if (mutex_lock_interruptible(&pcdev->dev_mutex)) + return -ERESTARTSYS; + ret = v4l2_m2m_mmap(file, ctx->m2m_ctx, vma); + mutex_unlock(&pcdev->dev_mutex); + return ret; } static const struct v4l2_file_operations emmaprp_fops = { @@ -916,10 +936,6 @@ static int emmaprp_probe(struct platform_device *pdev) } *vfd = emmaprp_videodev; - /* Locking in file operations other than ioctl should be done - by the driver, not the V4L2 core. - This driver needs auditing so that this flag can be removed. */ - set_bit(V4L2_FL_LOCK_ALL_FOPS, &vfd->flags); vfd->lock = &pcdev->dev_mutex; video_set_drvdata(vfd, pcdev); |