Skip to contentSkip to conversation

platform/chrome: Constify static attribute_group structs

PATCH Applied Rikard Falkeborn 2 participants 2 messages Jan 9, 2021 – Jan 20, 2021

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

PATCH 1/1 platform/chrome: Constify static attribute_group structs

The only usage of these is to print their name in a dev_err-message, and to pass their address to sysfs_create_group() and sysfs_remove_group(), both which takes pointers to const. Make them const to allow the compiler to put them in read-only memory.

---
 drivers/platform/chrome/cros_ec_lightbar.c | 2 +-
 drivers/platform/chrome/cros_ec_sysfs.c    | 2 +-
 drivers/platform/chrome/cros_ec_vbc.c      | 2 +-
 drivers/platform/chrome/wilco_ec/sysfs.c   | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)
drivers/platform/chrome/cros_ec_lightbar.c +1 -1
index de8dfb12e486..469dfc7a4a03 100644
@@ -523,7 +523,7 @@ static struct attribute *__lb_cmds_attrs[] = {
 	NULL,
 };
 
-static struct attribute_group cros_ec_lightbar_attr_group = {
+static const struct attribute_group cros_ec_lightbar_attr_group = {
 	.name = "lightbar",
 	.attrs = __lb_cmds_attrs,
 };
drivers/platform/chrome/cros_ec_sysfs.c +1 -1
index f521a5c65091..fc8681f80aba 100644
@@ -329,7 +329,7 @@ static umode_t cros_ec_ctrl_visible(struct kobject *kobj,
 	return a->mode;
 }
 
-static struct attribute_group cros_ec_attr_group = {
+static const struct attribute_group cros_ec_attr_group = {
 	.attrs = __ec_attrs,
 	.is_visible = cros_ec_ctrl_visible,
 };
drivers/platform/chrome/cros_ec_vbc.c +1 -1
index f3a70a312b43..c859c862d7ac 100644
@@ -101,7 +101,7 @@ static struct bin_attribute *cros_ec_vbc_bin_attrs[] = {
 	NULL
 };
 
-static struct attribute_group cros_ec_vbc_attr_group = {
+static const struct attribute_group cros_ec_vbc_attr_group = {
 	.name = "vbc",
 	.bin_attrs = cros_ec_vbc_bin_attrs,
 };
drivers/platform/chrome/wilco_ec/sysfs.c +1 -1
index 3c587b4054a5..79a5e8fa680f 100644
@@ -236,7 +236,7 @@ static struct attribute *wilco_dev_attrs[] = {
 	NULL,
 };
 
-static struct attribute_group wilco_dev_attr_group = {
+static const struct attribute_group wilco_dev_attr_group = {
 	.attrs = wilco_dev_attrs,
 };
 
Signature · 1 line
2.30.0
#1 lore raw
Quoted 4 lines · Rikard Falkeborn

The only usage of these is to print their name in a dev_err-message, and to pass their address to sysfs_create_group() and sysfs_remove_group(), both which takes pointers to const. Make them const to allow the compiler to put them in read-only memory.

Applied, thanks!

[1/1] platform/chrome: Constify static attribute_group structs

      commit: ed07d774c4b2793be4d2bfc62cf69c3e55667f5a

Best regards,

Signature · 1 line
Enric Balletbo i Serra <[email protected]>