Skip to content

Commit 1cf996a

Browse files
Bartosz GolaszewskiDanilo Krummrich
authored andcommitted
driver core: make software nodes available earlier
Software nodes are currently initialized in a function registered as a postcore_initcall(). However, some devices may want to register software nodes earlier than that (or also in a postcore_initcall() where they're at the mercy of the link order). Move the initialization to driver_init() making swnode available much earlier as well as making their initialization time deterministic. Suggested-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com> Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://patch.msgid.link/20260402-nokia770-gpio-swnodes-v5-3-d730db3dd299@oss.qualcomm.com [ Fix typo in the commit message: "s/merci/mercy/". - Danilo ] Signed-off-by: Danilo Krummrich <dakr@kernel.org>
1 parent b3eb6a2 commit 1cf996a

3 files changed

Lines changed: 4 additions & 4 deletions

File tree

drivers/base/base.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,7 @@ static inline int devtmpfs_create_node(struct device *dev) { return 0; }
312312
static inline int devtmpfs_delete_node(struct device *dev) { return 0; }
313313
#endif
314314

315+
void software_node_init(void);
315316
void software_node_notify(struct device *dev);
316317
void software_node_notify_remove(struct device *dev);
317318

drivers/base/init.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ void __init driver_init(void)
3434
*/
3535
faux_bus_init();
3636
of_core_init();
37+
software_node_init();
3738
platform_bus_init();
3839
auxiliary_bus_init();
3940
memory_dev_init();

drivers/base/swnode.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1127,11 +1127,9 @@ void software_node_notify_remove(struct device *dev)
11271127
}
11281128
}
11291129

1130-
static int __init software_node_init(void)
1130+
void __init software_node_init(void)
11311131
{
11321132
swnode_kset = kset_create_and_add("software_nodes", NULL, kernel_kobj);
11331133
if (!swnode_kset)
1134-
return -ENOMEM;
1135-
return 0;
1134+
pr_err("failed to register software nodes\n");
11361135
}
1137-
postcore_initcall(software_node_init);

0 commit comments

Comments
 (0)