The goal is to put an existing (in-source kernel) device driver into an external kernel module. The device driver is put together into a struct platform_driver
instance, then is registered with module_platform_driver()
macro. The macro is supposed to be implementing the module_init()
and module_exit()
functions necessary for a Linux kernel module definition, however with below Makefile
Yocto throws multiple errors, one of them being: aarch64-poky-linux-ld.bfd: no input files
The Makefile:
obj-m += my-mod-lkm.o
my-mod-lkm-y := my-mod.c
SRC := $(shell pwd)
all:
$(MAKE) -C $(KERNEL_SRC) M=$(SRC) modules
modules_install:
$(MAKE) -C $(KERNEL_SRC) M=$(SRC) modules_install
clean:
$(MAKE) -C $(KERNEL_SRC) M=$(SRC) clean
Does Yocto not support the module_init
/module_exit
macros? I noticed that it does compile a simple module:
#include <linux/module.h> /* Needed by all modules */
#include <linux/kernel.h>
#include <linux/printk.h> /* Needed for pr_info() */
int init_module(void)
{
pr_info("My module initiated!");
return 0;
}
void cleanup_module(void)
{
pr_info("My module exited!");
}
MODULE_LICENSE("GPL");
Why would the latter work and the more recent way of using module_init()
/ module_exit()
not? Is it right to assume that simple call to module_platform_driver()
is enough to put a platform_driver
into a kernel module?