staging: fieldbus: arcx-anybus: constify static structs
authorRikard Falkeborn <rikard.falkeborn@gmail.com>
Sun, 7 Feb 2021 20:25:01 +0000 (21:25 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 8 Feb 2021 14:22:34 +0000 (15:22 +0100)
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.

Reviewed-by: Sven Van Asbroeck <TheSven73@gmail.com>
Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
Link: https://lore.kernel.org/r/20210207202501.9494-1-rikard.falkeborn@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/fieldbus/anybuss/arcx-anybus.c

index b5fded1..9af2e63 100644 (file)
@@ -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,
 };