kobject: kset_uevent_ops: make name() callback take a const *
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 21 Nov 2022 09:46:48 +0000 (10:46 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 22 Nov 2022 16:34:52 +0000 (17:34 +0100)
The name() 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 the single existing name() callback
to have the correct signature to preserve the build.

Acked-by: Rafael J. Wysocki <rafael@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Link: https://lore.kernel.org/r/20221121094649.1556002-4-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/base/core.c
include/linux/kobject.h

index 005a2b092f3ee82a1e81e0ee61e4d621ecf88b30..a3e14143ec0cfd4beed114627361affb7da18650 100644 (file)
@@ -2376,9 +2376,9 @@ static int dev_uevent_filter(const struct kobject *kobj)
        return 0;
 }
 
-static const char *dev_uevent_name(struct kobject *kobj)
+static const char *dev_uevent_name(const struct kobject *kobj)
 {
-       struct device *dev = kobj_to_dev(kobj);
+       const struct device *dev = kobj_to_dev(kobj);
 
        if (dev->bus)
                return dev->bus->name;
index 640f59d4b3de787bce547fa4bb4396d4d898a461..58a5b75612e35870f8569674aaa574d0a742bafc 100644 (file)
@@ -136,7 +136,7 @@ struct kobj_uevent_env {
 
 struct kset_uevent_ops {
        int (* const filter)(const struct kobject *kobj);
-       const char *(* const name)(struct kobject *kobj);
+       const char *(* const name)(const struct kobject *kobj);
        int (* const uevent)(struct kobject *kobj, struct kobj_uevent_env *env);
 };