On Sat, Jan 16, 2021 at 10:41 PM Heiner Kallweit <hkallwe...@gmail.com> wrote: > >> > >> It seems unlikely that a system uses both, the parallel *and* the SPI > >> variant of the ks8851. So the additional memory necessary because of > >> code duplication wouldn't matter in practice. > > > > I have a board with both options populated on my desk, sorry. > > Making the common part a separate module shouldn't be that hard. > AFAICS it would just take: > - export 4 functions from common > - extend Kconfig > - extend Makefile > One similar configuration that comes to my mind and could be used as > template is SPI_FSL_LIB.
There is no need to even change Kconfig, just simplify the Makefile to obj-$(CONFIG_KS8851) += ks8851_common.o ks8851_spi.o obj-$(CONFIG_KS8851_MLL) += ks8851_common.o ks8851_par.o This will do the right thing and build ks8851_common.ko into vmlinux if at least one of the two front-ends is built-in, and otherwise build it at a loadable module if there is another module using it. Arnd