2 * Copyright (C) 2010 Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #include <linux/module.h>
21 #include <linux/moduleparam.h>
22 #include <linux/init.h>
23 #include <linux/kernel.h>
24 #include <linux/slab.h>
26 MODULE_LICENSE("GPL");
27 MODULE_AUTHOR("Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>");
28 MODULE_DESCRIPTION("Hello, world");
31 module_param_named(size, size, int, S_IRUGO | S_IWUSR);
38 static struct hello *hello;
40 static char default_greeting[] = "Hello, world!\n";
42 static int hello_init(void)
44 hello = kmalloc(sizeof(*hello) + sizeof(default_greeting), GFP_KERNEL);
47 memcpy(hello->greeting, default_greeting, sizeof(default_greeting));
48 printk("%s\n", hello->greeting);
49 printk("%p %p %p\n", hello, hello->greeting,
50 container_of(&hello->greeting, struct hello, greeting));
51 printk("size %d\n", ARRAY_SIZE(default_greeting));
55 static __exit void hello_exit(void)
60 module_init(hello_init);
61 module_exit(hello_exit);