block: make kobj_type structures constant
authorThomas Weißschuh <linux@weissschuh.net>
Wed, 8 Feb 2023 04:01:22 +0000 (04:01 +0000)
committerJens Axboe <axboe@kernel.dk>
Thu, 9 Feb 2023 16:38:16 +0000 (09:38 -0700)
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>
Link: https://lore.kernel.org/r/20230208-kobj_type-block-v1-1-0b3eafd7d983@weissschuh.net
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-crypto-sysfs.c
block/blk-ia-ranges.c
block/blk-integrity.c
block/blk-mq-sysfs.c
block/blk-sysfs.c
block/elevator.c

index 55268edc06253d5c3f66af66745b640f5eebec76..a304434489bacf05550c5c2f9c6f0f27b335323d 100644 (file)
@@ -116,7 +116,7 @@ static void blk_crypto_release(struct kobject *kobj)
        kfree(container_of(kobj, struct blk_crypto_kobj, kobj));
 }
 
-static struct kobj_type blk_crypto_ktype = {
+static const struct kobj_type blk_crypto_ktype = {
        .default_groups = blk_crypto_attr_groups,
        .sysfs_ops      = &blk_crypto_attr_ops,
        .release        = blk_crypto_release,
index 2141931ddd37e06d9605fc8a9609a47228a5151e..c9eb4241e048390c814b4e9ceba5ae035de07a60 100644 (file)
@@ -75,7 +75,7 @@ static void blk_ia_range_sysfs_nop_release(struct kobject *kobj)
 {
 }
 
-static struct kobj_type blk_ia_range_ktype = {
+static const struct kobj_type blk_ia_range_ktype = {
        .sysfs_ops      = &blk_ia_range_sysfs_ops,
        .default_groups = blk_ia_range_groups,
        .release        = blk_ia_range_sysfs_nop_release,
@@ -94,7 +94,7 @@ static void blk_ia_ranges_sysfs_release(struct kobject *kobj)
        kfree(iars);
 }
 
-static struct kobj_type blk_ia_ranges_ktype = {
+static const struct kobj_type blk_ia_ranges_ktype = {
        .release        = blk_ia_ranges_sysfs_release,
 };
 
index 69eed260a823907ad8b9955cf06607a31a52f528..8f01d786f5cb95e9fe62c1e429b97656d701bae9 100644 (file)
@@ -356,7 +356,7 @@ static const struct sysfs_ops integrity_ops = {
        .store  = &integrity_attr_store,
 };
 
-static struct kobj_type integrity_ktype = {
+static const struct kobj_type integrity_ktype = {
        .default_groups = integrity_groups,
        .sysfs_ops      = &integrity_ops,
 };
index 2dfd7853a804687ff46dd3449cab3c35dccef4be..1b2b0d258e465f74332e909c5b0e9452cbed4cb7 100644 (file)
@@ -129,15 +129,15 @@ static const struct sysfs_ops blk_mq_hw_sysfs_ops = {
        .show   = blk_mq_hw_sysfs_show,
 };
 
-static struct kobj_type blk_mq_ktype = {
+static const struct kobj_type blk_mq_ktype = {
        .release        = blk_mq_sysfs_release,
 };
 
-static struct kobj_type blk_mq_ctx_ktype = {
+static const struct kobj_type blk_mq_ctx_ktype = {
        .release        = blk_mq_ctx_sysfs_release,
 };
 
-static struct kobj_type blk_mq_hw_ktype = {
+static const struct kobj_type blk_mq_hw_ktype = {
        .sysfs_ops      = &blk_mq_hw_sysfs_ops,
        .default_groups = default_hw_ctx_groups,
        .release        = blk_mq_hw_sysfs_release,
index d70ebecb534798d56e95a95bf59b0aed4d286353..f1fce1c7fa44b819caa60a305c7582e0d51f70ee 100644 (file)
@@ -765,7 +765,7 @@ static void blk_queue_release(struct kobject *kobj)
        /* nothing to do here, all data is associated with the parent gendisk */
 }
 
-static struct kobj_type blk_queue_ktype = {
+static const struct kobj_type blk_queue_ktype = {
        .default_groups = blk_queue_attr_groups,
        .sysfs_ops      = &queue_sysfs_ops,
        .release        = blk_queue_release,
index adee58e48e2dd8b6b88c952411240d67eaf4548f..24909069f872889506ce2b77313c5f8fd46b1c66 100644 (file)
@@ -126,7 +126,7 @@ static struct elevator_type *elevator_find_get(struct request_queue *q,
        return e;
 }
 
-static struct kobj_type elv_ktype;
+static const struct kobj_type elv_ktype;
 
 struct elevator_queue *elevator_alloc(struct request_queue *q,
                                  struct elevator_type *e)
@@ -455,7 +455,7 @@ static const struct sysfs_ops elv_sysfs_ops = {
        .store  = elv_attr_store,
 };
 
-static struct kobj_type elv_ktype = {
+static const struct kobj_type elv_ktype = {
        .sysfs_ops      = &elv_sysfs_ops,
        .release        = elevator_release,
 };