From: Domen Puncer <domen@coderock.org>

Use wait_event instead of sleep_on.
Also, remove two unused variables.

Signed-off-by: Domen Puncer <domen@coderock.org>
Acked-by: Ondrej Zary <linux@rainbow-software.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 25-akpm/drivers/cdrom/cdu31a.c |   42 +++++++++++++++++++++++++----------------
 1 files changed, 26 insertions(+), 16 deletions(-)

diff -puN drivers/cdrom/cdu31a.c~cdrom-cdu31a-use-wait_event drivers/cdrom/cdu31a.c
--- 25/drivers/cdrom/cdu31a.c~cdrom-cdu31a-use-wait_event	2005-03-13 14:01:49.000000000 -0800
+++ 25-akpm/drivers/cdrom/cdu31a.c	2005-03-13 14:01:49.000000000 -0800
@@ -264,15 +264,8 @@ static int sony_toc_read = 0;	/* Has the
 static struct s_sony_subcode last_sony_subcode;	/* Points to the last
 						   subcode address read */
 
-static volatile int sony_inuse = 0;	/* Is the drive in use?  Only one operation
-					   at a time allowed */
-
 static DECLARE_MUTEX(sony_sem);		/* Semaphore for drive hardware access */
 
-static struct task_struct *has_cd_task = NULL;	/* The task that is currently
-						   using the CDROM drive, or
-						   NULL if none. */
-
 static int is_double_speed = 0;	/* does the drive support double speed ? */
 
 static int is_auto_eject = 1;	/* Door has been locked? 1=No/0=Yes */
@@ -300,6 +293,7 @@ module_param(cdu31a_irq, int, 0);
 /* The interrupt handler will wake this queue up when it gets an
    interrupts. */
 DECLARE_WAIT_QUEUE_HEAD(cdu31a_irq_wait);
+static int irq_flag = 0;
 
 static int curr_control_reg = 0;	/* Current value of the control register */
 
@@ -376,17 +370,31 @@ static inline void disable_interrupts(vo
  */
 static inline void sony_sleep(void)
 {
-	unsigned long flags;
-
 	if (cdu31a_irq <= 0) {
 		yield();
 	} else {		/* Interrupt driven */
+		DEFINE_WAIT(w);
+		int first = 1;
+
+		while (1) {
+			prepare_to_wait(&cdu31a_irq_wait, &w,
+					TASK_INTERRUPTIBLE);
+			if (first) {
+				enable_interrupts();
+				first = 0;
+			}
 
-		save_flags(flags);
-		cli();
-		enable_interrupts();
-		interruptible_sleep_on(&cdu31a_irq_wait);
-		restore_flags(flags);
+			if (irq_flag != 0)
+				break;
+			if (!signal_pending(current)) {
+				schedule();
+				continue;
+			} else
+				disable_interrupts();
+			break;
+		}
+		finish_wait(&cdu31a_irq_wait, &w);
+		irq_flag = 0;
 	}
 }
 
@@ -530,11 +538,13 @@ static irqreturn_t cdu31a_interrupt(int 
 		/* If something was waiting, wake it up now. */
 		if (waitqueue_active(&cdu31a_irq_wait)) {
 			disable_interrupts();
-			wake_up(&cdu31a_irq_wait);
+			irq_flag = 1;
+			wake_up_interruptible(&cdu31a_irq_wait);
 		}
 	} else if (waitqueue_active(&cdu31a_irq_wait)) {
 		disable_interrupts();
-		wake_up(&cdu31a_irq_wait);
+		irq_flag = 1;
+		wake_up_interruptible(&cdu31a_irq_wait);
 	} else {
 		disable_interrupts();
 		printk(KERN_NOTICE PFX
_