Commit 9617b5b6 authored by Bartosz Golaszewski's avatar Bartosz Golaszewski Committed by Danilo Krummrich
Browse files

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: default avatarBartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Link: https://patch.msgid.link/20260402-nokia770-gpio-swnodes-v5-1-d730db3dd299@oss.qualcomm.com


Signed-off-by: default avatarDanilo Krummrich <dakr@kernel.org>
parent 704b2a7d
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -7805,6 +7805,7 @@ F: include/linux/debugfs.h
F:	include/linux/device.h
F:	include/linux/fwnode.h
F:	include/linux/kobj*
F:	include/linux/ksysfs.h
F:	include/linux/property.h
F:	include/linux/sysfs.h
F:	kernel/ksysfs.c

include/linux/ksysfs.h

0 → 100644
+8 −0
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0 */

#ifndef _KSYSFS_H_
#define _KSYSFS_H_

void ksysfs_init(void);

#endif /* _KSYSFS_H_ */
+2 −0
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@
#include <linux/kmod.h>
#include <linux/kprobes.h>
#include <linux/kmsan.h>
#include <linux/ksysfs.h>
#include <linux/vmalloc.h>
#include <linux/kernel_stat.h>
#include <linux/start_kernel.h>
@@ -1473,6 +1474,7 @@ static void __init do_initcalls(void)
static void __init do_basic_setup(void)
{
	cpuset_init_smp();
	ksysfs_init();
	driver_init();
	init_irq_proc();
	do_ctors();
+4 −5
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@

#include <asm/byteorder.h>
#include <linux/kobject.h>
#include <linux/ksysfs.h>
#include <linux/string.h>
#include <linux/sysfs.h>
#include <linux/export.h>
@@ -213,7 +214,7 @@ static const struct attribute_group kernel_attr_group = {
	.attrs = kernel_attrs,
};

static int __init ksysfs_init(void)
void __init ksysfs_init(void)
{
	int error;

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

	return 0;
	return;

group_exit:
	sysfs_remove_group(kernel_kobj, &kernel_attr_group);
kset_exit:
	kobject_put(kernel_kobj);
exit:
	return error;
	pr_err("failed to initialize the kernel kobject: %d\n", error);
}

core_initcall(ksysfs_init);