Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Thomas Weißschuh and committed by
Jens Axboe
22398387 e80fd7a0

+23 -23
+23 -23
block/blk-sysfs.c
··· 581 581 return 0; 582 582 } 583 583 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, \ 588 588 }; 589 589 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, \ 595 595 }; 596 596 597 597 #define QUEUE_LIM_RO_ENTRY(_prefix, _name) \ 598 - static struct queue_sysfs_entry _prefix##_entry = { \ 598 + static const struct queue_sysfs_entry _prefix##_entry = { \ 599 599 .attr = { .name = _name, .mode = 0444 }, \ 600 600 .show_limit = _prefix##_show, \ 601 601 } 602 602 603 603 #define QUEUE_LIM_RW_ENTRY(_prefix, _name) \ 604 - static struct queue_sysfs_entry _prefix##_entry = { \ 604 + static const struct queue_sysfs_entry _prefix##_entry = { \ 605 605 .attr = { .name = _name, .mode = 0644 }, \ 606 606 .show_limit = _prefix##_show, \ 607 607 .store_limit = _prefix##_store, \ ··· 665 665 QUEUE_LIM_RO_ENTRY(queue_dma_alignment, "dma_alignment"); 666 666 667 667 /* 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 = { 669 669 .attr = {.name = "hw_sector_size", .mode = 0444 }, 670 670 .show_limit = queue_logical_block_size_show, 671 671 }; ··· 731 731 #endif 732 732 733 733 /* Common attributes for bio-based and request-based queues. */ 734 - static struct attribute *queue_attrs[] = { 734 + static const struct attribute *const queue_attrs[] = { 735 735 /* 736 736 * Attributes which are protected with q->limits_lock. 737 737 */ ··· 791 791 }; 792 792 793 793 /* 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[] = { 795 795 /* 796 796 * Attributes which require some form of locking other than 797 797 * q->sysfs_lock. ··· 811 811 NULL, 812 812 }; 813 813 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, 815 815 int n) 816 816 { 817 817 struct gendisk *disk = container_of(kobj, struct gendisk, queue_kobj); ··· 827 827 } 828 828 829 829 static umode_t blk_mq_queue_attr_visible(struct kobject *kobj, 830 - struct attribute *attr, int n) 830 + const struct attribute *attr, int n) 831 831 { 832 832 struct gendisk *disk = container_of(kobj, struct gendisk, queue_kobj); 833 833 struct request_queue *q = disk->queue; ··· 841 841 return attr->mode; 842 842 } 843 843 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, 847 847 }; 848 848 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, 852 852 }; 853 853 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) 855 855 856 856 static ssize_t 857 857 queue_attr_show(struct kobject *kobj, struct attribute *attr, char *page)