Your actual problem is that you want to configure something in your module.
Reading a configuration file does not solve that problem, it just introduces another problem.
To configure something in your module, use a module parameter:
#include <linux/kernel.h>
#include <linux/module.h>
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Sefu");
static char *my_param = "default";
module_param(my_param, charp, 0444);
MODULE_PARM_DESC(my_param, "my little configuration string");
int init_module(void)
{
printk(KERN_INFO "The parameter is: %s\n", my_param);
return 0;
}
void cleanup_module(void)
{
}
To set that value, load your module with something like
modprobe mymodule my_param=whatever
or put this line into some .conf file in /etc/modprobe.d/
:
options mymodule my_param=whatever