Skip to content

Commit c32dc04

Browse files
rikardfalkebornliu-song-6
authored andcommitted
md: Constify attribute_group structs
The attribute_group structs are never modified, they're only passed to sysfs_create_group() and sysfs_remove_group(). Make them const to allow the compiler to put them in read-only memory. Signed-off-by: Rikard Falkeborn <[email protected]> Signed-off-by: Song Liu <[email protected]>
1 parent 608f52e commit c32dc04

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

drivers/md/md-bitmap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2616,7 +2616,7 @@ static struct attribute *md_bitmap_attrs[] = {
26162616
&max_backlog_used.attr,
26172617
NULL
26182618
};
2619-
struct attribute_group md_bitmap_group = {
2619+
const struct attribute_group md_bitmap_group = {
26202620
.name = "bitmap",
26212621
.attrs = md_bitmap_attrs,
26222622
};

drivers/md/md.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,7 @@ static struct mddev *mddev_alloc(dev_t unit)
785785
return ERR_PTR(error);
786786
}
787787

788-
static struct attribute_group md_redundancy_group;
788+
static const struct attribute_group md_redundancy_group;
789789

790790
void mddev_unlock(struct mddev *mddev)
791791
{
@@ -802,7 +802,7 @@ void mddev_unlock(struct mddev *mddev)
802802
* test it under the same mutex to ensure its correct value
803803
* is seen.
804804
*/
805-
struct attribute_group *to_remove = mddev->to_remove;
805+
const struct attribute_group *to_remove = mddev->to_remove;
806806
mddev->to_remove = NULL;
807807
mddev->sysfs_active = 1;
808808
mutex_unlock(&mddev->reconfig_mutex);
@@ -5500,7 +5500,7 @@ static struct attribute *md_redundancy_attrs[] = {
55005500
&md_degraded.attr,
55015501
NULL,
55025502
};
5503-
static struct attribute_group md_redundancy_group = {
5503+
static const struct attribute_group md_redundancy_group = {
55045504
.name = NULL,
55055505
.attrs = md_redundancy_attrs,
55065506
};

drivers/md/md.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ struct mddev {
481481
atomic_t max_corr_read_errors; /* max read retries */
482482
struct list_head all_mddevs;
483483

484-
struct attribute_group *to_remove;
484+
const struct attribute_group *to_remove;
485485

486486
struct bio_set bio_set;
487487
struct bio_set sync_set; /* for sync operations like
@@ -613,7 +613,7 @@ struct md_sysfs_entry {
613613
ssize_t (*show)(struct mddev *, char *);
614614
ssize_t (*store)(struct mddev *, const char *, size_t);
615615
};
616-
extern struct attribute_group md_bitmap_group;
616+
extern const struct attribute_group md_bitmap_group;
617617

618618
static inline struct kernfs_node *sysfs_get_dirent_safe(struct kernfs_node *sd, char *name)
619619
{

drivers/md/raid5.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6940,7 +6940,7 @@ static struct attribute *raid5_attrs[] = {
69406940
&ppl_write_hint.attr,
69416941
NULL,
69426942
};
6943-
static struct attribute_group raid5_attrs_group = {
6943+
static const struct attribute_group raid5_attrs_group = {
69446944
.name = NULL,
69456945
.attrs = raid5_attrs,
69466946
};

0 commit comments

Comments
 (0)