Use DEFINE_TIMER. timer
authorThadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Fri, 21 May 2010 14:09:33 +0000 (10:09 -0400)
committerThadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Fri, 21 May 2010 14:09:33 +0000 (10:09 -0400)
hellochar.c

index b5cae85..d8adcf9 100644 (file)
@@ -27,7 +27,7 @@ MODULE_LICENSE("GPL");
 
 static dev_t devnum;
 static struct cdev *dev;
-static const char default_greeting[] = "Hello, World!\n";
+static const char def_greeting[] = "Hello, World!\n";
 
 static DEFINE_SPINLOCK(hello_lock);
 
@@ -41,15 +41,13 @@ static void hello_world(unsigned long greeting)
        printk(KERN_INFO "%s", (char *) greeting);
 }
 
-static struct timer_list hello_timer;
+static DEFINE_TIMER(hello_timer, hello_world, 0, def_greeting);
+
 static ssize_t hello_read(struct file *fp, char __user *buf, size_t sz,
        loff_t *pos)
 {
        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;
 }