I'm trying to write a kernel module for a display but I'm struggling with the basics.
If I try to separate source files and define this in Makefile via -objs, the kernel module gets compiled, load, but doesnt do anything.
Code:
driver.c
#define LINUX
#include <linux/module.h>
#include <linux/kernel.h>
#include "display.h"
int init_module(void) {
printk(KERN_INFO "module registered\n");
init_display();
return 0;
}
void cleanup_module(void) {
printk(KERN_INFO "module unregistered\n");
}
display.h
#ifndef DISPLAY_H
#define DISPLAY_H
void init_display (void);
#endif
display.c
#include "display.h"
#include <linux/module.h> /* Needed by all modules */
#include <linux/kernel.h> /* Needed for KERN_ALERT */
void init_display (void) {
printk(KERN_INFO "initialize display\n");
}
Makefile
obj-m := driver.o
driver-objs := driver.o display.o
KDIR := /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
default:
$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
clean:
$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) clean
Without the include and driver-objs in Makefile I'm getting the KERN_INFO (load, unload) output, with it, the kernellog is empty.
Any directions, what I'm doing wrong?