driverdev-devel.linuxdriverproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] staging: fieldbus: arcx-anybus: constify static structs
@ 2021-02-07 20:25 Rikard Falkeborn
  2021-02-08 13:21 ` Sven Van Asbroeck
  0 siblings, 1 reply; 2+ messages in thread
From: Rikard Falkeborn @ 2021-02-07 20:25 UTC (permalink / raw)
  To: Sven Van Asbroeck, Greg Kroah-Hartman
  Cc: devel, linux-kernel, Rikard Falkeborn

Constify two static structs which are never modified, to allow the
compiler to put them in read-only memory.

The only usage of controller_attribute_group is to put its address in an
array of pointers to const struct attribute_group, and the only usage of
can_power_ops is to assign its address to the 'ops' field in the
regulator_desc struct, which is a pointer to const struct regulator_ops.

Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
---
 drivers/staging/fieldbus/anybuss/arcx-anybus.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/fieldbus/anybuss/arcx-anybus.c b/drivers/staging/fieldbus/anybuss/arcx-anybus.c
index b5fded15e8a6..9af2e63050d1 100644
--- a/drivers/staging/fieldbus/anybuss/arcx-anybus.c
+++ b/drivers/staging/fieldbus/anybuss/arcx-anybus.c
@@ -185,7 +185,7 @@ static struct attribute *controller_attributes[] = {
 	NULL,
 };
 
-static struct attribute_group controller_attribute_group = {
+static const struct attribute_group controller_attribute_group = {
 	.attrs = controller_attributes,
 };
 
@@ -206,7 +206,7 @@ static int can_power_is_enabled(struct regulator_dev *rdev)
 	return !(readb(cd->cpld_base + CPLD_STATUS1) & CPLD_STATUS1_CAN_POWER);
 }
 
-static struct regulator_ops can_power_ops = {
+static const struct regulator_ops can_power_ops = {
 	.is_enabled = can_power_is_enabled,
 };
 
-- 
2.30.0

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

* Re: [PATCH] staging: fieldbus: arcx-anybus: constify static structs
  2021-02-07 20:25 [PATCH] staging: fieldbus: arcx-anybus: constify static structs Rikard Falkeborn
@ 2021-02-08 13:21 ` Sven Van Asbroeck
  0 siblings, 0 replies; 2+ messages in thread
From: Sven Van Asbroeck @ 2021-02-08 13:21 UTC (permalink / raw)
  To: Rikard Falkeborn; +Cc: devel, Greg Kroah-Hartman, Linux Kernel Mailing List

Hi Rikard, thank you for the contribution.

On Sun, Feb 7, 2021 at 3:25 PM Rikard Falkeborn
<rikard.falkeborn@gmail.com> wrote:
>
> Constify two static structs which are never modified, to allow the
> compiler to put them in read-only memory.
>
> The only usage of controller_attribute_group is to put its address in an
> array of pointers to const struct attribute_group, and the only usage of
> can_power_ops is to assign its address to the 'ops' field in the
> regulator_desc struct, which is a pointer to const struct regulator_ops.
>
> Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>

Reviewed-by: Sven Van Asbroeck <TheSven73@gmail.com>
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

end of thread, other threads:[~2021-02-08 13:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-07 20:25 [PATCH] staging: fieldbus: arcx-anybus: constify static structs Rikard Falkeborn
2021-02-08 13:21 ` Sven Van Asbroeck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).