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.

samples/kobject: make kobj_type structure 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/20230208-kobj_type-samples-v1-1-fca804a8e9f3@weissschuh.net
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Thomas Weißschuh and committed by
Greg Kroah-Hartman
862f6a84 c83d9ab4

+1 -1
+1 -1
samples/kobject/kset-example.c
··· 185 185 * release function, and the set of default attributes we want created 186 186 * whenever a kobject of this type is registered with the kernel. 187 187 */ 188 - static struct kobj_type foo_ktype = { 188 + static const struct kobj_type foo_ktype = { 189 189 .sysfs_ops = &foo_sysfs_ops, 190 190 .release = foo_release, 191 191 .default_groups = foo_default_groups,