All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] md: Constify attribute_group structs
@ 2021-05-29 10:30 Rikard Falkeborn
  2021-06-01  4:26 ` Song Liu
  0 siblings, 1 reply; 2+ messages in thread
From: Rikard Falkeborn @ 2021-05-29 10:30 UTC (permalink / raw)
  To: Song Liu; +Cc: linux-raid, linux-kernel, Rikard Falkeborn

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 <rikard.falkeborn@gmail.com>
---
 drivers/md/md-bitmap.c | 2 +-
 drivers/md/md.c        | 6 +++---
 drivers/md/md.h        | 4 ++--
 drivers/md/raid5.c     | 2 +-
 4 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
index ea3130e11680..e29c6298ef5c 100644
--- a/drivers/md/md-bitmap.c
+++ b/drivers/md/md-bitmap.c
@@ -2616,7 +2616,7 @@ static struct attribute *md_bitmap_attrs[] = {
 	&max_backlog_used.attr,
 	NULL
 };
-struct attribute_group md_bitmap_group = {
+const struct attribute_group md_bitmap_group = {
 	.name = "bitmap",
 	.attrs = md_bitmap_attrs,
 };
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 49f897fbb89b..0e40bb5618a1 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -824,7 +824,7 @@ static struct mddev *mddev_alloc(dev_t unit)
 	return ERR_PTR(error);
 }
 
-static struct attribute_group md_redundancy_group;
+static const struct attribute_group md_redundancy_group;
 
 void mddev_unlock(struct mddev *mddev)
 {
@@ -841,7 +841,7 @@ void mddev_unlock(struct mddev *mddev)
 		 * test it under the same mutex to ensure its correct value
 		 * is seen.
 		 */
-		struct attribute_group *to_remove = mddev->to_remove;
+		const struct attribute_group *to_remove = mddev->to_remove;
 		mddev->to_remove = NULL;
 		mddev->sysfs_active = 1;
 		mutex_unlock(&mddev->reconfig_mutex);
@@ -5538,7 +5538,7 @@ static struct attribute *md_redundancy_attrs[] = {
 	&md_degraded.attr,
 	NULL,
 };
-static struct attribute_group md_redundancy_group = {
+static const struct attribute_group md_redundancy_group = {
 	.name = NULL,
 	.attrs = md_redundancy_attrs,
 };
diff --git a/drivers/md/md.h b/drivers/md/md.h
index fb7eab58cfd5..31e743e2ecae 100644
--- a/drivers/md/md.h
+++ b/drivers/md/md.h
@@ -481,7 +481,7 @@ struct mddev {
 	atomic_t			max_corr_read_errors; /* max read retries */
 	struct list_head		all_mddevs;
 
-	struct attribute_group		*to_remove;
+	const struct attribute_group	*to_remove;
 
 	struct bio_set			bio_set;
 	struct bio_set			sync_set; /* for sync operations like
@@ -613,7 +613,7 @@ struct md_sysfs_entry {
 	ssize_t (*show)(struct mddev *, char *);
 	ssize_t (*store)(struct mddev *, const char *, size_t);
 };
-extern struct attribute_group md_bitmap_group;
+extern const struct attribute_group md_bitmap_group;
 
 static inline struct kernfs_node *sysfs_get_dirent_safe(struct kernfs_node *sd, char *name)
 {
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 841e1c1aa5e6..b0a3050aa0a4 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -6930,7 +6930,7 @@ static struct attribute *raid5_attrs[] =  {
 	&ppl_write_hint.attr,
 	NULL,
 };
-static struct attribute_group raid5_attrs_group = {
+static const struct attribute_group raid5_attrs_group = {
 	.name = NULL,
 	.attrs = raid5_attrs,
 };
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] md: Constify attribute_group structs
  2021-05-29 10:30 [PATCH] md: Constify attribute_group structs Rikard Falkeborn
@ 2021-06-01  4:26 ` Song Liu
  0 siblings, 0 replies; 2+ messages in thread
From: Song Liu @ 2021-06-01  4:26 UTC (permalink / raw)
  To: Rikard Falkeborn; +Cc: linux-raid, open list

On Sat, May 29, 2021 at 3:30 AM Rikard Falkeborn
<rikard.falkeborn@gmail.com> wrote:
>
> 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 <rikard.falkeborn@gmail.com>

Applied to md-next. Thanks!
Song

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-06-01  4:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-29 10:30 [PATCH] md: Constify attribute_group structs Rikard Falkeborn
2021-06-01  4:26 ` Song Liu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.