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

driver core: class: make class_register() take a const *

Now that the class code is cleaned up to not modify the class pointer
registered with it, change class_register() to take a const * to allow
the structure to be placed into read-only memory.

Acked-by: Rafael J. Wysocki <rafael@kernel.org>
Link: https://lore.kernel.org/r/2023040248-customary-release-4aec@gregkh
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

+5 -5
+1 -1
drivers/base/base.h
··· 54 54 struct device *dev_root; 55 55 56 56 struct kset glue_dirs; 57 - struct class *class; 57 + const struct class *class; 58 58 59 59 struct lock_class_key lock_key; 60 60 };
+3 -3
drivers/base/class.c
··· 93 93 static void class_release(struct kobject *kobj) 94 94 { 95 95 struct subsys_private *cp = to_subsys_private(kobj); 96 - struct class *class = cp->class; 96 + const struct class *class = cp->class; 97 97 98 98 pr_debug("class '%s': release.\n", class->name); 99 99 ··· 110 110 static const struct kobj_ns_type_operations *class_child_ns_type(const struct kobject *kobj) 111 111 { 112 112 const struct subsys_private *cp = to_subsys_private(kobj); 113 - struct class *class = cp->class; 113 + const struct class *class = cp->class; 114 114 115 115 return class->ns_type; 116 116 } ··· 175 175 put_device(dev); 176 176 } 177 177 178 - int class_register(struct class *cls) 178 + int class_register(const struct class *cls) 179 179 { 180 180 struct subsys_private *cp; 181 181 struct lock_class_key *key;
+1 -1
include/linux/device/class.h
··· 76 76 const struct device_type *type; 77 77 }; 78 78 79 - int __must_check class_register(struct class *class); 79 + int __must_check class_register(const struct class *class); 80 80 void class_unregister(const struct class *class); 81 81 bool class_is_registered(const struct class *class); 82 82