Change dm-daemon.c to use completions rather than semaphores.
[Mike Christie]
--- diff/drivers/md/dm-daemon.c	2003-12-29 10:16:08.000000000 +0000
+++ source/drivers/md/dm-daemon.c	2003-12-29 10:16:22.000000000 +0000
@@ -10,6 +10,7 @@
 #include <linux/module.h>
 #include <linux/sched.h>
 #include <linux/suspend.h>
+#include <linux/completion.h>
 
 static int daemon(void *arg)
 {
@@ -22,8 +23,7 @@
 
 	add_wait_queue(&dd->job_queue, &wq);
 
-	down(&dd->run_lock);
-	up(&dd->start_lock);
+	complete(&dd->start);
 
 	/*
 	 * dd->fn() could do anything, very likely it will
@@ -55,8 +55,7 @@
 
  out:
 	remove_wait_queue(&dd->job_queue, &wq);
-	up(&dd->run_lock);
-	return 0;
+	complete_and_exit(&dd->run, 0);
 }
 
 int dm_daemon_start(struct dm_daemon *dd, const char *name, jiffy_t (*fn)(void))
@@ -68,14 +67,13 @@
 	 */
 	dd->fn = fn;
 	strncpy(dd->name, name, sizeof(dd->name) - 1);
-	sema_init(&dd->start_lock, 1);
-	sema_init(&dd->run_lock, 1);
+	init_completion(&dd->start);
+	init_completion(&dd->run);
 	init_waitqueue_head(&dd->job_queue);
 
 	/*
 	 * Start the new thread.
 	 */
-	down(&dd->start_lock);
 	pid = kernel_thread(daemon, dd, CLONE_KERNEL);
 	if (pid <= 0) {
 		DMERR("Failed to start %s thread", name);
@@ -85,8 +83,7 @@
 	/*
 	 * wait for the daemon to up this mutex.
 	 */
-	down(&dd->start_lock);
-	up(&dd->start_lock);
+	wait_for_completion(&dd->start);
 
 	return 0;
 }
@@ -95,8 +92,7 @@
 {
 	atomic_set(&dd->please_die, 1);
 	dm_daemon_wake(dd);
-	down(&dd->run_lock);
-	up(&dd->run_lock);
+	wait_for_completion(&dd->run);
 }
 
 void dm_daemon_wake(struct dm_daemon *dd)
--- diff/drivers/md/dm-daemon.h	2003-12-29 10:16:08.000000000 +0000
+++ source/drivers/md/dm-daemon.h	2003-12-29 10:16:22.000000000 +0000
@@ -8,7 +8,7 @@
 #define DM_DAEMON_H
 
 #include <asm/atomic.h>
-#include <asm/semaphore.h>
+#include <linux/completion.h>
 
 /*
  * The daemons work function returns a *hint* as to when it
@@ -18,8 +18,8 @@
 	jiffy_t (*fn)(void);
 	char name[16];
 	atomic_t please_die;
-	struct semaphore start_lock;
-	struct semaphore run_lock;
+	struct completion start;
+	struct completion run;
 
 	atomic_t woken;
 	wait_queue_head_t job_queue;