summaryrefslogtreecommitdiff
path: root/linux/drivers/media/video
diff options
context:
space:
mode:
authorBrandon Philips <brandon@ifup.org>2008-04-02 11:10:59 -0700
committerBrandon Philips <brandon@ifup.org>2008-04-02 11:10:59 -0700
commit0d730d2dbca7a10dd804a067cb380305e16c5a14 (patch)
tree648be0f262d6af98b227e1f00332e11b704ac7fb /linux/drivers/media/video
parent98eb0e3f7a086e3eae0736d229b3f8791f194c76 (diff)
downloadmediapointer-dvb-s2-0d730d2dbca7a10dd804a067cb380305e16c5a14.tar.gz
mediapointer-dvb-s2-0d730d2dbca7a10dd804a067cb380305e16c5a14.tar.bz2
videobuf: Simplify videobuf_waiton logic and possibly avoid missed wakeup
Possible missed wakeup- use kernel helpers for wait queues http://www.mail-archive.com/linux-usb-devel@lists.sourceforge.net/msg27983.html Signed-off-by: Brandon Philips <bphilips@suse.de> --- linux/drivers/media/video/videobuf-core.c | 37 ++++++++++++------------------ 1 file changed, 15 insertions(+), 22 deletions(-)
Diffstat (limited to 'linux/drivers/media/video')
-rw-r--r--linux/drivers/media/video/videobuf-core.c37
1 files changed, 15 insertions, 22 deletions
diff --git a/linux/drivers/media/video/videobuf-core.c b/linux/drivers/media/video/videobuf-core.c
index ec94e9adb..47af78a06 100644
--- a/linux/drivers/media/video/videobuf-core.c
+++ b/linux/drivers/media/video/videobuf-core.c
@@ -65,32 +65,25 @@ void *videobuf_alloc(struct videobuf_queue *q)
return vb;
}
+#define WAITON_CONDITION (vb->state != VIDEOBUF_ACTIVE &&\
+ vb->state != VIDEOBUF_QUEUED)
int videobuf_waiton(struct videobuf_buffer *vb, int non_blocking, int intr)
{
- int retval = 0;
- DECLARE_WAITQUEUE(wait, current);
-
MAGIC_CHECK(vb->magic, MAGIC_BUFFER);
- add_wait_queue(&vb->done, &wait);
- while (vb->state == VIDEOBUF_ACTIVE || vb->state == VIDEOBUF_QUEUED) {
- if (non_blocking) {
- retval = -EAGAIN;
- break;
- }
- set_current_state(intr ? TASK_INTERRUPTIBLE
- : TASK_UNINTERRUPTIBLE);
- if (vb->state == VIDEOBUF_ACTIVE ||
- vb->state == VIDEOBUF_QUEUED)
- schedule();
- set_current_state(TASK_RUNNING);
- if (intr && signal_pending(current)) {
- dprintk(1, "buffer waiton: -EINTR\n");
- retval = -EINTR;
- break;
- }
+
+ if (non_blocking) {
+ if (WAITON_CONDITION)
+ return 0;
+ else
+ return -EAGAIN;
}
- remove_wait_queue(&vb->done, &wait);
- return retval;
+
+ if (intr)
+ return wait_event_interruptible(vb->done, WAITON_CONDITION);
+ else
+ wait_event(vb->done, WAITON_CONDITION);
+
+ return 0;
}
int videobuf_iolock(struct videobuf_queue *q, struct videobuf_buffer *vb,