aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/s5p-g2d
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2012-06-24 05:58:28 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-08-09 19:13:08 -0400
commitde40cb227d1948490da7fd833100ae7a4ae7d825 (patch)
tree12e07144f3ff85e29039193a87faa4eab31e162b /drivers/media/video/s5p-g2d
parentb0d5cd6b5f2137b3485c96c673beebfd6c726fd3 (diff)
[media] s5p-g2d: 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/s5p-g2d')
-rw-r--r--drivers/media/video/s5p-g2d/g2d.c27
1 files changed, 21 insertions, 6 deletions
diff --git a/drivers/media/video/s5p-g2d/g2d.c b/drivers/media/video/s5p-g2d/g2d.c
index 7c2200435206..0edc2df98732 100644
--- a/drivers/media/video/s5p-g2d/g2d.c
+++ b/drivers/media/video/s5p-g2d/g2d.c
@@ -248,9 +248,14 @@ static int g2d_open(struct file *file)
248 ctx->in = def_frame; 248 ctx->in = def_frame;
249 ctx->out = def_frame; 249 ctx->out = def_frame;
250 250
251 if (mutex_lock_interruptible(&dev->mutex)) {
252 kfree(ctx);
253 return -ERESTARTSYS;
254 }
251 ctx->m2m_ctx = v4l2_m2m_ctx_init(dev->m2m_dev, ctx, &queue_init); 255 ctx->m2m_ctx = v4l2_m2m_ctx_init(dev->m2m_dev, ctx, &queue_init);
252 if (IS_ERR(ctx->m2m_ctx)) { 256 if (IS_ERR(ctx->m2m_ctx)) {
253 ret = PTR_ERR(ctx->m2m_ctx); 257 ret = PTR_ERR(ctx->m2m_ctx);
258 mutex_unlock(&dev->mutex);
254 kfree(ctx); 259 kfree(ctx);
255 return ret; 260 return ret;
256 } 261 }
@@ -264,6 +269,7 @@ static int g2d_open(struct file *file)
264 v4l2_ctrl_handler_setup(&ctx->ctrl_handler); 269 v4l2_ctrl_handler_setup(&ctx->ctrl_handler);
265 270
266 ctx->fh.ctrl_handler = &ctx->ctrl_handler; 271 ctx->fh.ctrl_handler = &ctx->ctrl_handler;
272 mutex_unlock(&dev->mutex);
267 273
268 v4l2_info(&dev->v4l2_dev, "instance opened\n"); 274 v4l2_info(&dev->v4l2_dev, "instance opened\n");
269 return 0; 275 return 0;
@@ -406,13 +412,26 @@ static int vidioc_s_fmt(struct file *file, void *prv, struct v4l2_format *f)
406static unsigned int g2d_poll(struct file *file, struct poll_table_struct *wait) 412static unsigned int g2d_poll(struct file *file, struct poll_table_struct *wait)
407{ 413{
408 struct g2d_ctx *ctx = fh2ctx(file->private_data); 414 struct g2d_ctx *ctx = fh2ctx(file->private_data);
409 return v4l2_m2m_poll(file, ctx->m2m_ctx, wait); 415 struct g2d_dev *dev = ctx->dev;
416 unsigned int res;
417
418 mutex_lock(&dev->mutex);
419 res = v4l2_m2m_poll(file, ctx->m2m_ctx, wait);
420 mutex_unlock(&dev->mutex);
421 return res;
410} 422}
411 423
412static int g2d_mmap(struct file *file, struct vm_area_struct *vma) 424static int g2d_mmap(struct file *file, struct vm_area_struct *vma)
413{ 425{
414 struct g2d_ctx *ctx = fh2ctx(file->private_data); 426 struct g2d_ctx *ctx = fh2ctx(file->private_data);
415 return v4l2_m2m_mmap(file, ctx->m2m_ctx, vma); 427 struct g2d_dev *dev = ctx->dev;
428 int ret;
429
430 if (mutex_lock_interruptible(&dev->mutex))
431 return -ERESTARTSYS;
432 ret = v4l2_m2m_mmap(file, ctx->m2m_ctx, vma);
433 mutex_unlock(&dev->mutex);
434 return ret;
416} 435}
417 436
418static int vidioc_reqbufs(struct file *file, void *priv, 437static int vidioc_reqbufs(struct file *file, void *priv,
@@ -753,10 +772,6 @@ static int g2d_probe(struct platform_device *pdev)
753 goto unreg_v4l2_dev; 772 goto unreg_v4l2_dev;
754 } 773 }
755 *vfd = g2d_videodev; 774 *vfd = g2d_videodev;
756 /* Locking in file operations other than ioctl should be done
757 by the driver, not the V4L2 core.
758 This driver needs auditing so that this flag can be removed. */
759 set_bit(V4L2_FL_LOCK_ALL_FOPS, &vfd->flags);
760 vfd->lock = &dev->mutex; 775 vfd->lock = &dev->mutex;
761 ret = video_register_device(vfd, VFL_TYPE_GRABBER, 0); 776 ret = video_register_device(vfd, VFL_TYPE_GRABBER, 0);
762 if (ret) { 777 if (ret) {