How to define a function in one linux kernel module and use it in another?

linux-kernel

Solution

Define it in `module1.c`:

#include <linux/module.h>

int fun(void);
EXPORT_SYMBOL(fun);

int fun(void)
{
    /* ... */
}

And use it in `module2.c`:

extern int fun(void);

Problem

I developed two simple modules to the kernel. Now i want to define a function in one module and after that use it in the other. How i can do that? Just define the function and caller in the other module without problems?

Original source

Related problems