Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

kernel: ksysfs: initialize kernel_kobj earlier

Software nodes depend on kernel_kobj which is initialized pretty late
into the boot process - as a core_initcall(). Ahead of moving the
software node initialization to driver_init() we must first make
kernel_kobj available before it.

Make ksysfs_init() visible in a new header - ksysfs.h - and call it in
do_basic_setup() right before driver_init().

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Link: https://patch.msgid.link/20260402-nokia770-gpio-swnodes-v5-1-d730db3dd299@oss.qualcomm.com
Signed-off-by: Danilo Krummrich <dakr@kernel.org>

authored by

Bartosz Golaszewski and committed by
Danilo Krummrich
9617b5b6 704b2a7d

+15 -5
+1
MAINTAINERS
··· 7805 7805 F: include/linux/device.h 7806 7806 F: include/linux/fwnode.h 7807 7807 F: include/linux/kobj* 7808 + F: include/linux/ksysfs.h 7808 7809 F: include/linux/property.h 7809 7810 F: include/linux/sysfs.h 7810 7811 F: kernel/ksysfs.c
+8
include/linux/ksysfs.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + 3 + #ifndef _KSYSFS_H_ 4 + #define _KSYSFS_H_ 5 + 6 + void ksysfs_init(void); 7 + 8 + #endif /* _KSYSFS_H_ */
+2
init/main.c
··· 36 36 #include <linux/kmod.h> 37 37 #include <linux/kprobes.h> 38 38 #include <linux/kmsan.h> 39 + #include <linux/ksysfs.h> 39 40 #include <linux/vmalloc.h> 40 41 #include <linux/kernel_stat.h> 41 42 #include <linux/start_kernel.h> ··· 1474 1473 static void __init do_basic_setup(void) 1475 1474 { 1476 1475 cpuset_init_smp(); 1476 + ksysfs_init(); 1477 1477 driver_init(); 1478 1478 init_irq_proc(); 1479 1479 do_ctors();
+4 -5
kernel/ksysfs.c
··· 8 8 9 9 #include <asm/byteorder.h> 10 10 #include <linux/kobject.h> 11 + #include <linux/ksysfs.h> 11 12 #include <linux/string.h> 12 13 #include <linux/sysfs.h> 13 14 #include <linux/export.h> ··· 214 213 .attrs = kernel_attrs, 215 214 }; 216 215 217 - static int __init ksysfs_init(void) 216 + void __init ksysfs_init(void) 218 217 { 219 218 int error; 220 219 ··· 235 234 goto group_exit; 236 235 } 237 236 238 - return 0; 237 + return; 239 238 240 239 group_exit: 241 240 sysfs_remove_group(kernel_kobj, &kernel_attr_group); 242 241 kset_exit: 243 242 kobject_put(kernel_kobj); 244 243 exit: 245 - return error; 244 + pr_err("failed to initialize the kernel kobject: %d\n", error); 246 245 } 247 - 248 - core_initcall(ksysfs_init);