[Cbe-oss-dev] [PATCH] spufs: turn run_sema into run_mutex

Christoph Hellwig hch at lst.de
Mon Apr 16 05:32:21 EST 2007


There is no reason for run_sema to be a struct semaphore.  Chaing
it to a mutex and rename it accordingly.


Signed-off-by: Christoph Hellwig <hch at lst.de>

Index: linux-2.6/arch/powerpc/platforms/cell/spufs/context.c
===================================================================
--- linux-2.6.orig/arch/powerpc/platforms/cell/spufs/context.c	2007-04-15 19:49:46.000000000 +0200
+++ linux-2.6/arch/powerpc/platforms/cell/spufs/context.c	2007-04-15 19:49:49.000000000 +0200
@@ -43,7 +43,7 @@ struct spu_context *alloc_spu_context(st
 	spin_lock_init(&ctx->mapping_lock);
 	kref_init(&ctx->kref);
 	mutex_init(&ctx->state_mutex);
-	init_MUTEX(&ctx->run_sema);
+	mutex_init(&ctx->run_mutex);
 	init_waitqueue_head(&ctx->ibox_wq);
 	init_waitqueue_head(&ctx->wbox_wq);
 	init_waitqueue_head(&ctx->stop_wq);
Index: linux-2.6/arch/powerpc/platforms/cell/spufs/run.c
===================================================================
--- linux-2.6.orig/arch/powerpc/platforms/cell/spufs/run.c	2007-04-15 19:49:41.000000000 +0200
+++ linux-2.6/arch/powerpc/platforms/cell/spufs/run.c	2007-04-15 19:49:49.000000000 +0200
@@ -293,7 +293,7 @@ long spufs_run_spu(struct file *file, st
 	struct spu * spu;
 	u32 status;
 
-	if (down_interruptible(&ctx->run_sema))
+	if (mutex_lock_interruptible(&ctx->run_mutex))
 		return -ERESTARTSYS;
 
 	ctx->ops->master_start(ctx);
@@ -377,6 +377,6 @@ out2:
 
 out:
 	*event = ctx->event_return;
-	up(&ctx->run_sema);
+	mutex_unlock(&ctx->run_mutex);
 	return ret;
 }
Index: linux-2.6/arch/powerpc/platforms/cell/spufs/spufs.h
===================================================================
--- linux-2.6.orig/arch/powerpc/platforms/cell/spufs/spufs.h	2007-04-15 19:49:46.000000000 +0200
+++ linux-2.6/arch/powerpc/platforms/cell/spufs/spufs.h	2007-04-15 19:49:49.000000000 +0200
@@ -61,7 +61,7 @@ struct spu_context {
 
 	enum { SPU_STATE_RUNNABLE, SPU_STATE_SAVED } state;
 	struct mutex state_mutex;
-	struct semaphore run_sema;
+	struct mutex run_mutex;
 
 	struct mm_struct *owner;
 



More information about the cbe-oss-dev mailing list