Skip to content

Commit 71c3ee5

Browse files
committed
Merge branch 'for-7.1/block' into for-next
* for-7.1/block: blk-mq: make blk_mq_hw_ctx_sysfs_entry instances const blk-crypto: make blk_crypto_attr instances const block: ia-ranges: make blk_ia_range_sysfs_entry instances const block: make queue_sysfs_entry instances const
2 parents bfa0914 + 3141e0e commit 71c3ee5

4 files changed

Lines changed: 51 additions & 51 deletions

File tree

block/blk-crypto-sysfs.c

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,58 +18,58 @@ struct blk_crypto_kobj {
1818
struct blk_crypto_attr {
1919
struct attribute attr;
2020
ssize_t (*show)(struct blk_crypto_profile *profile,
21-
struct blk_crypto_attr *attr, char *page);
21+
const struct blk_crypto_attr *attr, char *page);
2222
};
2323

2424
static struct blk_crypto_profile *kobj_to_crypto_profile(struct kobject *kobj)
2525
{
2626
return container_of(kobj, struct blk_crypto_kobj, kobj)->profile;
2727
}
2828

29-
static struct blk_crypto_attr *attr_to_crypto_attr(struct attribute *attr)
29+
static const struct blk_crypto_attr *attr_to_crypto_attr(const struct attribute *attr)
3030
{
31-
return container_of(attr, struct blk_crypto_attr, attr);
31+
return container_of_const(attr, struct blk_crypto_attr, attr);
3232
}
3333

3434
static ssize_t hw_wrapped_keys_show(struct blk_crypto_profile *profile,
35-
struct blk_crypto_attr *attr, char *page)
35+
const struct blk_crypto_attr *attr, char *page)
3636
{
3737
/* Always show supported, since the file doesn't exist otherwise. */
3838
return sysfs_emit(page, "supported\n");
3939
}
4040

4141
static ssize_t max_dun_bits_show(struct blk_crypto_profile *profile,
42-
struct blk_crypto_attr *attr, char *page)
42+
const struct blk_crypto_attr *attr, char *page)
4343
{
4444
return sysfs_emit(page, "%u\n", 8 * profile->max_dun_bytes_supported);
4545
}
4646

4747
static ssize_t num_keyslots_show(struct blk_crypto_profile *profile,
48-
struct blk_crypto_attr *attr, char *page)
48+
const struct blk_crypto_attr *attr, char *page)
4949
{
5050
return sysfs_emit(page, "%u\n", profile->num_slots);
5151
}
5252

5353
static ssize_t raw_keys_show(struct blk_crypto_profile *profile,
54-
struct blk_crypto_attr *attr, char *page)
54+
const struct blk_crypto_attr *attr, char *page)
5555
{
5656
/* Always show supported, since the file doesn't exist otherwise. */
5757
return sysfs_emit(page, "supported\n");
5858
}
5959

6060
#define BLK_CRYPTO_RO_ATTR(_name) \
61-
static struct blk_crypto_attr _name##_attr = __ATTR_RO(_name)
61+
static const struct blk_crypto_attr _name##_attr = __ATTR_RO(_name)
6262

6363
BLK_CRYPTO_RO_ATTR(hw_wrapped_keys);
6464
BLK_CRYPTO_RO_ATTR(max_dun_bits);
6565
BLK_CRYPTO_RO_ATTR(num_keyslots);
6666
BLK_CRYPTO_RO_ATTR(raw_keys);
6767

