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

kobject: make kobject_namespace take a const *

kobject_namespace() should take a const *kobject as it does not modify
the kobject passed to it. Change that, and the functions
kobj_child_ns_ops() and kobj_ns_ops() needed to also be changed to const
*.

Acked-by: Rafael J. Wysocki <rafael@kernel.org>
Link: https://lore.kernel.org/r/20221121094649.1556002-2-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

+6 -6
+1 -1
include/linux/kobject.h
··· 112 112 struct kobject *kobj); 113 113 extern void kobject_put(struct kobject *kobj); 114 114 115 - extern const void *kobject_namespace(struct kobject *kobj); 115 + extern const void *kobject_namespace(const struct kobject *kobj); 116 116 extern void kobject_get_ownership(const struct kobject *kobj, 117 117 kuid_t *uid, kgid_t *gid); 118 118 extern char *kobject_get_path(const struct kobject *kobj, gfp_t flag);
+2 -2
include/linux/kobject_ns.h
··· 47 47 48 48 int kobj_ns_type_register(const struct kobj_ns_type_operations *ops); 49 49 int kobj_ns_type_registered(enum kobj_ns_type type); 50 - const struct kobj_ns_type_operations *kobj_child_ns_ops(struct kobject *parent); 51 - const struct kobj_ns_type_operations *kobj_ns_ops(struct kobject *kobj); 50 + const struct kobj_ns_type_operations *kobj_child_ns_ops(const struct kobject *parent); 51 + const struct kobj_ns_type_operations *kobj_ns_ops(const struct kobject *kobj); 52 52 53 53 bool kobj_ns_current_may_mount(enum kobj_ns_type type); 54 54 void *kobj_ns_grab_current(enum kobj_ns_type type);
+3 -3
lib/kobject.c
··· 25 25 * and thus @kobj should have a namespace tag associated with it. Returns 26 26 * %NULL otherwise. 27 27 */ 28 - const void *kobject_namespace(struct kobject *kobj) 28 + const void *kobject_namespace(const struct kobject *kobj) 29 29 { 30 30 const struct kobj_ns_type_operations *ns_ops = kobj_ns_ops(kobj); 31 31 ··· 1039 1039 return registered; 1040 1040 } 1041 1041 1042 - const struct kobj_ns_type_operations *kobj_child_ns_ops(struct kobject *parent) 1042 + const struct kobj_ns_type_operations *kobj_child_ns_ops(const struct kobject *parent) 1043 1043 { 1044 1044 const struct kobj_ns_type_operations *ops = NULL; 1045 1045 ··· 1049 1049 return ops; 1050 1050 } 1051 1051 1052 - const struct kobj_ns_type_operations *kobj_ns_ops(struct kobject *kobj) 1052 + const struct kobj_ns_type_operations *kobj_ns_ops(const struct kobject *kobj) 1053 1053 { 1054 1054 return kobj_child_ns_ops(kobj->parent); 1055 1055 }