diff options
| author | Emese Revfy <re.emese@gmail.com> | 2010-01-18 20:58:23 -0500 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-03-07 20:04:49 -0500 |
| commit | 52cf25d0ab7f78eeecc59ac652ed5090f69b619e (patch) | |
| tree | 031d1ffb3890bd69c0260c864c512e0be62ac05c | |
| parent | 6c1733aca0b48db4d0e660d54976a1cca25b5eaf (diff) | |
Driver core: Constify struct sysfs_ops in struct kobj_type
Constify struct sysfs_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>
Acked-by: David Teigland <teigland@redhat.com>
Acked-by: Matt Domsch <Matt_Domsch@dell.com>
Acked-by: Maciej Sosnowski <maciej.sosnowski@intel.com>
Acked-by: Hans J. Koch <hjk@linutronix.de>
Acked-by: Pekka Enberg <penberg@cs.helsinki.fi>
Acked-by: Jens Axboe <jens.axboe@oracle.com>
Acked-by: Stephen Hemminger <shemminger@vyatta.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
54 files changed, 69 insertions, 70 deletions
diff --git a/Documentation/kobject.txt b/Documentation/kobject.txt index c79ab996dada..bdb13817e1e9 100644 --- a/Documentation/kobject.txt +++ b/Documentation/kobject.txt | |||
| @@ -266,7 +266,7 @@ kobj_type: | |||
| 266 | 266 | ||
| 267 | struct kobj_type { | 267 | struct kobj_type { |
| 268 | void (*release)(struct kobject *); | 268 | void (*release)(struct kobject *); |
| 269 | struct sysfs_ops *sysfs_ops; | 269 | const struct sysfs_ops *sysfs_ops; |
| 270 | struct attribute **default_attrs; | 270 | struct attribute **default_attrs; |
| 271 | }; | 271 | }; |
| 272 | 272 | ||
diff --git a/arch/ia64/kernel/topology.c b/arch/ia64/kernel/topology.c index 8f060352e129..b3a5818088d9 100644 --- a/arch/ia64/kernel/topology.c +++ b/arch/ia64/kernel/topology.c | |||
| @@ -282,7 +282,7 @@ static ssize_t cache_show(struct kobject * kobj, struct attribute * attr, char * | |||
| 282 | return ret; | 282 | return ret; |
| 283 | } | 283 | } |
| 284 | 284 | ||
| 285 | static struct sysfs_ops cache_sysfs_ops = { | 285 | static const struct sysfs_ops cache_sysfs_ops = { |
| 286 | .show = cache_show | 286 | .show = cache_show |
| 287 | }; | 287 | }; |
| 288 | 288 | ||
diff --git a/arch/powerpc/kernel/cacheinfo.c b/arch/powerpc/kernel/cacheinfo.c index bb37b1d19a58..01fe9ce28379 100644 --- a/arch/powerpc/kernel/cacheinfo.c +++ b/arch/powerpc/kernel/cacheinfo.c | |||
| @@ -642,7 +642,7 @@ static struct kobj_attribute *cache_index_opt_attrs[] = { | |||
| 642 | &cache_assoc_attr, | 642 | &cache_assoc_attr, |
| 643 | }; | 643 | }; |
| 644 | 644 | ||
| 645 | static struct sysfs_ops cache_index_ops = { | 645 | static const struct sysfs_ops cache_index_ops = { |
| 646 | .show = cache_index_show, | 646 | .show = cache_index_show, |
| 647 | }; | 647 | }; |
| 648 | 648 | ||
diff --git a/arch/sh/kernel/cpu/sh4/sq.c b/arch/sh/kernel/cpu/sh4/sq.c index fc065f9da6e5..14726eef1ce0 100644 --- a/arch/sh/kernel/cpu/sh4/sq.c +++ b/arch/sh/kernel/cpu/sh4/sq.c | |||
| @@ -326,7 +326,7 @@ static struct attribute *sq_sysfs_attrs[] = { | |||
| 326 | NULL, | 326 | NULL, |
| 327 | }; | 327 | }; |
| 328 | 328 | ||
| 329 | static struct sysfs_ops sq_sysfs_ops = { | 329 | static const struct sysfs_ops sq_sysfs_ops = { |
| 330 | .show = sq_sysfs_show, | 330 | .show = sq_sysfs_show, |
| 331 | .store = sq_sysfs_store, | 331 | .store = sq_sysfs_store, |
| 332 | }; | 332 | }; |
diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c index eddb1bdd1b8f..b3eeb66c0a51 100644 --- a/arch/x86/kernel/cpu/intel_cacheinfo.c +++ b/arch/x86/kernel/cpu/intel_cacheinfo.c | |||
| @@ -903,7 +903,7 @@ static ssize_t store(struct kobject *kobj, struct attribute *attr, | |||
| 903 | return ret; | 903 | return ret; |
| 904 | } | 904 | } |
| 905 | 905 | ||
| 906 | static struct sysfs_ops sysfs_ops = { | 906 | static const struct sysfs_ops sysfs_ops = { |
| 907 | .show = show, | 907 | .show = show, |
| 908 | .store = store, | 908 | .store = store, |
| 909 | }; | 909 | }; |
diff --git a/arch/x86/kernel/cpu/mcheck/mce_amd.c b/arch/x86/kernel/cpu/mcheck/mce_amd.c index 83a3d1f4efca..cda932ca3ade 100644 --- a/arch/x86/kernel/cpu/mcheck/mce_amd.c +++ b/arch/x86/kernel/cpu/mcheck/mce_amd.c | |||
| @@ -388,7 +388,7 @@ static ssize_t store(struct kobject *kobj, struct attribute *attr, | |||
| 388 | return ret; | 388 | return ret; |
| 389 | } | 389 | } |
| 390 | 390 | ||
| 391 | static struct sysfs_ops threshold_ops = { | 391 | static const struct sysfs_ops threshold_ops = { |
| 392 | .show = show, | 392 | .show = show, |
| 393 | .store = store, | 393 | .store = store, |
| 394 | }; | 394 | }; |
diff --git a/block/blk-integrity.c b/block/blk-integrity.c index 15c630813b1c..96e83c2bdb94 100644 --- a/block/blk-integrity.c +++ b/block/blk-integrity.c | |||
| @@ -278,7 +278,7 @@ static struct attribute *integrity_attrs[] = { | |||
| 278 | NULL, | 278 | NULL, |
| 279 | }; | 279 | }; |
| 280 | 280 | ||
| 281 | static struct sysfs_ops integrity_ops = { | 281 | static const struct sysfs_ops integrity_ops = { |
| 282 | .show = &integrity_attr_show, | 282 | .show = &integrity_attr_show, |
| 283 | .store = &integrity_attr_store, | 283 | .store = &integrity_attr_store, |
| 284 | }; | 284 | }; |
diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c index e85442415db3..2ae2cb3f362f 100644 --- a/block/blk-sysfs.c +++ b/block/blk-sysfs.c | |||
| @@ -450,7 +450,7 @@ static void blk_release_queue(struct kobject *kobj) | |||
| 450 | kmem_cache_free(blk_requestq_cachep, q); | 450 | kmem_cache_free(blk_requestq_cachep, q); |
| 451 | } | 451 | } |
| 452 | 452 | ||
| 453 | static struct sysfs_ops queue_sysfs_ops = { | 453 | static const struct sysfs_ops queue_sysfs_ops = { |
| 454 | .show = queue_attr_show, | 454 | .show = queue_attr_show, |
| 455 | .store = queue_attr_store, | 455 | .store = queue_attr_store, |
| 456 | }; | ||
