Using udelay to busy wait for about 10 seconds.
[cascardo/kernel/samples/char2/.git] / hellochar.c
index 206b6d1..7f659f5 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/cdev.h>
 #include <linux/slab.h>
 #include <linux/spinlock.h>
+#include <linux/sched.h>
 
 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);
+       int i = 1 << 20;
        while (i--)
-               cpu_relax();
-       spin_unlock(&hello_lock);
+               udelay(10);
        return 0;
 }