6868
static umode_t blk_crypto_is_visible(struct kobject *kobj,
69-
struct attribute *attr, int n)
69+
const struct attribute *attr, int n)
7070
{
7171
struct blk_crypto_profile *profile = kobj_to_crypto_profile(kobj);
72-
struct blk_crypto_attr *a = attr_to_crypto_attr(attr);
72+
const struct blk_crypto_attr *a = attr_to_crypto_attr(attr);
7373

7474
if (a == &hw_wrapped_keys_attr &&
7575
!(profile->key_types_supported & BLK_CRYPTO_KEY_TYPE_HW_WRAPPED))
@@ -81,7 +81,7 @@ static umode_t blk_crypto_is_visible(struct kobject *kobj,
8181
return 0444;
8282
}
8383

84-
static struct attribute *blk_crypto_attrs[] = {
84+
static const struct attribute *const blk_crypto_attrs[] = {
8585
&hw_wrapped_keys_attr.attr,
8686
&max_dun_bits_attr.attr,
8787
&num_keyslots_attr.attr,
@@ -90,22 +90,22 @@ static struct attribute *blk_crypto_attrs[] = {
9090
};
9191

9292
static const struct attribute_group blk_crypto_attr_group = {
93-
.attrs = blk_crypto_attrs,
94-
.is_visible = blk_crypto_is_visible,
93+
.attrs_const = blk_crypto_attrs,
94+
.is_visible_const = blk_crypto_is_visible,
9595
};
9696

9797
/*
9898
* The encryption mode attributes. To avoid hard-coding the list of encryption
9999
* modes, these are initialized at boot time by blk_crypto_sysfs_init().
100100
*/
101101
static struct blk_crypto_attr __blk_crypto_mode_attrs[BLK_ENCRYPTION_MODE_MAX];
102-
static struct attribute *blk_crypto_mode_attrs[BLK_ENCRYPTION_MODE_MAX + 1];
102+
static const struct attribute *blk_crypto_mode_attrs[BLK_ENCRYPTION_MODE_MAX + 1];
103103

104104
static umode_t blk_crypto_mode_is_visible(struct kobject *kobj,
105-
struct attribute *attr, int n)
105+
const struct attribute *attr, int n)
106106
{
107107
struct blk_crypto_profile *profile = kobj_to_crypto_profile(kobj);
108-
struct blk_crypto_attr *a = attr_to_crypto_attr(attr);
108+
const struct blk_crypto_attr *a = attr_to_crypto_attr(attr);
109109
int mode_num = a - __blk_crypto_mode_attrs;
110110

111111
if (profile->modes_supported[mode_num])
@@ -114,7 +114,7 @@ static umode_t blk_crypto_mode_is_visible(struct kobject *kobj,
114114
}
115115

116116
static ssize_t blk_crypto_mode_show(struct blk_crypto_profile *profile,
117-
struct blk_crypto_attr *attr, char *page)
117+
const struct blk_crypto_attr *attr, char *page)
118118
{
119119
int mode_num = attr - __blk_crypto_mode_attrs;
120120

@@ -123,8 +123,8 @@ static ssize_t blk_crypto_mode_show(struct blk_crypto_profile *profile,
123123

124124
static const struct attribute_group blk_crypto_modes_attr_group = {
125125
.name = "modes",
126-
.attrs = blk_crypto_mode_attrs,
127-
.is_visible = blk_crypto_mode_is_visible,
126+
.attrs_const = blk_crypto_mode_attrs,
127+
.is_visible_const = blk_crypto_mode_is_visible,
128128
};
129129

130130
static const struct attribute_group *blk_crypto_attr_groups[] = {
@@ -137,7 +137,7 @@ static ssize_t blk_crypto_attr_show(struct kobject *kobj,
137137
struct attribute *attr, char *page)
138138
{
139139
struct blk_crypto_profile *profile = kobj_to_crypto_profile(kobj);
140-
struct blk_crypto_attr *a = attr_to_crypto_attr(attr);
140+
const struct blk_crypto_attr *a = attr_to_crypto_attr(attr);
141141

142142
return a->show(profile, a, page);
143143
}

block/blk-ia-ranges.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,17 @@ struct blk_ia_range_sysfs_entry {
3030
ssize_t (*show)(struct blk_independent_access_range *iar, char *buf);
3131
};
3232

33-
static struct blk_ia_range_sysfs_entry blk_ia_range_sector_entry = {
33+
static const struct blk_ia_range_sysfs_entry blk_ia_range_sector_entry = {
3434
.attr = { .name = "sector", .mode = 0444 },
3535
.show = blk_ia_range_sector_show,
3636
};
3737

38-
static struct blk_ia_range_sysfs_entry blk_ia_range_nr_sectors_entry = {
38+
static const struct blk_ia_range_sysfs_entry blk_ia_range_nr_sectors_entry = {
3939
.attr = { .name = "nr_sectors", .mode = 0444 },
4040
.show = blk_ia_range_nr_sectors_show,
4141
};
4242

43-
static struct attribute *blk_ia_range_attrs[] = {
43+
static const struct attribute *const blk_ia_range_attrs[] = {
4444
&blk_ia_range_sector_entry.attr,
4545
&blk_ia_range_nr_sectors_entry.attr,
4646
NULL,

block/blk-mq-sysfs.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ static ssize_t blk_mq_hw_sysfs_show(struct kobject *kobj,
5353
struct request_queue *q;
5454
ssize_t res;
5555

56-
entry = container_of(attr, struct blk_mq_hw_ctx_sysfs_entry, attr);
56+
entry = container_of_const(attr, struct blk_mq_hw_ctx_sysfs_entry, attr);
5757
hctx = container_of(kobj, struct blk_mq_hw_ctx, kobj);
5858
q = hctx->queue;
5959

@@ -101,20 +101,20 @@ static ssize_t blk_mq_hw_sysfs_cpus_show(struct blk_mq_hw_ctx *hctx, char *page)
101101
return pos + ret;
102102
}
103103

104-
static struct blk_mq_hw_ctx_sysfs_entry blk_mq_hw_sysfs_nr_tags = {
104+
static const struct blk_mq_hw_ctx_sysfs_entry blk_mq_hw_sysfs_nr_tags = {
105105
.attr = {.name = "nr_tags", .mode = 0444 },
106106
.show = blk_mq_hw_sysfs_nr_tags_show,
107107
};
108-
static struct blk_mq_hw_ctx_sysfs_entry blk_mq_hw_sysfs_nr_reserved_tags = {
108+
static const struct blk_mq_hw_ctx_sysfs_entry blk_mq_hw_sysfs_nr_reserved_tags = {
109109
.attr = {.name = "nr_reserved_tags", .mode = 0444 },
110110
.show = blk_mq_hw_sysfs_nr_reserved_tags_show,
111111
};
112-
static struct blk_mq_hw_ctx_sysfs_entry blk_mq_hw_sysfs_cpus = {
112+
static const struct blk_mq_hw_ctx_sysfs_entry blk_mq_hw_sysfs_cpus = {
113113
.attr = {.name = "cpu_list", .mode = 0444 },
114114
.show = blk_mq_hw_sysfs_cpus_show,
115115
};
116116

117-
static struct attribute *default_hw_ctx_attrs[] = {
117+
static const struct attribute *const default_hw_ctx_attrs[] = {
118118
&blk_mq_hw_sysfs_nr_tags.attr,
119119
&blk_mq_hw_sysfs_nr_reserved_tags.attr,
120120
&blk_mq_hw_sysfs_cpus.attr,

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)