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

Cc: Sumit Semwal <sumit.semwal@linaro.org>
Cc: linux-media@vger.kernel.org
Cc: dri-devel@lists.freedesktop.org
Cc: linaro-mm-sig@lists.linaro.org
Acked-by: Rafael J. Wysocki <rafael@kernel.org>
Acked-by: Christian König <christian.koenig@amd.com> for the changes to
Link: https://lore.kernel.org/r/20221121094649.1556002-3-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/base/bus.c
drivers/base/core.c
drivers/dma-buf/dma-buf-sysfs-stats.c
include/linux/kobject.h
kernel/params.c

index 7ca47e5b3c1f4c4200bac096f72fd170d113400c..4ec6dbab73be5ceaa603ea138ca2a13184bb170f 100644 (file)
@@ -163,7 +163,7 @@ static struct kobj_type bus_ktype = {
        .release        = bus_release,
 };
 
-static int bus_uevent_filter(struct kobject *kobj)
+static int bus_uevent_filter(const struct kobject *kobj)
 {
        const struct kobj_type *ktype = get_ktype(kobj);
 
index a79b99ecf4d8be94f77c16568cf47da1457ed379..005a2b092f3ee82a1e81e0ee61e4d621ecf88b30 100644 (file)
@@ -2362,12 +2362,12 @@ static struct kobj_type device_ktype = {
 };
 
 
-static int dev_uevent_filter(struct kobject *kobj)
+static int dev_uevent_filter(const struct kobject *kobj)
 {
        const struct kobj_type *ktype = get_ktype(kobj);
 
        if (ktype == &device_ktype) {
-               struct device *dev = kobj_to_dev(kobj);
+               const struct device *dev = kobj_to_dev(kobj);
                if (dev->bus)
                        return 1;
                if (dev->class)
index 2bba0babcb62b9f67cc8716c507d6fe816860734..f69d68122b9b1313ebc6f94cfb12d7c707cebe2e 100644 (file)
@@ -132,7 +132,7 @@ void dma_buf_stats_teardown(struct dma_buf *dmabuf)
 
 
 /* Statistics files do not need to send uevents. */
-static int dmabuf_sysfs_uevent_filter(struct kobject *kobj)
+static int dmabuf_sysfs_uevent_filter(const struct kobject *kobj)
 {
        return 0;
 }
index 5a2d58e10bf554e89bba2f4c8a13ed176e06840f..640f59d4b3de787bce547fa4bb4396d4d898a461 100644 (file)
@@ -135,7 +135,7 @@ struct kobj_uevent_env {
 };
 
 struct kset_uevent_ops {
-       int (* const filter)(struct kobject *kobj);
+       int (* const filter)(const struct kobject *kobj);
        const char *(* const name)(struct kobject *kobj);
        int (* const uevent)(struct kobject *kobj, struct kobj_uevent_env *env);
 };
index 5b92310425c50a5314942b14d7866f7fec383c20..d2237209cedacc53495aaa910947b00a2ad9a289 100644 (file)
@@ -926,7 +926,7 @@ static const struct sysfs_ops module_sysfs_ops = {
        .store = module_attr_store,
 };
 
-static int uevent_filter(struct kobject *kobj)
+static int uevent_filter(const struct kobject *kobj)
 {
        const struct kobj_type *ktype = get_ktype(kobj);