Skip to contentSkip to conversation

thunderbolt: Constify static attribute_group structs

PATCH Applied Rikard Falkeborn 2 participants 2 messages Jan 8, 2021 – Jan 11, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 thunderbolt: Constify static attribute_group structs

The only usage of these is to put their addresses in arrays of pointers to const attribute_groups. Make them const to allow the compiler to put them in read-only memory.

---
 drivers/thunderbolt/domain.c  | 2 +-
 drivers/thunderbolt/switch.c  | 2 +-
 drivers/thunderbolt/xdomain.c | 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)
drivers/thunderbolt/domain.c +1 -1
index f0de94f7acbf..d2b92a8be577 100644
@@ -289,7 +289,7 @@ static umode_t domain_attr_is_visible(struct kobject *kobj,
 	return attr->mode;
 }
 
-static struct attribute_group domain_attr_group = {
+static const struct attribute_group domain_attr_group = {
 	.is_visible = domain_attr_is_visible,
 	.attrs = domain_attrs,
 };
drivers/thunderbolt/switch.c +1 -1
index a8572f49d3ad..602e1835bf61 100644
@@ -1771,7 +1771,7 @@ static umode_t switch_attr_is_visible(struct kobject *kobj,
 	return sw->safe_mode ? 0 : attr->mode;
 }
 
-static struct attribute_group switch_group = {
+static const struct attribute_group switch_group = {
 	.is_visible = switch_attr_is_visible,
 	.attrs = switch_attrs,
 };
drivers/thunderbolt/xdomain.c +2 -2
index 9b3a299a1202..f2d4db1cd84d 100644
@@ -756,7 +756,7 @@ static struct attribute *tb_service_attrs[] = {
 	NULL,
 };
 
-static struct attribute_group tb_service_attr_group = {
+static const struct attribute_group tb_service_attr_group = {
 	.attrs = tb_service_attrs,
 };
 
@@ -1239,7 +1239,7 @@ static struct attribute *xdomain_attrs[] = {
 	NULL,
 };
 
-static struct attribute_group xdomain_attr_group = {
+static const struct attribute_group xdomain_attr_group = {
 	.attrs = xdomain_attrs,
 };
 
Signature · 1 line
2.30.0
#1 lore raw
Quoted 5 lines · Rikard Falkeborn

The only usage of these is to put their addresses in arrays of pointers to const attribute_groups. Make them const to allow the compiler to put them in read-only memory.

Applied to thunderbolt.git/next, thanks!