Re: [PATCH v2 1/2] net: ethernet: i40e: fix build error
From: Andrew Lunn
Date: Thu Sep 06 2018 - 14:03:34 EST
> I'm more worried about how it interacts with modules. For example,
> we could have i40e and i40evf share some code, but then wouldn't one
> of them become dependent on the other? i.e. you'd have to load i40e
> in order to successfully load i40evf? Or you'd have to have some
> sort of common glue module which you load first, and then load i40e
> and i40evf after? This also creates some interactions with
> out-of-tree modules which make it difficult. It would be nice if we
> could share the code in some way that still resulted in allowing
> each module to be separate...
You have a few options here.
1) A library module, containing shared code. Use EXPORT_SYMBOL_GPL()
in the library module, and the kernel runtime linker will link the
calls into the library. Also, modprobe will ensure the library module
is loaded first, before the driver module.
2) Build time sharing of code. Place the shared code into a .o file,
and link it to both modules.
There is nothing particularly difficult here, this all done lots of
times within the kernel. Just look around and see how others do it.
Andrew