summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Weißschuh <linux@weissschuh.net>2026-03-17 01:43:51 +0300
committerJens Axboe <axboe@kernel.dk>2026-03-18 04:29:16 +0300
commit223983874d0366ac12d30eab3b633d699bdf763e (patch)
tree81e99f93e916bff2af0f4cf74a71f7fc635e882f
parente80fd7a08940093aad5ea247a42046b57709a7bd (diff)
downloadlinux-223983874d0366ac12d30eab3b633d699bdf763e.tar.xz
block: make queue_sysfs_entry instances const
The queue_sysfs_entry structures are never modified, mark them as const. Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Reviewed-by: John Garry <john.g.garry@oracle.com> Link: https://patch.msgid.link/20260316-b4-sysfs-const-attr-block-v1-1-a35d73b986b0@weissschuh.net Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--block/blk-sysfs.c46
1 files changed, 23 insertions, 23 deletions
diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
index 878b8a4b55bb..f22c1f253eb3 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -581,27 +581,27 @@ static int queue_wc_store(struct gendisk *disk, const char *page,
return 0;
}
-#define QUEUE_RO_ENTRY(_prefix, _name) \
-static struct queue_sysfs_entry _prefix##_entry = { \
- .attr = { .name = _name, .mode = 0444 }, \
- .show = _prefix##_show, \
+#define QUEUE_RO_ENTRY(_prefix, _name) \
+static const struct queue_sysfs_entry _prefix##_entry = { \
+ .attr = { .name = _name, .mode = 0444 }, \
+ .show = _prefix##_show, \
};
-#define QUEUE_RW_ENTRY(_prefix, _name) \
-static struct queue_sysfs_entry _prefix##_entry = { \
- .attr = { .name = _name, .mode = 0644 }, \
- .show = _prefix##_show, \
- .store = _prefix##_store, \
+#define QUEUE_RW_ENTRY(_prefix, _name) \
+static const struct queue_sysfs_entry _prefix##_entry = { \
+ .attr = { .name = _name, .mode = 0644 }, \
+ .show = _prefix##_show, \
+ .store = _prefix##_store, \
};
#define QUEUE_LIM_RO_ENTRY(_prefix, _name) \
-static struct queue_sysfs_entry _prefix##_entry = { \
+static const struct queue_sysfs_entry _prefix##_entry = { \
.attr = { .name = _name, .mode = 0444 }, \
.show_limit = _prefix##_show, \
}
#define QUEUE_LIM_RW_ENTRY(_prefix, _name) \
-static struct queue_sysfs_entry _prefix##_entry = { \
+static const struct queue_sysfs_entry _prefix##_entry = { \
.attr = { .name = _name, .mode = 0644 }, \
.show_limit = _prefix##_show, \
.store_limit = _prefix##_store, \
@@ -665,7 +665,7 @@ QUEUE_LIM_RO_ENTRY(queue_virt_boundary_mask, "virt_boundary_mask");
QUEUE_LIM_RO_ENTRY(queue_dma_alignment, "dma_alignment");
/* legacy alias for logical_block_size: */
-static struct queue_sysfs_entry queue_hw_sector_size_entry = {
+static const struct queue_sysfs_entry queue_hw_sector_size_entry = {
.attr = {.name = "hw_sector_size", .mode = 0444 },
.show_limit = queue_logical_block_size_show,
};
@@ -731,7 +731,7 @@ QUEUE_RW_ENTRY(queue_wb_lat, "wbt_lat_usec");
#endif
/* Common attributes for bio-based and request-based queues. */
-static struct attribute *queue_attrs[] = {
+static const struct attribute *const queue_attrs[] = {
/*
* Attributes which are protected with q->limits_lock.
*/
@@ -791,7 +791,7 @@ static struct attribute *queue_attrs[] = {
};
/* Request-based queue attributes that are not relevant for bio-based queues. */
-static struct attribute *blk_mq_queue_attrs[] = {
+static const struct attribute *const blk_mq_queue_attrs[] = {
/*
* Attributes which require some form of locking other than
* q->sysfs_lock.
@@ -811,7 +811,7 @@ static struct attribute *blk_mq_queue_attrs[] = {
NULL,
};
-static umode_t queue_attr_visible(struct kobject *kobj, struct attribute *attr,
+static umode_t queue_attr_visible(struct kobject *kobj, const struct attribute *attr,
int n)
{
struct gendisk *disk = container_of(kobj, struct gendisk, queue_kobj);
@@ -827,7 +827,7 @@ static umode_t queue_attr_visible(struct kobject *kobj, struct attribute *attr,
}
static umode_t blk_mq_queue_attr_visible(struct kobject *kobj,
- struct attribute *attr, int n)
+ const struct attribute *attr, int n)
{
struct gendisk *disk = container_of(kobj, struct gendisk, queue_kobj);
struct request_queue *q = disk->queue;
@@ -841,17 +841,17 @@ static umode_t blk_mq_queue_attr_visible(struct kobject *kobj,
return attr->mode;
}
-static struct attribute_group queue_attr_group = {
- .attrs = queue_attrs,
- .is_visible = queue_attr_visible,
+static const struct attribute_group queue_attr_group = {
+ .attrs_const = queue_attrs,
+ .is_visible_const = queue_attr_visible,
};
-static struct attribute_group blk_mq_queue_attr_group = {
- .attrs = blk_mq_queue_attrs,
- .is_visible = blk_mq_queue_attr_visible,
+static const struct attribute_group blk_mq_queue_attr_group = {
+ .attrs_const = blk_mq_queue_attrs,
+ .is_visible_const = blk_mq_queue_attr_visible,
};
-#define to_queue(atr) container_of((atr), struct queue_sysfs_entry, attr)
+#define to_queue(atr) container_of_const((atr), struct queue_sysfs_entry, attr)
static ssize_t
queue_attr_show(struct kobject *kobj, struct attribute *attr, char *page)