Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

bcache: make kobj_type structures constant

Since commit ee6d3dd4ed48 ("driver core: make kobj_type constant.")
the driver core allows the usage of const struct kobj_type.

Take advantage of this to constify the structure definitions to prevent
modification at runtime.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Signed-off-by: Coly Li <colyli@suse.de>
Link: https://lore.kernel.org/r/20230615121223.22502-3-colyli@suse.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Thomas Weißschuh and committed by
Jens Axboe
b98dd0b0 a301b2de

+6 -6
+5 -5
drivers/md/bcache/bcache.h
··· 1004 1004 extern struct mutex bch_register_lock; 1005 1005 extern struct list_head bch_cache_sets; 1006 1006 1007 - extern struct kobj_type bch_cached_dev_ktype; 1008 - extern struct kobj_type bch_flash_dev_ktype; 1009 - extern struct kobj_type bch_cache_set_ktype; 1010 - extern struct kobj_type bch_cache_set_internal_ktype; 1011 - extern struct kobj_type bch_cache_ktype; 1007 + extern const struct kobj_type bch_cached_dev_ktype; 1008 + extern const struct kobj_type bch_flash_dev_ktype; 1009 + extern const struct kobj_type bch_cache_set_ktype; 1010 + extern const struct kobj_type bch_cache_set_internal_ktype; 1011 + extern const struct kobj_type bch_cache_ktype; 1012 1012 1013 1013 void bch_cached_dev_release(struct kobject *kobj); 1014 1014 void bch_flash_dev_release(struct kobject *kobj);
+1 -1
drivers/md/bcache/sysfs.h
··· 3 3 #define _BCACHE_SYSFS_H_ 4 4 5 5 #define KTYPE(type) \ 6 - struct kobj_type type ## _ktype = { \ 6 + const struct kobj_type type ## _ktype = { \ 7 7 .release = type ## _release, \ 8 8 .sysfs_ops = &((const struct sysfs_ops) { \ 9 9 .show = type ## _show, \