Commit 52cf25d0ab7f78eeecc59ac652ed5090f69b619e
Committed by
Greg Kroah-Hartman
1 parent
6c1733aca0
Exists in
master
and in
20 other branches
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>
Showing 54 changed files with 69 additions and 70 deletions Side-by-side Diff
- Documentation/kobject.txt
- arch/ia64/kernel/topology.c
- arch/powerpc/kernel/cacheinfo.c
- arch/sh/kernel/cpu/sh4/sq.c
- arch/x86/kernel/cpu/intel_cacheinfo.c
- arch/x86/kernel/cpu/mcheck/mce_amd.c
- block/blk-integrity.c
- block/blk-sysfs.c
- block/elevator.c
- drivers/base/bus.c
- drivers/base/class.c
- drivers/base/core.c
- drivers/base/sys.c
- drivers/block/pktcdvd.c
- drivers/cpufreq/cpufreq.c
- drivers/cpuidle/sysfs.c
- drivers/dma/ioat/dma.c
- drivers/dma/ioat/dma.h
- drivers/edac/edac_device_sysfs.c
- drivers/edac/edac_mc_sysfs.c
- drivers/edac/edac_pci_sysfs.c
- drivers/firmware/edd.c
- drivers/firmware/efivars.c
- drivers/firmware/iscsi_ibft.c
- drivers/firmware/memmap.c
- drivers/gpu/drm/ttm/ttm_bo.c
- drivers/gpu/drm/ttm/ttm_memory.c
- drivers/infiniband/core/cm.c
- drivers/infiniband/core/sysfs.c
- drivers/md/dm-sysfs.c
- drivers/md/md.c
- drivers/net/ibmveth.c
- drivers/net/iseries_veth.c
- drivers/parisc/pdc_stable.c
- drivers/pci/hotplug/fakephp.c
- drivers/pci/slot.c
- drivers/uio/uio.c
- drivers/uwb/wlp/sysfs.c
- drivers/video/omap2/dss/manager.c
- drivers/video/omap2/dss/overlay.c
- drivers/xen/sys-hypervisor.c
- fs/btrfs/sysfs.c
- fs/dlm/lockspace.c
- fs/ext4/super.c
- fs/gfs2/sys.c
- fs/ocfs2/cluster/masklog.c
- fs/sysfs/file.c
- include/linux/kobject.h
- kernel/params.c
- lib/kobject.c
- mm/slub.c
- net/bridge/br_private.h
- net/bridge/br_sysfs_if.c
- samples/kobject/kset-example.c
Documentation/kobject.txt
arch/ia64/kernel/topology.c
arch/powerpc/kernel/cacheinfo.c
arch/sh/kernel/cpu/sh4/sq.c
arch/x86/kernel/cpu/intel_cacheinfo.c
arch/x86/kernel/cpu/mcheck/mce_amd.c
block/blk-integrity.c
block/blk-sysfs.c
block/elevator.c
drivers/base/bus.c
... | ... | @@ -70,7 +70,7 @@ |
70 | 70 | return ret; |
71 | 71 | } |
72 | 72 | |
73 | -static struct sysfs_ops driver_sysfs_ops = { | |
73 | +static const struct sysfs_ops driver_sysfs_ops = { | |
74 | 74 | .show = drv_attr_show, |
75 | 75 | .store = drv_attr_store, |
76 | 76 | }; |
... | ... | @@ -115,7 +115,7 @@ |
115 | 115 | return ret; |
116 | 116 | } |
117 | 117 | |
118 | -static struct sysfs_ops bus_sysfs_ops = { | |
118 | +static const struct sysfs_ops bus_sysfs_ops = { | |
119 | 119 | .show = bus_attr_show, |
120 | 120 | .store = bus_attr_store, |
121 | 121 | }; |
drivers/base/class.c
drivers/base/core.c
drivers/base/sys.c
... | ... | @@ -54,7 +54,7 @@ |
54 | 54 | return -EIO; |
55 | 55 | } |
56 | 56 | |
57 | -static struct sysfs_ops sysfs_ops = { | |
57 | +static const struct sysfs_ops sysfs_ops = { | |
58 | 58 | .show = sysdev_show, |
59 | 59 | .store = sysdev_store, |
60 | 60 | }; |
... | ... | @@ -104,7 +104,7 @@ |
104 | 104 | return -EIO; |
105 | 105 | } |
106 | 106 | |
107 | -static struct sysfs_ops sysfs_class_ops = { | |
107 | +static const struct sysfs_ops sysfs_class_ops = { | |
108 | 108 | .show = sysdev_class_show, |
109 | 109 | .store = sysdev_class_store, |
110 | 110 | }; |
drivers/block/pktcdvd.c
drivers/cpufreq/cpufreq.c
drivers/cpuidle/sysfs.c
... | ... | @@ -195,7 +195,7 @@ |
195 | 195 | return ret; |
196 | 196 | } |
197 | 197 | |
198 | -static struct sysfs_ops cpuidle_sysfs_ops = { | |
198 | +static const struct sysfs_ops cpuidle_sysfs_ops = { | |
199 | 199 | .show = cpuidle_show, |
200 | 200 | .store = cpuidle_store, |
201 | 201 | }; |
... | ... | @@ -281,7 +281,7 @@ |
281 | 281 | return ret; |
282 | 282 | } |
283 | 283 | |
284 | -static struct sysfs_ops cpuidle_state_sysfs_ops = { | |
284 | +static const struct sysfs_ops cpuidle_state_sysfs_ops = { | |
285 | 285 | .show = cpuidle_state_show, |
286 | 286 | }; |
287 | 287 |
drivers/dma/ioat/dma.c
drivers/dma/ioat/dma.h
... | ... | @@ -346,7 +346,7 @@ |
346 | 346 | unsigned long *phys_complete); |
347 | 347 | void ioat_kobject_add(struct ioatdma_device *device, struct kobj_type *type); |
348 | 348 | void ioat_kobject_del(struct ioatdma_device *device); |
349 | -extern struct sysfs_ops ioat_sysfs_ops; | |
349 | +extern const struct sysfs_ops ioat_sysfs_ops; | |
350 | 350 | extern struct ioat_sysfs_entry ioat_version_attr; |
351 | 351 | extern struct ioat_sysfs_entry ioat_cap_attr; |
352 | 352 | #endif /* IOATDMA_H */ |
drivers/edac/edac_device_sysfs.c
... | ... | @@ -137,7 +137,7 @@ |
137 | 137 | } |
138 | 138 | |
139 | 139 | /* edac_dev file operations for an 'ctl_info' */ |
140 | -static struct sysfs_ops device_ctl_info_ops = { | |
140 | +static const struct sysfs_ops device_ctl_info_ops = { | |
141 | 141 | .show = edac_dev_ctl_info_show, |
142 | 142 | .store = edac_dev_ctl_info_store |
143 | 143 | }; |
... | ... | @@ -373,7 +373,7 @@ |
373 | 373 | } |
374 | 374 | |
375 | 375 | /* edac_dev file operations for an 'instance' */ |
376 | -static struct sysfs_ops device_instance_ops = { | |
376 | +static const struct sysfs_ops device_instance_ops = { | |
377 | 377 | .show = edac_dev_instance_show, |
378 | 378 | .store = edac_dev_instance_store |
379 | 379 | }; |
... | ... | @@ -476,7 +476,7 @@ |
476 | 476 | } |
477 | 477 | |
478 | 478 | /* edac_dev file operations for a 'block' */ |
479 | -static struct sysfs_ops device_block_ops = { | |
479 | +static const struct sysfs_ops device_block_ops = { | |
480 | 480 | .show = edac_dev_block_show, |
481 | 481 | .store = edac_dev_block_store |
482 | 482 | }; |
drivers/edac/edac_mc_sysfs.c
... | ... | @@ -245,7 +245,7 @@ |
245 | 245 | return -EIO; |
246 | 246 | } |
247 | 247 | |
248 | -static struct sysfs_ops csrowfs_ops = { | |
248 | +static const struct sysfs_ops csrowfs_ops = { | |
249 | 249 | .show = csrowdev_show, |
250 | 250 | .store = csrowdev_store |
251 | 251 | }; |
... | ... | @@ -575,7 +575,7 @@ |
575 | 575 | } |
576 | 576 | |
577 | 577 | /* Intermediate show/store table */ |
578 | -static struct sysfs_ops mci_ops = { | |
578 | +static const struct sysfs_ops mci_ops = { | |
579 | 579 | .show = mcidev_show, |
580 | 580 | .store = mcidev_store |
581 | 581 | }; |
drivers/edac/edac_pci_sysfs.c
... | ... | @@ -121,7 +121,7 @@ |
121 | 121 | } |
122 | 122 | |
123 | 123 | /* fs_ops table */ |
124 | -static struct sysfs_ops pci_instance_ops = { | |
124 | +static const struct sysfs_ops pci_instance_ops = { | |
125 | 125 | .show = edac_pci_instance_show, |
126 | 126 | .store = edac_pci_instance_store |
127 | 127 | }; |
... | ... | @@ -261,7 +261,7 @@ |
261 | 261 | return -EIO; |
262 | 262 | } |
263 | 263 | |
264 | -static struct sysfs_ops edac_pci_sysfs_ops = { | |
264 | +static const struct sysfs_ops edac_pci_sysfs_ops = { | |
265 | 265 | .show = edac_pci_dev_show, |
266 | 266 | .store = edac_pci_dev_store |
267 | 267 | }; |
drivers/firmware/edd.c
drivers/firmware/efivars.c
drivers/firmware/iscsi_ibft.c
drivers/firmware/memmap.c
drivers/gpu/drm/ttm/ttm_bo.c
drivers/gpu/drm/ttm/ttm_memory.c
drivers/infiniband/core/cm.c
drivers/infiniband/core/sysfs.c
drivers/md/dm-sysfs.c
drivers/md/md.c
... | ... | @@ -2642,7 +2642,7 @@ |
2642 | 2642 | mdk_rdev_t *rdev = container_of(ko, mdk_rdev_t, kobj); |
2643 | 2643 | kfree(rdev); |
2644 | 2644 | } |
2645 | -static struct sysfs_ops rdev_sysfs_ops = { | |
2645 | +static const struct sysfs_ops rdev_sysfs_ops = { | |
2646 | 2646 | .show = rdev_attr_show, |
2647 | 2647 | .store = rdev_attr_store, |
2648 | 2648 | }; |
... | ... | @@ -4059,7 +4059,7 @@ |
4059 | 4059 | kfree(mddev); |
4060 | 4060 | } |
4061 | 4061 | |
4062 | -static struct sysfs_ops md_sysfs_ops = { | |
4062 | +static const struct sysfs_ops md_sysfs_ops = { | |
4063 | 4063 | .show = md_attr_show, |
4064 | 4064 | .store = md_attr_store, |
4065 | 4065 | }; |
drivers/net/ibmveth.c
drivers/net/iseries_veth.c
... | ... | @@ -384,7 +384,7 @@ |
384 | 384 | NULL |
385 | 385 | }; |
386 | 386 | |
387 | -static struct sysfs_ops veth_cnx_sysfs_ops = { | |
387 | +static const struct sysfs_ops veth_cnx_sysfs_ops = { | |
388 | 388 | .show = veth_cnx_attribute_show |
389 | 389 | }; |
390 | 390 | |
... | ... | @@ -441,7 +441,7 @@ |
441 | 441 | NULL |
442 | 442 | }; |
443 | 443 | |
444 | -static struct sysfs_ops veth_port_sysfs_ops = { | |
444 | +static const struct sysfs_ops veth_port_sysfs_ops = { | |
445 | 445 | .show = veth_port_attribute_show |
446 | 446 | }; |
447 | 447 |
drivers/parisc/pdc_stable.c
drivers/pci/hotplug/fakephp.c
drivers/pci/slot.c
drivers/uio/uio.c
... | ... | @@ -129,7 +129,7 @@ |
129 | 129 | return entry->show(mem, buf); |
130 | 130 | } |
131 | 131 | |
132 | -static struct sysfs_ops map_sysfs_ops = { | |
132 | +static const struct sysfs_ops map_sysfs_ops = { | |
133 | 133 | .show = map_type_show, |
134 | 134 | }; |
135 | 135 | |
... | ... | @@ -217,7 +217,7 @@ |
217 | 217 | return entry->show(port, buf); |
218 | 218 | } |
219 | 219 | |
220 | -static struct sysfs_ops portio_sysfs_ops = { | |
220 | +static const struct sysfs_ops portio_sysfs_ops = { | |
221 | 221 | .show = portio_type_show, |
222 | 222 | }; |
223 | 223 |
drivers/uwb/wlp/sysfs.c
drivers/video/omap2/dss/manager.c
drivers/video/omap2/dss/overlay.c
drivers/xen/sys-hypervisor.c
fs/btrfs/sysfs.c
... | ... | @@ -164,12 +164,12 @@ |
164 | 164 | complete(&root->kobj_unregister); |
165 | 165 | } |
166 | 166 | |
167 | -static struct sysfs_ops btrfs_super_attr_ops = { | |
167 | +static const struct sysfs_ops btrfs_super_attr_ops = { | |
168 | 168 | .show = btrfs_super_attr_show, |
169 | 169 | .store = btrfs_super_attr_store, |
170 | 170 | }; |
171 | 171 | |
172 | -static struct sysfs_ops btrfs_root_attr_ops = { | |
172 | +static const struct sysfs_ops btrfs_root_attr_ops = { | |
173 | 173 | .show = btrfs_root_attr_show, |
174 | 174 | .store = btrfs_root_attr_store, |
175 | 175 | }; |
fs/dlm/lockspace.c
fs/ext4/super.c
fs/gfs2/sys.c
fs/ocfs2/cluster/masklog.c
fs/sysfs/file.c
... | ... | @@ -53,7 +53,7 @@ |
53 | 53 | size_t count; |
54 | 54 | loff_t pos; |
55 | 55 | char * page; |
56 | - struct sysfs_ops * ops; | |
56 | + const struct sysfs_ops * ops; | |
57 | 57 | struct mutex mutex; |
58 | 58 | int needs_read_fill; |
59 | 59 | int event; |
... | ... | @@ -75,7 +75,7 @@ |
75 | 75 | { |
76 | 76 | struct sysfs_dirent *attr_sd = dentry->d_fsdata; |
77 | 77 | struct kobject *kobj = attr_sd->s_parent->s_dir.kobj; |
78 | - struct sysfs_ops * ops = buffer->ops; | |
78 | + const struct sysfs_ops * ops = buffer->ops; | |
79 | 79 | int ret = 0; |
80 | 80 | ssize_t count; |
81 | 81 | |
... | ... | @@ -199,7 +199,7 @@ |
199 | 199 | { |
200 | 200 | struct sysfs_dirent *attr_sd = dentry->d_fsdata; |
201 | 201 | struct kobject *kobj = attr_sd->s_parent->s_dir.kobj; |
202 | - struct sysfs_ops * ops = buffer->ops; | |
202 | + const struct sysfs_ops * ops = buffer->ops; | |
203 | 203 | int rc; |
204 | 204 | |
205 | 205 | /* need attr_sd for attr and ops, its parent for kobj */ |
... | ... | @@ -335,7 +335,7 @@ |
335 | 335 | struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata; |
336 | 336 | struct kobject *kobj = attr_sd->s_parent->s_dir.kobj; |
337 | 337 | struct sysfs_buffer *buffer; |
338 | - struct sysfs_ops *ops; | |
338 | + const struct sysfs_ops *ops; | |
339 | 339 | int error = -EACCES; |
340 | 340 | char *p; |
341 | 341 |
include/linux/kobject.h
... | ... | @@ -106,7 +106,7 @@ |
106 | 106 | |
107 | 107 | struct kobj_type { |
108 | 108 | void (*release)(struct kobject *kobj); |
109 | - struct sysfs_ops *sysfs_ops; | |
109 | + const struct sysfs_ops *sysfs_ops; | |
110 | 110 | struct attribute **default_attrs; |
111 | 111 | }; |
112 | 112 | |
... | ... | @@ -132,7 +132,7 @@ |
132 | 132 | const char *buf, size_t count); |
133 | 133 | }; |
134 | 134 | |
135 | -extern struct sysfs_ops kobj_sysfs_ops; | |
135 | +extern const struct sysfs_ops kobj_sysfs_ops; | |
136 | 136 | |
137 | 137 | /** |
138 | 138 | * struct kset - a set of kobjects of a specific type, belonging to a specific subsystem. |
kernel/params.c
lib/kobject.c
mm/slub.c
net/bridge/br_private.h
net/bridge/br_sysfs_if.c
samples/kobject/kset-example.c