summaryrefslogtreecommitdiff
path: root/v4l_experimental/pvrusb2/pvrusb2-ioread.c
diff options
context:
space:
mode:
authorMike Isely <devnull@localhost>2006-01-23 06:58:06 +0000
committerMike Isely <devnull@localhost>2006-01-23 06:58:06 +0000
commit02770b94ef98488e5f3a2f255ab32bcf6829710d (patch)
treee0bc4d8d28cdf841a01d6abbe8b020c392234d7d /v4l_experimental/pvrusb2/pvrusb2-ioread.c
parent5a0c9ba6e3b1171b5998d194fd5d7d9142f45881 (diff)
downloadmediapointer-dvb-s2-02770b94ef98488e5f3a2f255ab32bcf6829710d.tar.gz
mediapointer-dvb-s2-02770b94ef98488e5f3a2f255ab32bcf6829710d.tar.bz2
Use mutexes in pvrusb2 for kernel 2.6.16 or later
From: Mike Isely <isely@pobox.com> Signed-off-by: Mike Isely <isely@pobox.com>
Diffstat (limited to 'v4l_experimental/pvrusb2/pvrusb2-ioread.c')
-rw-r--r--v4l_experimental/pvrusb2/pvrusb2-ioread.c28
1 files changed, 19 insertions, 9 deletions
diff --git a/v4l_experimental/pvrusb2/pvrusb2-ioread.c b/v4l_experimental/pvrusb2/pvrusb2-ioread.c
index 5517e545c..375dd8acb 100644
--- a/v4l_experimental/pvrusb2/pvrusb2-ioread.c
+++ b/v4l_experimental/pvrusb2/pvrusb2-ioread.c
@@ -1,6 +1,6 @@
/*
*
- * $Id: pvrusb2-ioread.c,v 1.1 2005/11/14 13:31:24 mchehab Exp $
+ * $Id: pvrusb2-ioread.c,v 1.2 2006/01/23 06:58:06 mcisely Exp $
*
* Copyright (C) 2005 Mike Isely <isely@pobox.com>
*
@@ -19,12 +19,18 @@
*
*/
+#include "compat.h"
#include "pvrusb2-ioread.h"
#include "pvrusb2-debug.h"
#include <linux/errno.h>
#include <linux/string.h>
#include <linux/slab.h>
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
+#include <asm/atomic.h>
+#include <asm/mutex.h>
+#else
#include <asm/semaphore.h>
+#endif
#include <asm/uaccess.h>
#define BUFFER_COUNT 32
@@ -37,7 +43,11 @@ struct pvr2_ioread {
int enabled;
int stream_running;
int spigot_open;
- struct semaphore sem;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
+ struct mutex mutex;
+#else
+ struct semaphore mutex;
+#endif
};
static int pvr2_ioread_init(struct pvr2_ioread *cp)
@@ -45,7 +55,7 @@ static int pvr2_ioread_init(struct pvr2_ioread *cp)
unsigned int idx;
cp->stream = 0;
- init_MUTEX(&cp->sem);
+ mutex_init(&cp->mutex);
for (idx = 0; idx < BUFFER_COUNT; idx++) {
cp->buffer_storage[idx] = kmalloc(BUFFER_SIZE,GFP_KERNEL);
@@ -146,7 +156,7 @@ int pvr2_ioread_setup(struct pvr2_ioread *cp,struct pvr2_stream *sp)
unsigned int idx;
struct pvr2_buffer *bp;
- down(&cp->sem); do {
+ mutex_lock(&cp->mutex); do {
if (cp->stream) {
pvr2_trace(PVR2_TRACE_START_STOP,
"/*---TRACE_READ---*/"
@@ -171,7 +181,7 @@ int pvr2_ioread_setup(struct pvr2_ioread *cp,struct pvr2_stream *sp)
}
cp->stream = sp;
}
- } while (0); up(&cp->sem);
+ } while (0); mutex_unlock(&cp->mutex);
return 0;
}
@@ -181,13 +191,13 @@ int pvr2_ioread_set_enabled(struct pvr2_ioread *cp,int fl)
int ret = 0;
if ((!fl) == (!(cp->enabled))) return ret;
- down(&cp->sem); do {
+ mutex_lock(&cp->mutex); do {
if (fl) {
ret = pvr2_ioread_start(cp);
} else {
pvr2_ioread_stop(cp);
}
- } while (0); up(&cp->sem);
+ } while (0); mutex_unlock(&cp->mutex);
return ret;
}
@@ -249,7 +259,7 @@ int pvr2_ioread_read(struct pvr2_ioread *cp,void __user *buf,unsigned int cnt)
cp->stream_running = !0;
- down(&cp->sem); do {
+ mutex_lock(&cp->mutex); do {
// Suck data out of the buffers and copy to the user
copied_cnt = 0;
@@ -325,7 +335,7 @@ int pvr2_ioread_read(struct pvr2_ioread *cp,void __user *buf,unsigned int cnt)
}
}
- } while (0); up(&cp->sem);
+ } while (0); mutex_unlock(&cp->mutex);
if (!ret) {
if (copied_cnt) {