Skip to content

Commit 52cf25d

Browse files
ephox-gcc-pluginsgregkh
authored andcommitted
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>
1 parent 6c1733a commit 52cf25d

54 files changed

Lines changed: 69 additions & 70 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎Documentation/kobject.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ kobj_type:
266266

267267
struct kobj_type {
268268
void (*release)(struct kobject *);
269-
struct sysfs_ops *sysfs_ops;
269+
const struct sysfs_ops *sysfs_ops;
270270
struct attribute **default_attrs;
271271
};
272272

‎arch/ia64/kernel/topology.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ static ssize_t cache_show(struct kobject * kobj, struct attribute * attr, char *
282282
return ret;
283283
}
284284

285-
static struct sysfs_ops cache_sysfs_ops = {
285+
static const struct sysfs_ops cache_sysfs_ops = {
286286
.show = cache_show
287287
};
288288

‎arch/powerpc/kernel/cacheinfo.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,7 @@ static struct kobj_attribute *cache_index_opt_attrs[] = {
642642
&cache_assoc_attr,
643643
};
644644

645-
static struct sysfs_ops cache_index_ops = {
645+
static const struct sysfs_ops cache_index_ops = {
646646
.show = cache_index_show,
647647
};
648648

‎arch/sh/kernel/cpu/sh4/sq.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ static struct attribute *sq_sysfs_attrs[] = {
326326
NULL,
327327
};
328328

329-
static struct sysfs_ops sq_sysfs_ops = {
329+
static const struct sysfs_ops sq_sysfs_ops = {
330330
.show = sq_sysfs_show,
331331
.store = sq_sysfs_store,
332332
};

‎arch/x86/kernel/cpu/intel_cacheinfo.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -903,7 +903,7 @@ static ssize_t store(struct kobject *kobj, struct attribute *attr,
903903
return ret;
904904
}
905905

906-
static struct sysfs_ops sysfs_ops = {
906+
static const struct sysfs_ops sysfs_ops = {
907907
.show = show,
908908
.store = store,
909909
};

‎arch/x86/kernel/cpu/mcheck/mce_amd.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ static ssize_t store(struct kobject *kobj, struct attribute *attr,
388388
return ret;
389389
}
390390

391-
static struct sysfs_ops threshold_ops = {
391+
static const struct sysfs_ops threshold_ops = {
392392
.show = show,
393393
.store = store,
394394
};

‎block/blk-integrity.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ static struct attribute *integrity_attrs[] = {
278278
NULL,
279279
};
280280

281-
static struct sysfs_ops integrity_ops = {
281+
static const struct sysfs_ops integrity_ops = {
282282
.show = &integrity_attr_show,
283283
.store = &integrity_attr_store,
284284
};

‎block/blk-sysfs.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ static void blk_release_queue(struct kobject *kobj)
450450
kmem_cache_free(blk_requestq_cachep, q);
451451
}
452452

453-
static struct sysfs_ops queue_sysfs_ops = {
453+
static const struct sysfs_ops queue_sysfs_ops = {
454454
.show = queue_attr_show,
455455
.store = queue_attr_store,
456456
};

‎block/elevator.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -892,7 +892,7 @@ elv_attr_store(struct kobject *kobj, struct attribute *attr,
892892
return error;
893893
}
894894

895-
static struct sysfs_ops elv_sysfs_ops = {
895+
static const struct sysfs_ops elv_sysfs_ops = {
896896
.show = elv_attr_show,
897897
.store = elv_attr_store,
898898
};

‎drivers/base/bus.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ static ssize_t drv_attr_store(struct kobject *kobj, struct attribute *attr,
7070
return ret;
7171
}
7272

73-
static struct sysfs_ops driver_sysfs_ops = {
73+
static const struct sysfs_ops driver_sysfs_ops = {
7474
.show = drv_attr_show,
7575
.store = drv_attr_store,
7676
};
@@ -115,7 +115,7 @@ static ssize_t bus_attr_store(struct kobject *kobj, struct attribute *attr,
115115
return ret;
116116
}
117117

118-
static struct sysfs_ops bus_sysfs_ops = {
118+
static const struct sysfs_ops bus_sysfs_ops = {
119119
.show = bus_attr_show,
120120
.store = bus_attr_store,
121121
};

0 commit comments

Comments
 (0)