]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
module: Rename MAX_PARAM_PREFIX_LEN to __MODULE_NAME_LEN
authorPetr Pavlu <petr.pavlu@suse.com>
Mon, 30 Jun 2025 14:32:36 +0000 (16:32 +0200)
committerDaniel Gomez <da.gomez@samsung.com>
Thu, 31 Jul 2025 11:57:47 +0000 (13:57 +0200)
The maximum module name length (MODULE_NAME_LEN) is somewhat confusingly
defined in terms of the maximum parameter prefix length
(MAX_PARAM_PREFIX_LEN), when in fact the dependency is in the opposite
direction.

This split originates from commit 730b69d22525 ("module: check kernel param
length at compile time, not runtime"). The code needed to use
MODULE_NAME_LEN in moduleparam.h, but because module.h requires
moduleparam.h, this created a circular dependency. It was resolved by
introducing MAX_PARAM_PREFIX_LEN in moduleparam.h and defining
MODULE_NAME_LEN in module.h in terms of MAX_PARAM_PREFIX_LEN.

Rename MAX_PARAM_PREFIX_LEN to __MODULE_NAME_LEN for clarity. This matches
the similar approach of defining MODULE_INFO in module.h and __MODULE_INFO
in moduleparam.h.

Signed-off-by: Petr Pavlu <petr.pavlu@suse.com>
Reviewed-by: Daniel Gomez <da.gomez@samsung.com>
Link: https://lore.kernel.org/r/20250630143535.267745-6-petr.pavlu@suse.com
Signed-off-by: Daniel Gomez <da.gomez@samsung.com>
include/linux/module.h
include/linux/moduleparam.h

index 5fe812de2d84cc26d13fffc2298137298e6f92e2..313ecb8e518183248ad92c8dd2dc74d9d0761597 100644 (file)
@@ -33,7 +33,7 @@
 #include <linux/percpu.h>
 #include <asm/module.h>
 
-#define MODULE_NAME_LEN MAX_PARAM_PREFIX_LEN
+#define MODULE_NAME_LEN __MODULE_NAME_LEN
 
 struct modversion_info {
        unsigned long crc;
index 110e9d09de24369e1bf9132a72e95fd16f32fa49..a04a2bc4f51e30f952cb7890d6d6f006b64cb888 100644 (file)
@@ -6,6 +6,13 @@
 #include <linux/stringify.h>
 #include <linux/kernel.h>
 
+/*
+ * The maximum module name length, including the NUL byte.
+ * Chosen so that structs with an unsigned long line up, specifically
+ * modversion_info.
+ */
+#define __MODULE_NAME_LEN (64 - sizeof(unsigned long))
+
 /* You can override this manually, but generally this should match the
    module name. */
 #ifdef MODULE
@@ -17,9 +24,6 @@
 #define __MODULE_INFO_PREFIX KBUILD_MODNAME "."
 #endif
 
-/* Chosen so that structs with an unsigned long line up. */
-#define MAX_PARAM_PREFIX_LEN (64 - sizeof(unsigned long))
-
 #define __MODULE_INFO(tag, name, info)                                   \
        static const char __UNIQUE_ID(name)[]                             \
                __used __section(".modinfo") __aligned(1)                 \
@@ -284,7 +288,7 @@ struct kparam_array
 
 /* This is the fundamental function for registering boot/module parameters. */
 #define __module_param_call(prefix, name, ops, arg, perm, level, flags)        \
-       static_assert(sizeof(""prefix) - 1 <= MAX_PARAM_PREFIX_LEN);    \
+       static_assert(sizeof(""prefix) - 1 <= __MODULE_NAME_LEN);       \
        static const char __param_str_##name[] = prefix #name;          \
        static struct kernel_param __moduleparam_const __param_##name   \
        __used __section("__param")                                     \