From 0c9b6491714c60c3d9575ba354f249f15ec43e17 Mon Sep 17 00:00:00 2001 From: Peter Colberg Date: Mon, 9 Dec 2024 14:16:17 -0500 Subject: [PATCH] backport: fix EXPORT_SYMBOL_NS_GPL() with Linux 6.13 The macro EXPORT_SYMBOL_NS_GPL() no longer stringifies its argument since commit cdd30ebb1b9f ("module: Convert symbol namespace to string literal"), which must now be done by the caller. Fixes: 7613542d6dda ("backport: Add definitions for module namespace") Signed-off-by: Peter Colberg --- drivers/mfd/intel-m10-bmc-core.c | 10 +++++----- include/linux/export.h | 24 +++++++++++++++++++++++- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/drivers/mfd/intel-m10-bmc-core.c b/drivers/mfd/intel-m10-bmc-core.c index 742819de..c5495b62 100644 --- a/drivers/mfd/intel-m10-bmc-core.c +++ b/drivers/mfd/intel-m10-bmc-core.c @@ -22,7 +22,7 @@ void m10bmc_fw_state_set(struct intel_m10bmc *m10bmc, enum m10bmc_fw_state new_s m10bmc->bmcfw_state = new_state; up_write(&m10bmc->bmcfw_lock); } -EXPORT_SYMBOL_NS_GPL(m10bmc_fw_state_set, INTEL_M10_BMC_CORE); +EXPORT_SYMBOL_NS_GPL(m10bmc_fw_state_set, "INTEL_M10_BMC_CORE"); /* * For some Intel FPGA devices, the BMC firmware is not available to service @@ -76,7 +76,7 @@ int m10bmc_sys_read(struct intel_m10bmc *m10bmc, unsigned int offset, unsigned i return ret; } -EXPORT_SYMBOL_NS_GPL(m10bmc_sys_read, INTEL_M10_BMC_CORE); +EXPORT_SYMBOL_NS_GPL(m10bmc_sys_read, "INTEL_M10_BMC_CORE"); int m10bmc_sys_update_bits(struct intel_m10bmc *m10bmc, unsigned int offset, unsigned int msk, unsigned int val) @@ -96,7 +96,7 @@ int m10bmc_sys_update_bits(struct intel_m10bmc *m10bmc, unsigned int offset, return ret; } -EXPORT_SYMBOL_NS_GPL(m10bmc_sys_update_bits, INTEL_M10_BMC_CORE); +EXPORT_SYMBOL_NS_GPL(m10bmc_sys_update_bits, "INTEL_M10_BMC_CORE"); static ssize_t bmc_version_show(struct device *dev, struct device_attribute *attr, char *buf) @@ -184,7 +184,7 @@ const struct attribute_group *m10bmc_dev_groups[] = { &m10bmc_group, NULL, }; -EXPORT_SYMBOL_NS_GPL(m10bmc_dev_groups, INTEL_M10_BMC_CORE); +EXPORT_SYMBOL_NS_GPL(m10bmc_dev_groups, "INTEL_M10_BMC_CORE"); int m10bmc_dev_init(struct intel_m10bmc *m10bmc, const struct intel_m10bmc_platform_info *info) { @@ -202,7 +202,7 @@ int m10bmc_dev_init(struct intel_m10bmc *m10bmc, const struct intel_m10bmc_platf return ret; } -EXPORT_SYMBOL_NS_GPL(m10bmc_dev_init, INTEL_M10_BMC_CORE); +EXPORT_SYMBOL_NS_GPL(m10bmc_dev_init, "INTEL_M10_BMC_CORE"); MODULE_DESCRIPTION("Intel MAX 10 BMC core driver"); MODULE_AUTHOR("Intel Corporation"); diff --git a/include/linux/export.h b/include/linux/export.h index 73da66f0..2c1924ca 100644 --- a/include/linux/export.h +++ b/include/linux/export.h @@ -5,8 +5,30 @@ #include #include_next -#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0) && RHEL_RELEASE_CODE < 0x900 +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0) #define EXPORT_SYMBOL_NS_GPL(sym, ns) EXPORT_SYMBOL_GPL(sym) +#elif LINUX_VERSION_CODE < KERNEL_VERSION(5, 5, 0) +/* The macro EXPORT_SYMBOL_NS_GPL() called __EXPORT_SYMBOL_NS() + * before commit c3a6cf19e695 ("export: avoid code duplication in + * include/linux/export.h"), which merged __EXPORT_SYMBOL_NS() + * into __EXPORT_SYMBOL(). + */ +#undef EXPORT_SYMBOL_NS_GPL +#define EXPORT_SYMBOL_NS_GPL(sym, ns) __EXPORT_SYMBOL_NS(sym, "_gpl", ns) +#elif LINUX_VERSION_CODE < KERNEL_VERSION(6, 4, 0) && RHEL_RELEASE_CODE < 0x905 +/* The macro EXPORT_SYMBOL_NS_GPL() passed the license string "_gpl" + * to __EXPORT_SYMBOL() before commit ddb5cdbafaaa ("kbuild: generate + * KSYMTAB entries by modpost"), after which it passes "GPL" instead. + */ +#undef EXPORT_SYMBOL_NS_GPL +#define EXPORT_SYMBOL_NS_GPL(sym, ns) __EXPORT_SYMBOL(sym, "_gpl", ns) +#elif LINUX_VERSION_CODE < KERNEL_VERSION(6, 13, 0) +/* The macro EXPORT_SYMBOL_NS_GPL() no longer stringifies its argument + * since commit cdd30ebb1b9f ("module: Convert symbol namespace to + * string literal"), which must now be done by the caller. + */ +#undef EXPORT_SYMBOL_NS_GPL +#define EXPORT_SYMBOL_NS_GPL(sym, ns) __EXPORT_SYMBOL(sym, "GPL", ns) #endif #endif