Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 330700
b: refs/heads/master
c: b0d5cd6
h: refs/heads/master
v: v3
  • Loading branch information
Hans Verkuil authored and Mauro Carvalho Chehab committed Aug 9, 2012
1 parent 2828b80 commit 79b61e9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 11 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: 8422b087834f198a63f33c46f34059356cafef9d
refs/heads/master: b0d5cd6b5f2137b3485c96c673beebfd6c726fd3
34 changes: 24 additions & 10 deletions trunk/drivers/media/video/s5p-jpeg/jpeg-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,11 @@ static int s5p_jpeg_open(struct file *file)
if (!ctx)
return -ENOMEM;

if (mutex_lock_interruptible(&jpeg->lock)) {
ret = -ERESTARTSYS;
goto free;
}

v4l2_fh_init(&ctx->fh, vfd);
/* Use separate control handler per file handle */
ctx->fh.ctrl_handler = &ctx->ctrl_handler;
Expand Down Expand Up @@ -319,20 +324,26 @@ static int s5p_jpeg_open(struct file *file)

ctx->out_q.fmt = out_fmt;
ctx->cap_q.fmt = s5p_jpeg_find_format(ctx->mode, V4L2_PIX_FMT_YUYV);
mutex_unlock(&jpeg->lock);
return 0;

error:
v4l2_fh_del(&ctx->fh);
v4l2_fh_exit(&ctx->fh);
mutex_unlock(&jpeg->lock);
free:
kfree(ctx);
return ret;
}

static int s5p_jpeg_release(struct file *file)
{
struct s5p_jpeg *jpeg = video_drvdata(file);
struct s5p_jpeg_ctx *ctx = fh_to_ctx(file->private_data);

mutex_lock(&jpeg->lock);
v4l2_m2m_ctx_release(ctx->m2m_ctx);
mutex_unlock(&jpeg->lock);
v4l2_ctrl_handler_free(&ctx->ctrl_handler);
v4l2_fh_del(&ctx->fh);
v4l2_fh_exit(&ctx->fh);
Expand All @@ -344,16 +355,27 @@ static int s5p_jpeg_release(struct file *file)
static unsigned int s5p_jpeg_poll(struct file *file,
struct poll_table_struct *wait)
{
struct s5p_jpeg *jpeg = video_drvdata(file);
struct s5p_jpeg_ctx *ctx = fh_to_ctx(file->private_data);
unsigned int res;

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

static int s5p_jpeg_mmap(struct file *file, struct vm_area_struct *vma)
{
struct s5p_jpeg *jpeg = video_drvdata(file);
struct s5p_jpeg_ctx *ctx = fh_to_ctx(file->private_data);
int ret;

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

static const struct v4l2_file_operations s5p_jpeg_fops = {
Expand Down Expand Up @@ -1372,10 +1394,6 @@ static int s5p_jpeg_probe(struct platform_device *pdev)
jpeg->vfd_encoder->release = video_device_release;
jpeg->vfd_encoder->lock = &jpeg->lock;
jpeg->vfd_encoder->v4l2_dev = &jpeg->v4l2_dev;
/* 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, &jpeg->vfd_encoder->flags);

ret = video_register_device(jpeg->vfd_encoder, VFL_TYPE_GRABBER, -1);
if (ret) {
Expand Down Expand Up @@ -1403,10 +1421,6 @@ static int s5p_jpeg_probe(struct platform_device *pdev)
jpeg->vfd_decoder->release = video_device_release;
jpeg->vfd_decoder->lock = &jpeg->lock;
jpeg->vfd_decoder->v4l2_dev = &jpeg->v4l2_dev;
/* 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, &jpeg->vfd_decoder->flags);

ret = video_register_device(jpeg->vfd_decoder, VFL_TYPE_GRABBER, -1);
if (ret) {
Expand Down

0 comments on commit 79b61e9

Please sign in to comment.