Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 223392
b: refs/heads/master
c: 8e815e1
h: refs/heads/master
v: v3
  • Loading branch information
Laurent Pinchart authored and Mauro Carvalho Chehab committed Dec 1, 2010
1 parent bd6ba77 commit a621da9
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 26 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: 23d9f3ef23f0dc4bb20ccd5540b9a91ff08da08f
refs/heads/master: 8e815e1763b8d4e5adf0dc14bde8c55329cf95a8
57 changes: 34 additions & 23 deletions trunk/drivers/media/video/uvc/uvc_queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,39 @@ void uvc_queue_init(struct uvc_video_queue *queue, enum v4l2_buf_type type,
queue->type = type;
}

/*
* Free the video buffers.
*
* This function must be called with the queue lock held.
*/
static int __uvc_free_buffers(struct uvc_video_queue *queue)
{
unsigned int i;

for (i = 0; i < queue->count; ++i) {
if (queue->buffer[i].vma_use_count != 0)
return -EBUSY;
}

if (queue->count) {
vfree(queue->mem);
queue->count = 0;
}

return 0;
}

int uvc_free_buffers(struct uvc_video_queue *queue)
{
int ret;

mutex_lock(&queue->mutex);
ret = __uvc_free_buffers(queue);
mutex_unlock(&queue->mutex);

return ret;
}

/*
* Allocate the video buffers.
*
Expand All @@ -110,7 +143,7 @@ int uvc_alloc_buffers(struct uvc_video_queue *queue, unsigned int nbuffers,

mutex_lock(&queue->mutex);

if ((ret = uvc_free_buffers(queue)) < 0)
if ((ret = __uvc_free_buffers(queue)) < 0)
goto done;

/* Bail out if no buffers should be allocated. */
Expand Down Expand Up @@ -151,28 +184,6 @@ int uvc_alloc_buffers(struct uvc_video_queue *queue, unsigned int nbuffers,
return ret;
}

/*
* Free the video buffers.
*
* This function must be called with the queue lock held.
*/
int uvc_free_buffers(struct uvc_video_queue *queue)
{
unsigned int i;

for (i = 0; i < queue->count; ++i) {
if (queue->buffer[i].vma_use_count != 0)
return -EBUSY;
}

if (queue->count) {
vfree(queue->mem);
queue->count = 0;
}

return 0;
}

/*
* Check if buffers have been allocated.
*/
Expand Down
2 changes: 0 additions & 2 deletions trunk/drivers/media/video/uvc/uvc_v4l2.c
Original file line number Diff line number Diff line change
Expand Up @@ -494,11 +494,9 @@ static int uvc_v4l2_release(struct file *file)
if (uvc_has_privileges(handle)) {
uvc_video_enable(stream, 0);

mutex_lock(&stream->queue.mutex);
if (uvc_free_buffers(&stream->queue) < 0)
uvc_printk(KERN_ERR, "uvc_v4l2_release: Unable to "
"free buffers.\n");
mutex_unlock(&stream->queue.mutex);
}

/* Release the file handle. */
Expand Down

0 comments on commit a621da9

Please sign in to comment.