diff mbox series

[v3,3/4] kernel: globalize lookup_or_create_module_kobject()

Message ID 20250211214842.1806521-4-shyamsaini@linux.microsoft.com (mailing list archive)
State New
Headers show
Series Properly handle module_kobject creation | expand

Checks

Context Check Description
mcgrof/vmtest-modules-next-PR fail PR summary
mcgrof/vmtest-modules-next-VM_Test-0 success Logs for Run CI tests
mcgrof/vmtest-modules-next-VM_Test-1 success Logs for Run CI tests
mcgrof/vmtest-modules-next-VM_Test-2 fail Logs for cleanup / Archive results and cleanup
mcgrof/vmtest-modules-next-VM_Test-3 fail Logs for cleanup / Archive results and cleanup
mcgrof/vmtest-modules-next-VM_Test-4 fail Logs for setup / Setup kdevops environment
mcgrof/vmtest-modules-next-VM_Test-5 fail Logs for setup / Setup kdevops environment

Commit Message

Shyam Saini Feb. 11, 2025, 9:48 p.m. UTC
lookup_or_create_module_kobject() is marked as static and __init,
to make it global drop static keyword.
Since this function can be called from non-init code, use __modinit
instead of __init, __modinit marker will make it __init if
CONFIG_MODULES is not defined.

Suggested-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Signed-off-by: Shyam Saini <shyamsaini@linux.microsoft.com>
---
 include/linux/module.h | 2 ++
 kernel/params.c        | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

Comments

Petr Pavlu Feb. 13, 2025, 3:59 p.m. UTC | #1
On 2/11/25 22:48, Shyam Saini wrote:
> lookup_or_create_module_kobject() is marked as static and __init,
> to make it global drop static keyword.
> Since this function can be called from non-init code, use __modinit
> instead of __init, __modinit marker will make it __init if
> CONFIG_MODULES is not defined.

Hm, we should later clean up kernel/params.c to use __init_or_module
from include/linux/module.h instead of its own __modinit implementation.

-- Petr
diff mbox series

Patch

diff --git a/include/linux/module.h b/include/linux/module.h
index 12f8a7d4fc1c..aeaaf9e068eb 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -162,6 +162,8 @@  extern void cleanup_module(void);
 #define __INITRODATA_OR_MODULE __INITRODATA
 #endif /*CONFIG_MODULES*/
 
+struct module_kobject *lookup_or_create_module_kobject(const char *name);
+
 /* Generic info of form tag = "info" */
 #define MODULE_INFO(tag, info) __MODULE_INFO(tag, tag, info)
 
diff --git a/kernel/params.c b/kernel/params.c
index 6e87aef876b2..1073f8ebd5a6 100644
--- a/kernel/params.c
+++ b/kernel/params.c
@@ -763,7 +763,7 @@  void destroy_params(const struct kernel_param *params, unsigned num)
 			params[i].ops->free(params[i].arg);
 }
 
-static struct module_kobject * __init lookup_or_create_module_kobject(const char *name)
+struct module_kobject __modinit * lookup_or_create_module_kobject(const char *name)
 {
 	struct module_kobject *mk;
 	struct kobject *kobj;