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.

driver core: make kobj_type structures 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 definitions to prevent
modification at runtime.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Link: https://lore.kernel.org/r/20230204-kobj_type-driver-core-v1-1-b9f809419f2c@weissschuh.net
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

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

+6 -6
+2 -2
drivers/base/bus.c
··· 91 91 kfree(drv_priv); 92 92 } 93 93 94 - static struct kobj_type driver_ktype = { 94 + static const struct kobj_type driver_ktype = { 95 95 .sysfs_ops = &driver_sysfs_ops, 96 96 .release = driver_release, 97 97 }; ··· 159 159 bus->p = NULL; 160 160 } 161 161 162 - static struct kobj_type bus_ktype = { 162 + static const struct kobj_type bus_ktype = { 163 163 .sysfs_ops = &bus_sysfs_ops, 164 164 .release = bus_release, 165 165 };
+1 -1
drivers/base/class.c
··· 77 77 .store = class_attr_store, 78 78 }; 79 79 80 - static struct kobj_type class_ktype = { 80 + static const struct kobj_type class_ktype = { 81 81 .sysfs_ops = &class_sysfs_ops, 82 82 .release = class_release, 83 83 .child_ns_type = class_child_ns_type,
+2 -2
drivers/base/core.c
··· 2354 2354 dev->class->get_ownership(dev, uid, gid); 2355 2355 } 2356 2356 2357 - static struct kobj_type device_ktype = { 2357 + static const struct kobj_type device_ktype = { 2358 2358 .release = device_release, 2359 2359 .sysfs_ops = &dev_sysfs_ops, 2360 2360 .namespace = device_namespace, ··· 2992 2992 return dir->class->ns_type; 2993 2993 } 2994 2994 2995 - static struct kobj_type class_dir_ktype = { 2995 + static const struct kobj_type class_dir_ktype = { 2996 2996 .release = class_dir_release, 2997 2997 .sysfs_ops = &kobj_sysfs_ops, 2998 2998 .child_ns_type = class_dir_child_ns_type
+1 -1
drivers/base/swnode.c
··· 760 760 kfree(swnode); 761 761 } 762 762 763 - static struct kobj_type software_node_type = { 763 + static const struct kobj_type software_node_type = { 764 764 .release = software_node_release, 765 765 .sysfs_ops = &kobj_sysfs_ops, 766 766 };