@@ -18,58 +18,58 @@ struct blk_crypto_kobj {
1818struct 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
2424static 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
3434static 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
4141static 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
4747static 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
5353static 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
6363BLK_CRYPTO_RO_ATTR (hw_wrapped_keys );
6464BLK_CRYPTO_RO_ATTR (max_dun_bits );
6565BLK_CRYPTO_RO_ATTR (num_keyslots );
6666BLK_CRYPTO_RO_ATTR (raw_keys );
6767
6868static 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
9292static 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 */
101101static 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
104104static 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
116116static 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
124124static 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
130130static 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}
0 commit comments