dde_linux: enhance KBUILD_MODNAME generation

It turns out solely relying on the name of the compilation-unit
is not enough. In at least one multi-device driver, e.g. rtlwifi,
an equally called compilation-unit is found in several different
directories. There KBUILD_MODNAME is used to name the driver,
which fails later on as the driver framework refuses to register
an equally named driver twice.

Instead of only considering the name of the compilation-unit also
include the last element of the path to generate differentiating
KBUILD_MODNAME value.

Issue #4861.
This commit is contained in:
Josef Söntgen 2023-05-20 19:33:45 +00:00 committed by Christian Helmuth
parent 0e82322605
commit dc178e0ab2

View File

@ -160,9 +160,16 @@ vpath %.S $(LX_GEN_DIR)
CUSTOM_TARGET_DEPS += $(TARGET_SOURCE_LIST)
# Define helper to generate unique KBUILD_MODNAME from filename and the
# last path element as using the file name is not enough for certain
# drivers (e.g., rtlwifi)
define GEN_KBUILD_MODNAME =
$(lastword $(subst /, ,$(dir $(1))))-$(notdir $(1))
endef
# Define per-compilation-unit CC_OPT defines needed by MODULE* macros in Linux
define CC_OPT_LX_RULES =
CC_OPT_$(1) += -DKBUILD_MODFILE='"$(1)"' -DKBUILD_BASENAME='"$(notdir $(1))"' -DKBUILD_MODNAME='"$(notdir $(1))"'
CC_OPT_$(1) += -DKBUILD_MODFILE='"$(1)"' -DKBUILD_BASENAME='"$(notdir $(1))"' -DKBUILD_MODNAME='"$(call GEN_KBUILD_MODNAME,$(1))"'
endef
$(foreach file,$(LX_SRC),$(eval $(call CC_OPT_LX_RULES,$(file:%.c=%))))