So I am learning to write device drivers and wrote this simple one:
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/module.h>
static int __init gotemp_init(void)
{
printk(KERN_DEBUG "Hello world");
return 0;
}
static void __exit gotemp_exit(void)
{
}
module_init(gotemp_init);
module_exit(gotemp_exit);
MODULE_AUTHOR("Abhinav Jain");
MODULE_DESCRIPTION("Simple driver");
MODULE_LICENSE("GPL");
And the makefile is this:
obj-m := hello.o
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
all:
$(MAKE) -C $(KERNELDIR) M=$(PWD)
But the output of dmesg
does not print the "Hello world"
.
I also tried KERN_INFO
but still the same results although the lsmod
shows the module hello
being loaded.
So why is the message not being logged?