Skip to contentSkip to conversation

MBCS: Convert algolock to mutex

PATCH New [email protected] 1 participant 3 messages Oct 24, 2007 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 1/3 MBCS: Convert algolock to mutex

MBCS: Convert the semaphore algolock to the mutex API

linux-2.6/drivers/char/mbcs.c +4 -3
@@ -24,6 +24,7 @@
 #include <linux/mm.h>
 #include <linux/fs.h>
 #include <linux/uio.h>
+#include <linux/mutex.h>
 #include <asm/io.h>
 #include <asm/uaccess.h>
 #include <asm/system.h>
@@ -282,7 +283,7 @@
 	void *mmr_base = soft->mmr_base;
 	union cm_control cm_control;
 
-	if (down_interruptible(&soft->algolock))
+	if (mutex_lock_interruptible(&soft->algolock))
 		return -ERESTARTSYS;
 
 	atomic_set(&soft->algo_done, 0);
@@ -299,7 +300,7 @@
 	cm_control.alg_go = 1;
 	MBCS_MMR_SET(mmr_base, MBCS_CM_CONTROL, cm_control.cm_control_reg);
 
-	up(&soft->algolock);
+	mutex_unlock(&soft->algolock);
 
 	return 0;
 }
@@ -765,7 +766,7 @@
 
 	init_MUTEX(&soft->dmawritelock);
 	init_MUTEX(&soft->dmareadlock);
-	init_MUTEX(&soft->algolock);
+	mutex_init(&soft->algolock);
 
 	mbcs_getdma_init(&soft->getdma);
 	mbcs_putdma_init(&soft->putdma);
linux-2.6/drivers/char/mbcs.h +1 -1
Index: kernel/linux-2.6/drivers/char/mbcs.h
===================================================================
@@ -539,7 +539,7 @@
 	atomic_t algo_done;
 	struct semaphore dmawritelock;
 	struct semaphore dmareadlock;
-	struct semaphore algolock;
+	struct mutex algolock;
 };
 
 static int mbcs_open(struct inode *ip, struct file *fp);
Signature · 10 lines
Matthias Kaehlcke
Linux Application Developer
Barcelona

              We build too many walls and not enough bridges
                             (Isaac Newton)
                                                                 .''`.
    using free software / Debian GNU/Linux | http://debian.org  : :'  :
                                                                `. `'`
gpg --keyserver pgp.mit.edu --recv-keys 47D8E5D4                  `-
#2 lore raw

PATCH 2/3 MBCS: Convert dmawritelock to mutex

In reply to a message not in the archive

MBCS: Convert the semaphore dmawritelock to the mutex API

linux-2.6/drivers/char/mbcs.h +1 -1
Index: kernel/linux-2.6/drivers/char/mbcs.h
===================================================================
@@ -537,7 +537,7 @@
 	atomic_t dmawrite_done;
 	atomic_t dmaread_done;
 	atomic_t algo_done;
-	struct semaphore dmawritelock;
+	struct mutex dmawritelock;
 	struct semaphore dmareadlock;
 	struct mutex algolock;
 };
linux-2.6/drivers/char/mbcs.c +3 -3
Index: kernel/linux-2.6/drivers/char/mbcs.c
===================================================================
@@ -311,7 +311,7 @@
 {
 	int rv = 0;
 
-	if (down_interruptible(&soft->dmawritelock))
+	if (mutex_lock_interruptible(&soft->dmawritelock))
 		return -ERESTARTSYS;
 
 	atomic_set(&soft->dmawrite_done, 0);
@@ -337,7 +337,7 @@
 	*off += len;
 
 dmawrite_exit:
-	up(&soft->dmawritelock);
+	mutex_unlock(&soft->dmawritelock);
 
 	return rv;
 }
@@ -764,7 +764,7 @@
 	init_waitqueue_head(&soft->dmaread_queue);
 	init_waitqueue_head(&soft->algo_queue);
 
-	init_MUTEX(&soft->dmawritelock);
+	mutex_init(&soft->dmawritelock);
 	init_MUTEX(&soft->dmareadlock);
 	mutex_init(&soft->algolock);
 
Signature · 10 lines
Matthias Kaehlcke
Linux Application Developer
Barcelona

              We build too many walls and not enough bridges
                             (Isaac Newton)
                                                                 .''`.
    using free software / Debian GNU/Linux | http://debian.org  : :'  :
                                                                `. `'`
gpg --keyserver pgp.mit.edu --recv-keys 47D8E5D4                  `-
#3 lore raw

PATCH 3/3 MBCS: Convert dmareadlock to mutex

In reply to a message not in the archive

MBCS: Convert the semaphore dmareadlock to the mutex API

linux-2.6/drivers/char/mbcs.c +3 -3
@@ -348,7 +348,7 @@
 {
 	int rv = 0;
 
-	if (down_interruptible(&soft->dmareadlock))
+	if (mutex_lock_interruptible(&soft->dmareadlock))
 		return -ERESTARTSYS;
 
 	atomic_set(&soft->dmawrite_done, 0);
@@ -373,7 +373,7 @@
 	*off += len;
 
 dmaread_exit:
-	up(&soft->dmareadlock);
+	mutex_unlock(&soft->dmareadlock);
 
 	return rv;
 }
@@ -765,7 +765,7 @@
 	init_waitqueue_head(&soft->algo_queue);
 
 	mutex_init(&soft->dmawritelock);
-	init_MUTEX(&soft->dmareadlock);
+	mutex_init(&soft->dmareadlock);
 	mutex_init(&soft->algolock);
 
 	mbcs_getdma_init(&soft->getdma);
linux-2.6/drivers/char/mbcs.h +1 -1
Index: kernel/linux-2.6/drivers/char/mbcs.h
===================================================================
@@ -538,7 +538,7 @@
 	atomic_t dmaread_done;
 	atomic_t algo_done;
 	struct mutex dmawritelock;
-	struct semaphore dmareadlock;
+	struct mutex dmareadlock;
 	struct mutex algolock;
 };
 
Signature · 10 lines
Matthias Kaehlcke
Linux Application Developer
Barcelona

              We build too many walls and not enough bridges
                             (Isaac Newton)
                                                                 .''`.
    using free software / Debian GNU/Linux | http://debian.org  : :'  :
                                                                `. `'`
gpg --keyserver pgp.mit.edu --recv-keys 47D8E5D4                  `-