On Sat, Jan 16, 2021 at 5:48 PM Marek Vasut <ma...@denx.de> wrote: > > When either the SPI or PAR variant is compiled as module AND the other > variant is compiled as built-in, the following build error occurs: > > arm-linux-gnueabi-ld: drivers/net/ethernet/micrel/ks8851_common.o: in > function `ks8851_probe_common': > ks8851_common.c:(.text+0x1564): undefined reference to `__this_module' > > Fix this by passing THIS_MODULE as argument to ks8851_probe_common(), > ks8851_register_mdiobus(), and ultimately __mdiobus_register() in the > ks8851_common.c. > > Fixes: ef3631220d2b ("net: ks8851: Register MDIO bus and the internal PHY") > Signed-off-by: Marek Vasut <ma...@denx.de> > Cc: Andrew Lunn <and...@lunn.ch> > Cc: Arnd Bergmann <a...@arndb.de> > Cc: Heiner Kallweit <hkallwe...@gmail.com> > Cc: Jakub Kicinski <k...@kernel.org> > Cc: Lukas Wunner <lu...@wunner.de>
I don't really like this version, as it does not actually solve the problem of linking the same object file into both vmlinux and a loadable module, which can have all kinds of side-effects besides that link failure you saw. If you want to avoid exporting all those symbols, a simpler hack would be to '#include "ks8851_common.c" from each of the two files, which then always duplicates the contents (even when both are built-in), but at least builds the file the correct way. Arnd