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

of: make of_node_ktype constant

Since commit ee6d3dd4ed48 ("driver core: make kobj_type constant.")
the driver core allows the usage of const struct kobj_type.

Take advantage of this to constify the structure definition to prevent
modification at runtime.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Link: https://lore.kernel.org/r/20230204-kobj_type-of-v1-1-5910c8ecb7a3@weissschuh.net
Signed-off-by: Rob Herring <robh@kernel.org>

authored by

Thomas Weißschuh and committed by
Rob Herring
20f6d4f2 df4fdd0d

+2 -2
+1 -1
drivers/of/kobj.c
··· 24 24 } 25 25 #endif /* CONFIG_OF_DYNAMIC */ 26 26 27 - struct kobj_type of_node_ktype = { 27 + const struct kobj_type of_node_ktype = { 28 28 .release = of_node_release, 29 29 }; 30 30
+1 -1
include/linux/of.h
··· 101 101 }; 102 102 103 103 /* initialize a node */ 104 - extern struct kobj_type of_node_ktype; 104 + extern const struct kobj_type of_node_ktype; 105 105 extern const struct fwnode_operations of_fwnode_ops; 106 106 static inline void of_node_init(struct device_node *node) 107 107 {