lkml.org 
[lkml]   [2004]   [Nov]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH 4/12] meye: do lock properly when waiting for buffers
===================================================================
ChangeSet@1.2343, 2004-11-02 15:46:59+01:00, stelian@popies.net
meye: do lock properly when waiting for buffers

Signed-off-by: Stelian Pop <stelian@popies.net>

===================================================================
meye.c | 15 +++++++++++++--
1 files changed, 13 insertions(+), 2 deletions(-)
===================================================================
diff -Nru a/drivers/media/video/meye.c b/drivers/media/video/meye.c
--- a/drivers/media/video/meye.c 2004-11-04 11:21:51 +01:00
+++ b/drivers/media/video/meye.c 2004-11-04 11:21:52 +01:00
@@ -929,19 +929,25 @@
if (*i < 0 || *i >= gbuffers)
return -EINVAL;

+ down(&meye.lock);
+
switch (meye.grab_buffer[*i].state) {

case MEYE_BUF_UNUSED:
+ up(&meye.lock);
return -EINVAL;
case MEYE_BUF_USING:
if (wait_event_interruptible(meye.proc_list,
- (meye.grab_buffer[*i].state != MEYE_BUF_USING)))
+ (meye.grab_buffer[*i].state != MEYE_BUF_USING))) {
+ up(&meye.lock);
return -EINTR;
+ }
/* fall through */
case MEYE_BUF_DONE:
meye.grab_buffer[*i].state = MEYE_BUF_UNUSED;
kfifo_get(meye.doneq, (unsigned char *)&unused, sizeof(int));
}
+ up(&meye.lock);
break;
}

@@ -1059,20 +1065,25 @@
if (*i < 0 || *i >= gbuffers)
return -EINVAL;

+ down(&meye.lock);
switch (meye.grab_buffer[*i].state) {

case MEYE_BUF_UNUSED:
+ up(&meye.lock);
return -EINVAL;
case MEYE_BUF_USING:
if (wait_event_interruptible(meye.proc_list,
- (meye.grab_buffer[*i].state != MEYE_BUF_USING)))
+ (meye.grab_buffer[*i].state != MEYE_BUF_USING))) {
+ up(&meye.lock);
return -EINTR;
+ }
/* fall through */
case MEYE_BUF_DONE:
meye.grab_buffer[*i].state = MEYE_BUF_UNUSED;
kfifo_get(meye.doneq, (unsigned char *)&unused, sizeof(int));
}
*i = meye.grab_buffer[*i].size;
+ up(&meye.lock);
break;
}

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
\
 
 \ /
  Last update: 2005-03-22 14:07    [from the cache]
©2003-2014 Jasper Spaans. Advertise on this site