Commit 5f622417 authored by Thomas Weißschuh's avatar Thomas Weißschuh Committed by Jens Axboe
Browse files

block: make kobj_type structures constant



Since commit ee6d3dd4 ("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: default avatarThomas Weißschuh <linux@weissschuh.net>
Link: https://lore.kernel.org/r/20230208-kobj_type-block-v1-1-0b3eafd7d983@weissschuh.net


Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 23f3e327
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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,
+2 −2
Original line number Diff line number Diff line
@@ -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,
};

+1 −1
Original line number Diff line number Diff line
@@ -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,
};
+3 −3
Original line number Diff line number Diff line
@@ -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,
+1 −1
Original line number Diff line number Diff line
@@ -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,
Loading