#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include "test.h"
MODULE_LICENSE("Dual BSD/GPL");
static int hello_init(void) {
printk("DRIVER LOADED\n");
printk("DRIVER INIT\n");
printk("result : %d",add(12,234));
return 0;
}
static void hello_exit(void) {
printk("DRIVER REMOVED\n");
}
module_init(hello_init);
module_exit(hello_exit);
here the add function output doesn't print by printk when the insmod issuing I am a fresh ldd lerner, plz can anybody help me to understand why this happening?
my test.c containing the following function body
int add(int a , int b){
return a+b;
}
and Makefile is as follows
obj-m = initial.o
all:
make -C /lib/modules/$(shell uname -r)/build/ M=$(PWD) modules
clean:
make -C /lib/modules/$(shell uname -r)/build/ M=$(PWD) clean
and my output shows:
Aug 16 11:15:44 beaglebone kernel: [13616.191741] DRIVER LOADED
Aug 16 11:15:44 beaglebone kernel: [13616.191758] DRIVER INIT
Aug 16 11:15:47 beaglebone kernel: [13616.191784] result : 246
Aug 16 11:15:47 beaglebone kernel: [13619.465555] DRIVER REMOVED