Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 330701
b: refs/heads/master
c: de40cb2
h: refs/heads/master
i:
  330699: 2828b80
v: v3
  • Loading branch information
Hans Verkuil authored and Mauro Carvalho Chehab committed Aug 9, 2012
1 parent 79b61e9 commit 6de7260
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: b0d5cd6b5f2137b3485c96c673beebfd6c726fd3
refs/heads/master: de40cb227d1948490da7fd833100ae7a4ae7d825
27 changes: 21 additions & 6 deletions trunk/drivers/media/video/s5p-g2d/g2d.c
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,14 @@ static int g2d_open(struct file *file)
ctx->in = def_frame;
ctx->out = def_frame;

if (mutex_lock_interruptible(&dev->mutex)) {
kfree(ctx);
return -ERESTARTSYS;
}
ctx->m2m_ctx = v4l2_m2m_ctx_init(dev->m2m_dev, ctx, &queue_init);
if (IS_ERR(ctx->m2m_ctx)) {
ret = PTR_ERR(ctx->m2m_ctx);
mutex_unlock(&dev->mutex);
kfree(ctx);
return ret;
}
Expand All @@ -264,6 +269,7 @@ static int g2d_open(struct file *file)
v4l2_ctrl_handler_setup(&ctx->ctrl_handler);

ctx->fh.ctrl_handler = &ctx->ctrl_handler;
mutex_unlock(&dev->mutex);

v4l2_info(&dev->v4l2_dev, "instance opened\n");
return 0;
Expand Down Expand Up @@ -406,13 +412,26 @@ static int vidioc_s_fmt(struct file *file, void *prv, struct v4l2_format *f)
static unsigned int g2d_poll(struct file *file, struct poll_table_struct *wait)
{
struct g2d_ctx *ctx = fh2ctx(file->private_data);
return v4l2_m2m_poll(file, ctx->m2m_ctx, wait);
struct g2d_dev *dev = ctx->dev;
unsigned int res;

mutex_lock(&dev->mutex);
res = v4l2_m2m_poll(file, ctx->m2m_ctx, wait);
mutex_unlock(&dev->mutex);
return res;
}

static int g2d_mmap(struct file *file, struct vm_area_struct *vma)
{
struct g2d_ctx *ctx = fh2ctx(file->private_data);
return v4l2_m2m_mmap(file, ctx->m2m_ctx, vma);
struct g2d_dev *dev = ctx->dev;
int ret;

if (mutex_lock_interruptible(&dev->mutex))
return -ERESTARTSYS;
ret = v4l2_m2m_mmap(file, ctx->m2m_ctx, vma);
mutex_unlock(&dev->mutex);
return ret;
}

static int vidioc_reqbufs(struct file *file, void *priv,
Expand Down Expand Up @@ -753,10 +772,6 @@ static int g2d_probe(struct platform_device *pdev)
goto unreg_v4l2_dev;
}
*vfd = g2d_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 = &dev->mutex;
ret = video_register_device(vfd, VFL_TYPE_GRABBER, 0);
if (ret) {
Expand Down

0 comments on commit 6de7260

Please sign in to comment.