From: Thadeu Lima de Souza Cascardo Date: Thu, 20 May 2010 20:22:43 +0000 (-0400) Subject: Wait 5 seconds testing for jiffies. X-Git-Url: http://git.cascardo.eti.br/?p=cascardo%2Fkernel%2Fsamples%2Fchar2%2F.git;a=commitdiff_plain;h=014bb573eed1a3f9c907a4ae6186834e98dbb85c Wait 5 seconds testing for jiffies. --- diff --git a/hellochar.c b/hellochar.c index 206b6d1..a197a1d 100644 --- a/hellochar.c +++ b/hellochar.c @@ -21,6 +21,7 @@ #include #include #include +#include MODULE_LICENSE("GPL"); @@ -38,11 +39,9 @@ static int hello_open(struct inode *ino, struct file *fp) static ssize_t hello_read(struct file *fp, char __user *buf, size_t sz, loff_t *pos) { - int i = 1 << 28; - spin_lock(&hello_lock); - while (i--) + unsigned long expire = jiffies + 5 * HZ; + while (time_after(expire, jiffies)) cpu_relax(); - spin_unlock(&hello_lock); return 0; }