public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Domen Puncer <domen@coderock.org>
To: akpm@osdl.org
Cc: linux-kernel@vger.kernel.org, emoenke@gwdg.de,
	linux@rainbow-software.org, domen@coderock.org
Subject: Re: [patch 3/3] cdrom/cdu31a update
Date: Sun, 13 Mar 2005 17:33:48 +0100 (CET)	[thread overview]
Message-ID: <20050313163348.190F91E3E1@trashy.coderock.org> (raw)
In-Reply-To: <20050313163330.171476@nd47.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>

--- ./drivers/cdrom/cdu31a.c.orig3	2005-03-06 22:04:42.000000000 +0100
+++ ./drivers/cdrom/cdu31a.c	2005-03-12 14:40:14.000000000 +0100
@@ -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

      parent reply	other threads:[~2005-03-13 16:40 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-03-13 16:33 [patch 0/3] cdrom/cdu31a update Domen Puncer
2005-03-13 16:33 ` [patch 1/3] " Domen Puncer
2005-03-13 16:33 ` [patch 2/3] " Domen Puncer
2005-03-13 16:33 ` Domen Puncer [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050313163348.190F91E3E1@trashy.coderock.org \
    --to=domen@coderock.org \
    --cc=akpm@osdl.org \
    --cc=emoenke@gwdg.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@rainbow-software.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox