Skip to content

Commit f8c7511

Browse files
rbmarliereaxboe
authored andcommitted
block: make block_class constant
Since commit 43a7206 ("driver core: class: make class_register() take a const *"), the driver core allows for struct class to be in read-only memory, so move the block_class structure to be declared at build time placing it into read-only memory, instead of having to be dynamically allocated at boot time. Cc: Greg Kroah-Hartman <[email protected]> Suggested-by: Greg Kroah-Hartman <[email protected]> Signed-off-by: Ricardo B. Marliere <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 33bffbb commit f8c7511

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

block/genhd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1201,7 +1201,7 @@ static int block_uevent(const struct device *dev, struct kobj_uevent_env *env)
12011201
return add_uevent_var(env, "DISKSEQ=%llu", disk->diskseq);
12021202
}
12031203

1204-
struct class block_class = {
1204+
const struct class block_class = {
12051205
.name = "block",
12061206
.dev_uevent = block_uevent,
12071207
};

drivers/base/base.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ static inline int devtmpfs_init(void) { return 0; }
207207
#endif
208208

209209
#ifdef CONFIG_BLOCK
210-
extern struct class block_class;
210+
extern const struct class block_class;
211211
static inline bool is_blockdev(struct device *dev)
212212
{
213213
return dev->class == &block_class;

include/linux/blkdev.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ struct blk_crypto_profile;
4242

4343
extern const struct device_type disk_type;
4444
extern const struct device_type part_type;
45-
extern struct class block_class;
45+
extern const struct class block_class;
4646

4747
/*
4848
* Maximum number of blkcg policies allowed to be registered concurrently.

0 commit comments

Comments
 (0)