name and types

* scope all the function names
* fix the fibonacci type to a long
* variablize the fib input and print it out
This commit is contained in:
Vincent Batts 2014-09-17 17:03:42 -04:00
parent e929dbcb6f
commit b090072939
1 changed files with 22 additions and 16 deletions

View File

@ -3,15 +3,15 @@
#include <linux/kallsyms.h>
static char __initdata hellomsg[] = KERN_NOTICE "Hello, Kernel, I'm in\n";
static char __exitdata byemsg[] = KERN_NOTICE "Bye, I'm out\n";
static char __initdata hello_hellomsg[] = KERN_NOTICE "Hello, Kernel, I'm in\n";
static char __exitdata hello_byemsg[] = KERN_NOTICE "Bye, I'm out\n";
static int print_hello(void)
static int hello_print_hello(void)
{
unsigned long i;
char *symbol_name;
printk(hellomsg);
printk(hello_hellomsg);
symbol_name = "free_pages";
printk("looking up '%s'\n", symbol_name);
@ -21,12 +21,12 @@ static int print_hello(void)
return 0;
}
int fib(int times, int n1, int n2)
long hello_fib(long times, long n1, long n2)
{
int i = 0;
int prev = n1;
int curr = n2;
int next = 0;
long i = 0;
long prev = n1;
long curr = n2;
long next = 0;
while (i < times)
{
@ -41,24 +41,30 @@ int fib(int times, int n1, int n2)
static int __init start_hello_world(void)
{
int f_int;
long f_int, f_cap, f_start1, f_start2;
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Vincent Batts <vbatts@hashbangbash.com>");
MODULE_DESCRIPTION("i am just reading headers");
MODULE_DESCRIPTION("just getting familiar");
MODULE_VERSION("1.0");
print_hello();
hello_print_hello();
f_int = fib(10000000, 0, 1);
f_cap = 10000000;
f_start1 = 0;
f_start2 = 1;
f_int = hello_fib(f_cap, f_start1, f_start2);
printk("fib of %ld and %ld (up to %ld): %ld\n", f_start1, f_start2, f_cap, f_int);
return 0;
}
static void __exit go_away(void)
static void __exit hello_go_away(void)
{
printk(byemsg);
printk(hello_byemsg);
}
module_init(start_hello_world);
module_exit(go_away);
module_exit(hello_go_away);
// vim:set shiftwidth=4 softtabstop=4 expandtab: