Skip to content

Commit 9cd4361

Browse files
ephox-gcc-pluginsgregkh
authored andcommitted
kobject: Constify struct kset_uevent_ops
Constify struct kset_uevent_ops. This is part of the ops structure constification effort started by Arjan van de Ven et al. Benefits of this constification: * prevents modification of data that is shared (referenced) by many other structure instances at runtime * detects/prevents accidental (but not intentional) modification attempts on archs that enforce read-only kernel data at runtime * potentially better optimized code as the compiler can assume that the const data cannot be changed * the compiler/linker move const data into .rodata and therefore exclude them from false sharing Signed-off-by: Emese Revfy <re.emese@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
1 parent 985fc17 commit 9cd4361

9 files changed

Lines changed: 14 additions & 14 deletions

File tree

‎drivers/base/bus.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ static int bus_uevent_filter(struct kset *kset, struct kobject *kobj)
154154
return 0;
155155
}
156156

157-
static struct kset_uevent_ops bus_uevent_ops = {
157+
static const struct kset_uevent_ops bus_uevent_ops = {
158158
.filter = bus_uevent_filter,
159159
};
160160

‎drivers/base/core.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ static int dev_uevent(struct kset *kset, struct kobject *kobj,
252252
return retval;
253253
}
254254

255-
static struct kset_uevent_ops device_uevent_ops = {
255+
static const struct kset_uevent_ops device_uevent_ops = {
256256
.filter = dev_uevent_filter,
257257
.name = dev_uevent_name,
258258
.uevent = dev_uevent,

‎drivers/base/memory.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ static int memory_uevent(struct kset *kset, struct kobject *obj, struct kobj_uev
4444
return retval;
4545
}
4646

47-
static struct kset_uevent_ops memory_uevent_ops = {
47+
static const struct kset_uevent_ops memory_uevent_ops = {
4848
.name = memory_uevent_name,
4949
.uevent = memory_uevent,
5050
};

‎fs/gfs2/sys.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ static int gfs2_uevent(struct kset *kset, struct kobject *kobj,
574574
return 0;
575575
}
576576

577-
static struct kset_uevent_ops gfs2_uevent_ops = {
577+
static const struct kset_uevent_ops gfs2_uevent_ops = {
578578
.uevent = gfs2_uevent,
579579
};
580580

‎include/linux/kobject.h‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,9 @@ struct kobj_uevent_env {
118118
};
119119

120120
struct kset_uevent_ops {
121-
int (*filter)(struct kset *kset, struct kobject *kobj);
122-
const char *(*name)(struct kset *kset, struct kobject *kobj);
123-
int (*uevent)(struct kset *kset, struct kobject *kobj,
121+
int (* const filter)(struct kset *kset, struct kobject *kobj);
122+
const char *(* const name)(struct kset *kset, struct kobject *kobj);
123+
int (* const uevent)(struct kset *kset, struct kobject *kobj,
124124
struct kobj_uevent_env *env);
125125
};
126126

@@ -155,14 +155,14 @@ struct kset {
155155
struct list_head list;
156156
spinlock_t list_lock;
157157
struct kobject kobj;
158-
struct kset_uevent_ops *uevent_ops;
158+
const struct kset_uevent_ops *uevent_ops;
159159
};
160160

161161
extern void kset_init(struct kset *kset);
162162
extern int __must_check kset_register(struct kset *kset);
163163
extern void kset_unregister(struct kset *kset);
164164
extern struct kset * __must_check kset_create_and_add(const char *name,
165-
struct kset_uevent_ops *u,
165+
const struct kset_uevent_ops *u,
166166
struct kobject *parent_kobj);
167167

168168
static inline struct kset *to_kset(struct kobject *kobj)

‎kernel/params.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,7 @@ static int uevent_filter(struct kset *kset, struct kobject *kobj)
736736
return 0;
737737
}
738738

739-
static struct kset_uevent_ops module_uevent_ops = {
739+
static const struct kset_uevent_ops module_uevent_ops = {
740740
.filter = uevent_filter,
741741
};
742742

‎lib/kobject.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,7 @@ static struct kobj_type kset_ktype = {
789789
* If the kset was not able to be created, NULL will be returned.
790790
*/
791791
static struct kset *kset_create(const char *name,
792-
struct kset_uevent_ops *uevent_ops,
792+
const struct kset_uevent_ops *uevent_ops,
793793
struct kobject *parent_kobj)
794794
{
795795
struct kset *kset;
@@ -832,7 +832,7 @@ static struct kset *kset_create(const char *name,
832832
* If the kset was not able to be created, NULL will be returned.
833833
*/
834834
struct kset *kset_create_and_add(const char *name,
835-
struct kset_uevent_ops *uevent_ops,
835+
const struct kset_uevent_ops *uevent_ops,
836836
struct kobject *parent_kobj)
837837
{
838838
struct kset *kset;

‎lib/kobject_uevent.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
9595
const char *subsystem;
9696
struct kobject *top_kobj;
9797
struct kset *kset;
98-
struct kset_uevent_ops *uevent_ops;
98+
const struct kset_uevent_ops *uevent_ops;
9999
u64 seq;
100100
int i = 0;
101101
int retval = 0;

‎mm/slub.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4409,7 +4409,7 @@ static int uevent_filter(struct kset *kset, struct kobject *kobj)
44094409
return 0;
44104410
}
44114411

4412-
static struct kset_uevent_ops slab_uevent_ops = {
4412+
static const struct kset_uevent_ops slab_uevent_ops = {
44134413
.filter = uevent_filter,
44144414
};
44154415

0 commit comments

Comments
 (0)