lkml.org 
[lkml]   [2005]   [Jun]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [patch 2/4] cdrom/aztcd: remove sleep_on() usage
domen@coderock.org wrote:
> From: Nishanth Aravamudan <nacc@us.ibm.com>
>
>
>
> Directly use wait-queues instead of the deprecated sleep_on().
> This required adding a local waitqueue. Patch is compile-tested.

IMHO this patch doesn't improve anything, it just makes the
code harder to read. sleep_on() is deprecated because there's
an inherent race between sleep_on() and wake_up(). To address
this you need to add a condition variable (e.g. AztStenLow) and
convert the code to use wait_event().
The timer trick used here makes it pretty hard to hit the
race, but with a preemptible kernel one could be preempted
between the SET_TIMER() and the sleep_on().

Johannes

> Signed-off-by: Nishanth Aravamudan <nacc@us.ibm.com>
> Signed-off-by: Domen Puncer <domen@coderock.org>
> ---
> aztcd.c | 6 +++++-
> 1 files changed, 5 insertions(+), 1 deletion(-)
>
> Index: quilt/drivers/cdrom/aztcd.c
> ===================================================================
> --- quilt.orig/drivers/cdrom/aztcd.c
> +++ quilt/drivers/cdrom/aztcd.c
> @@ -179,6 +179,7 @@
> #include <linux/ioport.h>
> #include <linux/string.h>
> #include <linux/major.h>
> +#include <linux/wait.h>
>
> #include <linux/init.h>
>
> @@ -429,9 +430,12 @@ static void dten_low(void)
> #define STEN_LOW_WAIT statusAzt()
> static void statusAzt(void)
> {
> + DEFINE_WAIT(wait);
> AztTimeout = AZT_STATUS_DELAY;
> SET_TIMER(aztStatTimer, HZ / 100);
> - sleep_on(&azt_waitq);
> + prepare_to_wait(&azt_waitq, &wait, TASK_UNINTERRUPTIBLE);
> + schedule();
> + finish_wait(&azt_waitq, &wait);
> if (AztTimeout <= 0)
> printk("aztcd: Error Wait STEN_LOW_WAIT command:%x\n",
> aztCmd);
>
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-06-21 12:05    [W:0.055 / U:0.128 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site