Skip to content

Commit 9617b5b

Browse files
Bartosz GolaszewskiDanilo Krummrich
authored andcommitted
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>
1 parent 704b2a7 commit 9617b5b

4 files changed

Lines changed: 15 additions & 5 deletions

File tree

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7805,6 +7805,7 @@ F: include/linux/debugfs.h
78057805
F: include/linux/device.h
78067806
F: include/linux/fwnode.h
78077807
F: include/linux/kobj*
7808+
F: include/linux/ksysfs.h
78087809
F: include/linux/property.h
78097810
F: include/linux/sysfs.h
78107811
F: kernel/ksysfs.c

include/linux/ksysfs.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
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_ */

init/main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include <linux/kmod.h>
3737
#include <linux/kprobes.h>
3838
#include <linux/kmsan.h>
39+
#include <linux/ksysfs.h>
3940
#include <linux/vmalloc.h>
4041
#include <linux/kernel_stat.h>
4142
#include <linux/start_kernel.h>
@@ -1473,6 +1474,7 @@ static void __init do_initcalls(void)
14731474
static void __init do_basic_setup(void)
14741475
{
14751476
cpuset_init_smp();
1477+
ksysfs_init();
14761478
driver_init();
14771479
init_irq_proc();
14781480
do_ctors();

kernel/ksysfs.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include <asm/byteorder.h>
1010
#include <linux/kobject.h>
11+
#include <linux/ksysfs.h>
1112
#include <linux/string.h>
1213
#include <linux/sysfs.h>
1314
#include <linux/export.h>
@@ -213,7 +214,7 @@ static const struct attribute_group kernel_attr_group = {
213214
.attrs = kernel_attrs,
214215
};
215216

216-
static int __init ksysfs_init(void)
217+
void __init ksysfs_init(void)
217218
{
218219
int error;
219220

@@ -234,14 +235,12 @@ static int __init ksysfs_init(void)
234235
goto group_exit;
235236
}
236237

237-
return 0;
238+
return;
238239

239240
group_exit:
240241
sysfs_remove_group(kernel_kobj, &kernel_attr_group);
241242
kset_exit:
242243
kobject_put(kernel_kobj);
243244
exit:
244-
return error;
245+
pr_err("failed to initialize the kernel kobject: %d\n", error);
245246
}
246-
247-
core_initcall(ksysfs_init);

0 commit comments

Comments
 (0)