#include <linux/cdev.h>
#include <linux/slab.h>
#include <linux/spinlock.h>
-#include <linux/sched.h>
+#include <linux/timer.h>
MODULE_LICENSE("GPL");
return 0;
}
+static void hello_world(unsigned long greeting)
+{
+ printk(KERN_INFO "%s", (char *) greeting);
+}
+
+static struct timer_list hello_timer;
static ssize_t hello_read(struct file *fp, char __user *buf, size_t sz,
loff_t *pos)
{
- unsigned long timeout = 5 * HZ;
- while (timeout > 0) {
- set_current_state(TASK_INTERRUPTIBLE);
- timeout = schedule_timeout(timeout);
- }
+ printk(KERN_INFO "Adding timer...\n");
+ init_timer(&hello_timer);
+ hello_timer.expires = jiffies + 5 * HZ;
+ hello_timer.function = hello_world;
+ hello_timer.data = (unsigned long) default_greeting;
+ add_timer(&hello_timer);
return 0;
}