power: supply: Constify static struct attribute_group
cover power: supply: Constify static struct attribute_group
Constify two static struct attribute_group. The only place they are used is to put their address in an array of pointers to const struct attribute_group. With these patches applied, all static attribute_group structs in drivers/power are const.
Rikard Falkeborn (2):
power: supply: ltc4162-l: Constify static struct attribute_group
power: supply: core: Constify static struct attribute_group
drivers/power/supply/ltc4162-l-charger.c | 2 +- drivers/power/supply/power_supply_sysfs.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
Signature · 1 line
2.30.0
PATCH 1/2 power: supply: ltc4162-l: Constify static struct attribute_group
The only usage of it is to put its address in an array of pointers to const static structs. Make it const to allow the compiler to put it in read-only memory.
--- drivers/power/supply/ltc4162-l-charger.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/power/supply/ltc4162-l-charger.c +1 -1
@@ -666,7 +666,7 @@ static struct attribute *ltc4162l_sysfs_entries[] = { NULL, }; -static struct attribute_group ltc4162l_attr_group = { +static const struct attribute_group ltc4162l_attr_group = { .name =NULL ,/* put in device directory */ .attrs = ltc4162l_sysfs_entries, };
Signature · 1 line
2.30.0
PATCH 2/2 power: supply: core: Constify static struct attribute_group
In reply to Rikard FalkebornThe only usage of it is to put its address in an array of pointers to const static structs. Make it const to allow the compiler to put it in read-only memory.
--- drivers/power/supply/power_supply_sysfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/power/supply/power_supply_sysfs.c +1 -1
@@ -374,7 +374,7 @@ static umode_t power_supply_attr_is_visible(struct kobject *kobj,return 0 ; } -static struct attribute_group power_supply_attr_group = { +static const struct attribute_group power_supply_attr_group = { .attrs = __power_supply_attrs, .is_visible = power_supply_attr_is_visible, };
Signature · 1 line
2.30.0
Hi,
Quoted 4 lines · Rikard Falkeborn
Constify two static struct
attribute_group. The only place they are used is to put their address in an array of pointers to const structattribute_group. With these patches applied, all staticattribute_groupstructs indrivers/powerare const.
Thanks, I queued both to power-supply's for-next branch.
-- Sebastian