constify struct sysfs_ops
Subsystems (9)
PATCH 3/3 constify struct sysfs_ops
.. as again all consumers of it don't require it to be modifiable.
As before, the patch doesn't change all instances where 'const' could have been added as a result of the base structure changes, only where either the change has a real effect (the module loader doesn't enforce read-only section attributes at present, so only built-in files matter) or where compiler warnings would result otherwise.
Signed-off-by Jan Beulich <[email protected]>
Cc Tony Luck <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Jens Axboe <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
--- Documentation/kobject.txt | 2 +- arch/ia64/kernel/topology.c | 2 +- arch/x86/kernel/cpu/intel_cacheinfo.c | 2 +- arch/x86/kernel/cpu/mcheck/mce_amd_64.c | 2 +- block/elevator.c | 2 +- block/genhd.c | 2 +- block/ll_rw_blk.c | 2 +- drivers/base/bus.c | 4 ++-- drivers/base/class.c | 4 ++-- drivers/base/core.c | 2 +- drivers/base/sys.c | 4 ++-- drivers/cpufreq/cpufreq.c | 2 +- drivers/cpuidle/sysfs.c | 4 ++-- drivers/pci/pci-driver.c | 2 +- fs/partitions/check.c | 2 +- fs/sysfs/file.c | 10 +++++----- include/linux/kobject.h | 2 +- kernel/params.c | 10 +--------- mm/slub.c | 2 +- 19 files changed, 27 insertions(+), 35 deletions(-)
Documentation/kobject.txt +1 -1
@@ -262,7 +262,7 @@ embedded in a subsystem itself. struct kobj_type { void (*release)(struct kobject *); - struct sysfs_ops * sysfs_ops; + const struct sysfs_ops *sysfs_ops; struct attribute *const *default_attrs; };
arch/ia64/kernel/topology.c +1 -1
@@ -267,7 +267,7 @@ static ssize_t cache_show(struct kobjectreturn ret; } -static struct sysfs_ops cache_sysfs_ops = { +static const struct sysfs_ops cache_sysfs_ops = { .show = cache_show };
arch/x86/kernel/cpu/intel_cacheinfo.c +1 -1
@@ -668,7 +668,7 @@ static ssize_t store(struct kobject * koreturn 0 ; } -static struct sysfs_ops sysfs_ops = { +static const struct sysfs_ops sysfs_ops = { .show = show, .store = store, };
arch/x86/kernel/cpu/mcheck/mce_amd_64.c +1 -1
@@ -377,7 +377,7 @@ static ssize_t store(struct kobject *kobreturn ret; } -static struct sysfs_ops threshold_ops = { +static const struct sysfs_ops threshold_ops = { .show = show, .store = store, };
block/elevator.c +1 -1
@@ -916,7 +916,7 @@ elv_attr_store(struct kobject *kobj, strreturn error; } -static struct sysfs_ops elv_sysfs_ops = { +static const struct sysfs_ops elv_sysfs_ops = { .show = elv_attr_show, .store = elv_attr_store, };
block/genhd.c +1 -1
@@ -389,7 +389,7 @@ static ssize_t disk_attr_store(struct koreturn ret; } -static struct sysfs_ops disk_sysfs_ops = { +static const struct sysfs_ops disk_sysfs_ops = { .show = &disk_attr_show, .store = &disk_attr_store, };
block/ll_rw_blk.c +1 -1
@@ -4162,7 +4162,7 @@ queue_attr_store(struct kobject *kobj, sreturn res; } -static struct sysfs_ops queue_sysfs_ops = { +static const struct sysfs_ops queue_sysfs_ops = { .show = queue_attr_show, .store = queue_attr_store, };
drivers/base/bus.c +2 -2
@@ -66,7 +66,7 @@ drv_attr_store(struct kobject * kobj, streturn ret; } -static struct sysfs_ops driver_sysfs_ops = { +static const struct sysfs_ops driver_sysfs_ops = { .show = drv_attr_show, .store = drv_attr_store, };
@@ -125,7 +125,7 @@ bus_attr_store(struct kobject * kobj, streturn ret; } -static struct sysfs_ops bus_sysfs_ops = { +static const struct sysfs_ops bus_sysfs_ops = { .show = bus_attr_show, .store = bus_attr_store, };
drivers/base/class.c +2 -2
@@ -60,7 +60,7 @@ static void class_release(struct kobject "be careful\n", class->name); } -static struct sysfs_ops class_sysfs_ops = { +static const struct sysfs_ops class_sysfs_ops = { .show = class_attr_show, .store = class_attr_store, };
@@ -299,7 +299,7 @@ class_device_attr_store(struct kobject *return ret; } -static struct sysfs_ops class_dev_sysfs_ops = { +static const struct sysfs_ops class_dev_sysfs_ops = { .show = class_device_attr_show, .store = class_device_attr_store, };
drivers/base/core.c +1 -1
@@ -76,7 +76,7 @@ dev_attr_store(struct kobject * kobj, streturn ret; } -static struct sysfs_ops dev_sysfs_ops = { +static const struct sysfs_ops dev_sysfs_ops = { .show = dev_attr_show, .store = dev_attr_store, };
drivers/base/sys.c +2 -2
@@ -55,7 +55,7 @@ sysdev_store(struct kobject * kobj, strureturn -EIO ; } -static struct sysfs_ops sysfs_ops = { +static const struct sysfs_ops sysfs_ops = { .show = sysdev_show, .store = sysdev_store, };
@@ -105,7 +105,7 @@ static ssize_t sysdev_class_store(structreturn -EIO ; } -static struct sysfs_ops sysfs_class_ops = { +static const struct sysfs_ops sysfs_class_ops = { .show = sysdev_class_show, .store = sysdev_class_store, };
drivers/cpufreq/cpufreq.c +1 -1
@@ -694,7 +694,7 @@ static void cpufreq_sysfs_release(structcomplete (&policy->kobj_unregister); } -static struct sysfs_ops sysfs_ops = { +static const struct sysfs_ops sysfs_ops = { .show = show, .store = store, };
drivers/cpuidle/sysfs.c +2 -2
@@ -186,7 +186,7 @@ static ssize_t cpuidle_store(struct kobjreturn ret; } -static struct sysfs_ops cpuidle_sysfs_ops = { +static const struct sysfs_ops cpuidle_sysfs_ops = { .show = cpuidle_show, .store = cpuidle_store, };
@@ -258,7 +258,7 @@ static ssize_t cpuidle_state_show(structreturn ret; } -static struct sysfs_ops cpuidle_state_sysfs_ops = { +static const struct sysfs_ops cpuidle_state_sysfs_ops = { .show = cpuidle_state_show, };
drivers/pci/pci-driver.c +1 -1
@@ -388,7 +388,7 @@ pci_driver_attr_store(struct kobject * kreturn ret; } -static struct sysfs_ops pci_driver_sysfs_ops = { +static const struct sysfs_ops pci_driver_sysfs_ops = { .show = pci_driver_attr_show, .store = pci_driver_attr_store, };
fs/partitions/check.c +1 -1
@@ -228,7 +228,7 @@ part_attr_store(struct kobject * kobj, sreturn ret; } -static struct sysfs_ops part_sysfs_ops = { +static const struct sysfs_ops part_sysfs_ops = { .show = part_attr_show, .store = part_attr_store, };
fs/sysfs/file.c +5 -5
@@ -52,7 +52,7 @@ subsys_attr_store(struct kobject * kobj,return ret; } -static struct sysfs_ops subsys_sysfs_ops = { +static const struct sysfs_ops subsys_sysfs_ops = { .show = subsys_attr_show, .store = subsys_attr_store, };
@@ -79,7 +79,7 @@ struct sysfs_buffer {size_t count;loff_t pos;char * page; -struct sysfs_ops * ops; +const struct sysfs_ops * ops;struct mutex mutex;int needs_read_fill;int event;
@@ -101,7 +101,7 @@ static int fill_read_buffer(struct dentr {struct sysfs_dirent *attr_sd = dentry->d_fsdata;struct kobject *kobj = attr_sd->s_parent->s_dir.kobj; -struct sysfs_ops * ops = buffer->ops; +const struct sysfs_ops * ops = buffer->ops;int ret =0 ;ssize_t count;
@@ -220,7 +220,7 @@ flush_write_buffer(struct dentry * dentr {struct sysfs_dirent *attr_sd = dentry->d_fsdata;struct kobject *kobj = attr_sd->s_parent->s_dir.kobj; -struct sysfs_ops * ops = buffer->ops; +const struct sysfs_ops * ops = buffer->ops;int rc;/* need attr_sd for attr and ops, its parent for kobj */
@@ -355,7 +355,7 @@ static int sysfs_open_file(struct inodestruct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata;struct kobject *kobj = attr_sd->s_parent->s_dir.kobj;struct sysfs_buffer * buffer; -struct sysfs_ops * ops =NULL ; +const struct sysfs_ops * ops =NULL ;int error;/* need attr_sd for attr and ops, its parent for kobj */
include/linux/kobject.h +1 -1
@@ -101,7 +101,7 @@ extern char * kobject_get_path(struct kostruct kobj_type {void (*release)(struct kobject *); -struct sysfs_ops * sysfs_ops; +const struct sysfs_ops *sysfs_ops;struct attribute *const *default_attrs; };
kernel/params.c +1 -9
@@ -673,7 +673,7 @@ static ssize_t module_attr_store(structreturn ret; } -static struct sysfs_ops module_sysfs_ops = { +static const struct sysfs_ops module_sysfs_ops = { .show = module_attr_show, .store = module_attr_store, };
@@ -730,14 +730,6 @@ static int __init param_sysfs_init(void) return 0; }subsys_initcall (param_sysfs_init); - -#else -#if 0 -static struct sysfs_ops module_sysfs_ops = { - .show =NULL , - .store =NULL , -}; -#endif #endif EXPORT_SYMBOL (param_set_byte);
mm/slub.c +1 -1
@@ -3940,7 +3940,7 @@ static ssize_t slab_attr_store(struct koreturn err; } -static struct sysfs_ops slab_sysfs_ops = { +static const struct sysfs_ops slab_sysfs_ops = { .show = slab_attr_show, .store = slab_attr_store, };