|
loding Kernel module with multiple source files
Hi All
I have a problem in loading the kernel module that is multiple source file.
At this stage its a plain kernel module having init and exit and one function that is beeing called from init module for showing the version .
To have 1 file for my module it works fine but if I have multiple
source files it compiles but it gives tainted message and init function is not getting invoked at all while loading the module.
i have file1.c file2.c file1.h and Makefile
following is my makefile
ifneq ($(KERNELRELEASE),)
obj-m := file1.o
file1-objs := file1.o file2.o
else
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
PWD :=$(shell pwd)
default:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
endif
clean:
rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions
following is my file1.c
#include <linux/init.h>
#include <linux/module.h>
#include "file1.h"
MODULE_LICENSE("Dual BSD/GPL");
static int hello_init(void)
{
printk(KERN_ALERT "Hello world \n");
show_version();
return 0;
}
static void hello_exit(void)
{
printk(KERN_ALERT "Goodbye, cruel world \n");
}
module_init(hello_init);
module_exit(hello_exit);
following is my file1.h
#ifndef _FILE1_H_
#define _FILEL1_H_
#define version "1.0"
void show_version(void);
#endif
following is my file2.c
#include <linux/kernel.h>
#include "file1.h"
void show_version(void)
{
printk(KERN_ALERT "Version is:%s \n",version);
}
Please help me in solving this problem any help will be greatly appreciated.
|