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");
35 static struct hello *hello;
37 static char default_greeting[] = "Hello, world!\n";
39 static int hello_init(void)
41 hello = kmalloc(sizeof(*hello) + sizeof(default_greeting), GFP_KERNEL);
44 memcpy(hello->greeting, default_greeting, sizeof(default_greeting));
45 printk("%s\n", hello->greeting);
46 printk("%p %p %p\n", hello, hello->greeting,
47 container_of(&hello->greeting, struct hello, greeting));
48 printk("size %d\n", ARRAY_SIZE(default_greeting));
52 static __exit void hello_exit(void)
57 module_init(hello_init);
58 module_exit(hello_exit);