Skip to contentSkip to conversation

cxl/core: Constify static attribute_group structs

PATCH New Rikard Falkeborn 1 participant 1 message Feb 10, 2022 CXL

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cxl/core: Constify static attribute_group structs

The only usage of these is to put their address in arrays of pointers to const struct attribute_group, so make them const to allow the compiler to put them in read-only memory.

---
 drivers/cxl/core/bus.c    | 8 ++++----
 drivers/cxl/core/core.h   | 2 +-
 drivers/cxl/core/memdev.c | 6 +++---
 3 files changed, 8 insertions(+), 8 deletions(-)
drivers/cxl/core/bus.c +4 -4
index 3f9b98ecd18b..4532ef8b806f 100644
@@ -38,7 +38,7 @@ static struct attribute *cxl_base_attributes[] = {
 	NULL,
 };
 
-struct attribute_group cxl_base_attribute_group = {
+const struct attribute_group cxl_base_attribute_group = {
 	.attrs = cxl_base_attributes,
 };
 
@@ -136,7 +136,7 @@ static struct attribute *cxl_decoder_base_attrs[] = {
 	NULL,
 };
 
-static struct attribute_group cxl_decoder_base_attribute_group = {
+static const struct attribute_group cxl_decoder_base_attribute_group = {
 	.attrs = cxl_decoder_base_attrs,
 };
 
@@ -148,7 +148,7 @@ static struct attribute *cxl_decoder_root_attrs[] = {
 	NULL,
 };
 
-static struct attribute_group cxl_decoder_root_attribute_group = {
+static const struct attribute_group cxl_decoder_root_attribute_group = {
 	.attrs = cxl_decoder_root_attrs,
 };
 
@@ -164,7 +164,7 @@ static struct attribute *cxl_decoder_switch_attrs[] = {
 	NULL,
 };
 
-static struct attribute_group cxl_decoder_switch_attribute_group = {
+static const struct attribute_group cxl_decoder_switch_attribute_group = {
 	.attrs = cxl_decoder_switch_attrs,
 };
 
drivers/cxl/core/core.h +1 -1
index e0c9aacc4e9c..1c0562cc9297 100644
@@ -7,7 +7,7 @@
 extern const struct device_type cxl_nvdimm_bridge_type;
 extern const struct device_type cxl_nvdimm_type;
 
-extern struct attribute_group cxl_base_attribute_group;
+extern const struct attribute_group cxl_base_attribute_group;
 
 struct cxl_send_command;
 struct cxl_mem_query_commands;
drivers/cxl/core/memdev.c +3 -3
index 61029cb7ac62..ac2d40741686 100644
@@ -106,16 +106,16 @@ static struct attribute *cxl_memdev_ram_attributes[] = {
 	NULL,
 };
 
-static struct attribute_group cxl_memdev_attribute_group = {
+static const struct attribute_group cxl_memdev_attribute_group = {
 	.attrs = cxl_memdev_attributes,
 };
 
-static struct attribute_group cxl_memdev_ram_attribute_group = {
+static const struct attribute_group cxl_memdev_ram_attribute_group = {
 	.name = "ram",
 	.attrs = cxl_memdev_ram_attributes,
 };
 
-static struct attribute_group cxl_memdev_pmem_attribute_group = {
+static const struct attribute_group cxl_memdev_pmem_attribute_group = {
 	.name = "pmem",
 	.attrs = cxl_memdev_pmem_attributes,
 };
Signature · 1 line
2.35.1