aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEmese Revfy <re.emese@gmail.com>2009-12-31 08:52:51 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2010-03-07 20:04:49 -0500
commit9cd43611ccfb46632bfa7d19f688924ea93f1613 (patch)
treee11ecee403235ba9d8855892fa7ad55d9b63e221
parent985fc176a6c03836454629be2f2a611ccc7c7002 (diff)
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>
-rw-r--r--drivers/base/bus.c2
-rw-r--r--drivers/base/core.c2
-rw-r--r--drivers/base/memory.c2
-rw-r--r--fs/gfs2/sys.c2
-rw-r--r--include/linux/kobject.h10
-rw-r--r--kernel/params.c2
-rw-r--r--lib/kobject.c4
-rw-r--r--lib/kobject_uevent.c2
-rw-r--r--mm/slub.c2
9 files changed, 14 insertions, 14 deletions
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index c0c5a43d9fb3..2afe599eb35d 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -154,7 +154,7 @@ static int bus_uevent_filter(struct kset *kset, struct kobject *kobj)
154 return 0; 154 return 0;
155} 155}
156 156
157static struct kset_uevent_ops bus_uevent_ops = { 157static const struct kset_uevent_ops bus_uevent_ops = {
158 .filter = bus_uevent_filter, 158 .filter = bus_uevent_filter,
159}; 159};
160 160
diff --git a/drivers/base/core.c b/drivers/base/core.c
index f6c73a9e3d95..58ec1069f4b0 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -252,7 +252,7 @@ static int dev_uevent(struct kset *kset, struct kobject *kobj,
252 return retval; 252 return retval;
253} 253}
254 254
255static struct kset_uevent_ops device_uevent_ops = { 255static const struct kset_uevent_ops device_uevent_ops = {
256 .filter = dev_uevent_filter, 256 .filter = dev_uevent_filter,
257 .name = dev_uevent_name, 257 .name = dev_uevent_name,
258 .uevent = dev_uevent, 258 .uevent = dev_uevent,
diff --git a/drivers/base/memory.c b/drivers/base/memory.c
index 495f15e92d4c..2f8691511190 100644
--- a/drivers/base/memory.c
+++ b/drivers/base/memory.c
@@ -44,7 +44,7 @@ static int memory_uevent(struct kset *kset, struct kobject *obj, struct kobj_uev
44 return retval; 44 return retval;
45} 45}
46 46
47static struct kset_uevent_ops memory_uevent_ops = { 47static const struct kset_uevent_ops memory_uevent_ops = {
48 .name = memory_uevent_name, 48 .name = memory_uevent_name,
49 .uevent = memory_uevent, 49 .uevent = memory_uevent,
50}; 50};
diff --git a/fs/gfs2/sys.c b/fs/gfs2/sys.c
index b5f1a46133c8..543503010ed0 100644
--- a/fs/gfs2/sys.c
+++ b/fs/gfs2/sys.c
@@ -574,7 +574,7 @@ static int gfs2_uevent(struct kset *kset, struct kobject *kobj,
574 return 0; 574 return 0;
575} 575}
576 576
577static struct kset_uevent_ops gfs2_uevent_ops = { 577static const struct kset_uevent_ops gfs2_uevent_ops = {
578 .uevent = gfs2_uevent, 578 .uevent = gfs2_uevent,
579}; 579};
580 580
diff --git a/include/linux/kobject.h b/include/linux/kobject.h
index 58ae8e00fcdd..57a1eaae9096 100644
--- a/include/linux/kobject.h
+++ b/include/linux/kobject.h
@@ -118,9 +118,9 @@ struct kobj_uevent_env {
118}; 118};
119 119
120struct kset_uevent_ops { 120struct kset_uevent_ops {
121 int (*filter)(struct kset *kset, struct kobject *kobj); 121 int (* const filter)(struct kset *kset, struct kobject *kobj);
122 const char *(*name)(struct kset *kset, struct kobject *kobj); 122 const char *(* const name)(struct kset *kset, struct kobject *kobj);
123 int (*uevent)(struct kset *kset, struct kobject *kobj, 123 int (* const uevent)(struct kset *kset, struct kobject *kobj,
124 struct kobj_uevent_env *env); 124 struct kobj_uevent_env *env);
125}; 125};
126 126
@@ -155,14 +155,14 @@ struct kset {
155 struct list_head list; 155 struct list_head list;
156 spinlock_t list_lock; 156 spinlock_t list_lock;
157 struct kobject kobj; 157 struct kobject kobj;
158 struct kset_uevent_ops *uevent_ops; 158 const struct kset_uevent_ops *uevent_ops;
159}; 159};
160 160
161extern void kset_init(struct kset *kset); 161extern void kset_init(struct kset *kset);
162extern int __must_check kset_register(struct kset *kset); 162extern int __must_check kset_register(struct kset *kset);
163extern void kset_unregister(struct kset *kset); 163extern void kset_unregister(struct kset *kset);
164extern struct kset * __must_check kset_create_and_add(const char *name, 164extern struct kset * __must_check kset_create_and_add(const char *name,
165 struct kset_uevent_ops *u, 165 const struct kset_uevent_ops *u,
166 struct kobject *parent_kobj); 166 struct kobject *parent_kobj);
167 167
168static inline struct kset *to_kset(struct kobject *kobj) 168static inline struct kset *to_kset(struct kobject *kobj)
diff --git a/kernel/params.c b/kernel/params.c
index 8d95f5451b22..48370be3c0a1 100644
--- a/kernel/params.c
+++ b/kernel/params.c
@@ -736,7 +736,7 @@ static int uevent_filter(struct kset *kset, struct kobject *kobj)
736 return 0; 736 return 0;
737} 737}
738 738
739static struct kset_uevent_ops module_uevent_ops = { 739static const struct kset_uevent_ops module_uevent_ops = {
740 .filter = uevent_filter, 740 .filter = uevent_filter,
741}; 741};
742 742
diff --git a/lib/kobject.c b/lib/kobject.c
index b512b746d2af..cecf5a0ef6e1 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -789,7 +789,7 @@ static struct kobj_type kset_ktype = {
789 * If the kset was not able to be created, NULL will be returned. 789 * If the kset was not able to be created, NULL will be returned.
790 */ 790 */
791static struct kset *kset_create(const char *name, 791static struct kset *kset_create(const char *name,
792 struct kset_uevent_ops *uevent_ops, 792 const struct kset_uevent_ops *uevent_ops,
793 struct kobject *parent_kobj) 793 struct kobject *parent_kobj)
794{ 794{
795 struct kset *kset; 795 struct kset *kset;
@@ -832,7 +832,7 @@ static struct kset *kset_create(const char *name,
832 * If the kset was not able to be created, NULL will be returned. 832 * If the kset was not able to be created, NULL will be returned.
833 */ 833 */
834struct kset *kset_create_and_add(const char *name, 834struct kset *kset_create_and_add(const char *name,
835 struct kset_uevent_ops *uevent_ops, 835 const struct kset_uevent_ops *uevent_ops,
836 struct kobject *parent_kobj) 836 struct kobject *parent_kobj)
837{ 837{
838 struct kset *kset; 838 struct kset *kset;
diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c
index 920a3ca6e259..c9d3a3e8405d 100644
--- a/lib/kobject_uevent.c
+++ b/lib/kobject_uevent.c
@@ -95,7 +95,7 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
95 const char *subsystem; 95 const char *subsystem;
96 struct kobject *top_kobj; 96 struct kobject *top_kobj;
97 struct kset *kset; 97 struct kset *kset;
98 struct kset_uevent_ops *uevent_ops; 98 const struct kset_uevent_ops *uevent_ops;
99 u64 seq; 99 u64 seq;
100 int i = 0; 100 int i = 0;
101 int retval = 0; 101 int retval = 0;
diff --git a/mm/slub.c b/mm/slub.c
index 0bfd3863d521..a26753c12dcd 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -4409,7 +4409,7 @@ static int uevent_filter(struct kset *kset, struct kobject *kobj)
4409 return 0; 4409 return 0;
4410} 4410}
4411 4411
4412static struct kset_uevent_ops slab_uevent_ops = { 4412static const struct kset_uevent_ops slab_uevent_ops = {
4413 .filter = uevent_filter, 4413 .filter = uevent_filter,
4414}; 4414};
4415 4415