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

kobject: kset_uevent_ops: make uevent() callback take a const *

The uevent() callback in struct kset_uevent_ops does not modify the
kobject passed into it, so make the pointer const to enforce this
restriction. When doing so, fix up all existing uevent() callbacks to
have the correct signature to preserve the build.

Cc: Christine Caulfield <ccaulfie@redhat.com>
Cc: David Teigland <teigland@redhat.com>
Cc: Bob Peterson <rpeterso@redhat.com>
Cc: Andreas Gruenbacher <agruenba@redhat.com>
Acked-by: Rafael J. Wysocki <rafael@kernel.org>
Acked-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20230111113018.459199-17-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

+8 -8
+2 -2
drivers/base/core.c
··· 2387 2387 return NULL; 2388 2388 } 2389 2389 2390 - static int dev_uevent(struct kobject *kobj, struct kobj_uevent_env *env) 2390 + static int dev_uevent(const struct kobject *kobj, struct kobj_uevent_env *env) 2391 2391 { 2392 - struct device *dev = kobj_to_dev(kobj); 2392 + const struct device *dev = kobj_to_dev(kobj); 2393 2393 int retval = 0; 2394 2394 2395 2395 /* add device node properties if present */
+2 -2
fs/dlm/lockspace.c
··· 215 215 return ls->ls_uevent_result; 216 216 } 217 217 218 - static int dlm_uevent(struct kobject *kobj, struct kobj_uevent_env *env) 218 + static int dlm_uevent(const struct kobject *kobj, struct kobj_uevent_env *env) 219 219 { 220 - struct dlm_ls *ls = container_of(kobj, struct dlm_ls, ls_kobj); 220 + const struct dlm_ls *ls = container_of(kobj, struct dlm_ls, ls_kobj); 221 221 222 222 add_uevent_var(env, "LOCKSPACE=%s", ls->ls_name); 223 223 return 0;
+3 -3
fs/gfs2/sys.c
··· 767 767 wait_for_completion(&sdp->sd_kobj_unregister); 768 768 } 769 769 770 - static int gfs2_uevent(struct kobject *kobj, struct kobj_uevent_env *env) 770 + static int gfs2_uevent(const struct kobject *kobj, struct kobj_uevent_env *env) 771 771 { 772 - struct gfs2_sbd *sdp = container_of(kobj, struct gfs2_sbd, sd_kobj); 773 - struct super_block *s = sdp->sd_vfs; 772 + const struct gfs2_sbd *sdp = container_of(kobj, struct gfs2_sbd, sd_kobj); 773 + const struct super_block *s = sdp->sd_vfs; 774 774 775 775 add_uevent_var(env, "LOCKTABLE=%s", sdp->sd_table_name); 776 776 add_uevent_var(env, "LOCKPROTO=%s", sdp->sd_proto_name);
+1 -1
include/linux/kobject.h
··· 137 137 struct kset_uevent_ops { 138 138 int (* const filter)(const struct kobject *kobj); 139 139 const char *(* const name)(const struct kobject *kobj); 140 - int (* const uevent)(struct kobject *kobj, struct kobj_uevent_env *env); 140 + int (* const uevent)(const struct kobject *kobj, struct kobj_uevent_env *env); 141 141 }; 142 142 143 143 struct kobj_attribute {