From: Greg Kroah-Hartman Date: Mon, 13 Mar 2023 18:18:39 +0000 (+0100) Subject: driver core: class: make class_create/remove_file*() options const X-Git-Tag: v6.6.7~2982^2~98 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=80842a92907bd68454591f9c7a73778f130ac38f;p=platform%2Fkernel%2Flinux-starfive.git driver core: class: make class_create/remove_file*() options const The class_create_file*() and class_remove_file*() functions do not modify the struct class at all, so mark them as const * to enforce that. Cc: "Rafael J. Wysocki" Link: https://lore.kernel.org/r/20230313181843.1207845-8-gregkh@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/base/class.c b/drivers/base/class.c index 52ba018..3d65221 100644 --- a/drivers/base/class.c +++ b/drivers/base/class.c @@ -87,7 +87,7 @@ static const struct kobj_type class_ktype = { static struct kset *class_kset; -int class_create_file_ns(struct class *cls, const struct class_attribute *attr, +int class_create_file_ns(const struct class *cls, const struct class_attribute *attr, const void *ns) { int error; @@ -101,7 +101,7 @@ int class_create_file_ns(struct class *cls, const struct class_attribute *attr, } EXPORT_SYMBOL_GPL(class_create_file_ns); -void class_remove_file_ns(struct class *cls, const struct class_attribute *attr, +void class_remove_file_ns(const struct class *cls, const struct class_attribute *attr, const void *ns) { if (cls) diff --git a/include/linux/device/class.h b/include/linux/device/class.h index dfa8958..75c1451f 100644 --- a/include/linux/device/class.h +++ b/include/linux/device/class.h @@ -200,20 +200,20 @@ struct class_attribute { #define CLASS_ATTR_WO(_name) \ struct class_attribute class_attr_##_name = __ATTR_WO(_name) -extern int __must_check class_create_file_ns(struct class *class, +extern int __must_check class_create_file_ns(const struct class *class, const struct class_attribute *attr, const void *ns); -extern void class_remove_file_ns(struct class *class, +extern void class_remove_file_ns(const struct class *class, const struct class_attribute *attr, const void *ns); -static inline int __must_check class_create_file(struct class *class, - const struct class_attribute *attr) +static inline int __must_check class_create_file(const struct class *class, + const struct class_attribute *attr) { return class_create_file_ns(class, attr, NULL); } -static inline void class_remove_file(struct class *class, +static inline void class_remove_file(const struct class *class, const struct class_attribute *attr) { return class_remove_file_ns(class, attr, NULL);