From dc178e0ab24bf2f67e63fde033531525860c09a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josef=20S=C3=B6ntgen?= Date: Sat, 20 May 2023 19:33:45 +0000 Subject: [PATCH] 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. --- repos/dde_linux/lib/import/import-lx_emul_common.inc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/repos/dde_linux/lib/import/import-lx_emul_common.inc b/repos/dde_linux/lib/import/import-lx_emul_common.inc index 2be8a0e3bb..fca29292a5 100644 --- a/repos/dde_linux/lib/import/import-lx_emul_common.inc +++ b/repos/dde_linux/lib/import/import-lx_emul_common.inc @@ -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=%))))