Skip to content

Commit 2239838

Browse files
t-8chaxboe
authored andcommitted
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>
1 parent e80fd7a commit 2239838

1 file changed

Lines changed: 23 additions & 23 deletions

File tree

block/blk-sysfs.c

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -581,27 +581,27 @@ static int queue_wc_store(struct gendisk *disk, const char *page,
581581
return 0;
582582
}
583583

584-
#define QUEUE_RO_ENTRY(_prefix, _name) \
585-
static struct queue_sysfs_entry _prefix##_entry = { \
586-
.attr = { .name = _name, .mode = 0444 }, \
587-
.show = _prefix##_show, \
584+
#define QUEUE_RO_ENTRY(_prefix, _name) \
585+
static const struct queue_sysfs_entry _prefix##_entry = { \
586+
.attr = { .name = _name, .mode = 0444 }, \
587+
.show = _prefix##_show, \
588588
};
589589

590-
#define QUEUE_RW_ENTRY(_prefix, _name) \
591-
static struct queue_sysfs_entry _prefix##_entry = { \
592-
.attr = { .name = _name, .mode = 0644 }, \
593-
.show = _prefix##_show, \
594-
.store = _prefix##_store, \
590+
#define QUEUE_RW_ENTRY(_prefix, _name) \
591+
static const struct queue_sysfs_entry _prefix##_entry = { \
592+
.attr = { .name = _name, .mode = 0644 }, \
593+
.show = _prefix##_show, \
594+
.store = _prefix##_store, \
595595
};
596596

597597
#define QUEUE_LIM_RO_ENTRY(_prefix, _name) \
598-
static struct queue_sysfs_entry _prefix##_entry = { \
598+
static const struct queue_sysfs_entry _prefix##_entry = { \
599599
.attr = { .name = _name, .mode = 0444 }, \
600600
.show_limit = _prefix##_show, \
601601
}
602602

603603
#define QUEUE_LIM_RW_ENTRY(_prefix, _name) \
604-
static struct queue_sysfs_entry _prefix##_entry = { \
604+
static const struct queue_sysfs_entry _prefix##_entry = { \
605605
.attr = { .name = _name, .mode = 0644 }, \
606606
.show_limit = _prefix##_show, \
607607
.store_limit = _prefix##_store, \
@@ -665,7 +665,7 @@ QUEUE_LIM_RO_ENTRY(queue_virt_boundary_mask, "virt_boundary_mask");
665665
QUEUE_LIM_RO_ENTRY(queue_dma_alignment, "dma_alignment");
666666

667667
/* legacy alias for logical_block_size: */
668-
static struct queue_sysfs_entry queue_hw_sector_size_entry = {
668+
static const struct queue_sysfs_entry queue_hw_sector_size_entry = {
669669
.attr = {.name = "hw_sector_size", .mode = 0444 },
670670
.show_limit = queue_logical_block_size_show,
671671
};
@@ -731,7 +731,7 @@ QUEUE_RW_ENTRY(queue_wb_lat, "wbt_lat_usec");
731731
#endif
732732

733733
/* Common attributes for bio-based and request-based queues. */
734-
static struct attribute *queue_attrs[] = {
734+
static const struct attribute *const queue_attrs[] = {
735735
/*
736736
* Attributes which are protected with q->limits_lock.
737737
*/
@@ -791,7 +791,7 @@ static struct attribute *queue_attrs[] = {
791791
};
792792

793793
/* Request-based queue attributes that are not relevant for bio-based queues. */
794-
static struct attribute *blk_mq_queue_attrs[] = {
794+
static const struct attribute *const blk_mq_queue_attrs[] = {
795795
/*
796796
* Attributes which require some form of locking other than
797797
* q->sysfs_lock.
@@ -811,7 +811,7 @@ static struct attribute *blk_mq_queue_attrs[] = {
811811
NULL,
812812
};
813813

814-
static umode_t queue_attr_visible(struct kobject *kobj, struct attribute *attr,
814+
static umode_t queue_attr_visible(struct kobject *kobj, const struct attribute *attr,
815815
int n)
816816
{
817817
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,
827827
}
828828

829829
static umode_t blk_mq_queue_attr_visible(struct kobject *kobj,
830-
struct attribute *attr, int n)
830+
const struct attribute *attr, int n)
831831
{
832832
struct gendisk *disk = container_of(kobj, struct gendisk, queue_kobj);
833833
struct request_queue *q = disk->queue;
@@ -841,17 +841,17 @@ static umode_t blk_mq_queue_attr_visible(struct kobject *kobj,
841841
return attr->mode;
842842
}
843843

844-
static struct attribute_group queue_attr_group = {
845-
.attrs = queue_attrs,
846-
.is_visible = queue_attr_visible,
844+
static const struct attribute_group queue_attr_group = {
845+
.attrs_const = queue_attrs,
846+
.is_visible_const = queue_attr_visible,
847847
};
848848

849-
static struct attribute_group blk_mq_queue_attr_group = {
850-
.attrs = blk_mq_queue_attrs,
851-
.is_visible = blk_mq_queue_attr_visible,
849+
static const struct attribute_group blk_mq_queue_attr_group = {
850+
.attrs_const = blk_mq_queue_attrs,
851+
.is_visible_const = blk_mq_queue_attr_visible,
852852
};
853853

854-
#define to_queue(atr) container_of((atr), struct queue_sysfs_entry, attr)
854+
#define to_queue(atr) container_of_const((atr), struct queue_sysfs_entry, attr)
855855

856856
static ssize_t
857857
queue_attr_show(struct kobject *kobj, struct attribute *attr, char *page)

0 commit comments

Comments
 (0)