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 <[email protected]>
Acked-by: David Teigland <[email protected]>
Acked-by: Matt Domsch <[email protected]>
Acked-by: Maciej Sosnowski <[email protected]>
Acked-by: Hans J. Koch <[email protected]>
Acked-by: Pekka Enberg <[email protected]>
Acked-by: Jens Axboe <[email protected]>
Acked-by: Stephen Hemminger <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
This commit is contained in:
Emese Revfy 2010-01-19 02:58:23 +01:00 • committed by Greg Kroah-Hartman
commit 52cf25d0ab
54 changed files with 69 additions and 70 deletions

View file

@ -73,7 +73,7 @@ static void legacy_release(struct kobject *kobj)
}
static struct kobj_type legacy_ktype = {
.sysfs_ops = &(struct sysfs_ops){
.sysfs_ops = &(const struct sysfs_ops){
.store = legacy_store, .show = legacy_show
},
.release = &legacy_release,

View file

@ -29,7 +29,7 @@ static ssize_t pci_slot_attr_store(struct kobject *kobj,
return attribute->store ? attribute->store(slot, buf, len) : -EIO;
}
static struct sysfs_ops pci_slot_sysfs_ops = {
static const struct sysfs_ops pci_slot_sysfs_ops = {
.show = pci_slot_attr_show,
.store = pci_slot_attr_store,
};