Skip to contentSkip to conversation

mfd: Constify struct regmap_config

PATCH Superseded Javier Carrasco 2 participants 10 messages Jul 3, 2024 – Jul 4, 2024

Subsystems (5)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover mfd: Constify struct regmap_config

This series adds the const modifier to the remaining regmap_config structs within mfd that are effectively used as const (i.e., only read after their declaration), but kept as writtable data.

---
Javier Carrasco (7):
mfd: da9062-core: Constify struct regmap_config
mfd: fsl-imx25-tsadc: Constify struct regmap_config
mfd: hi655x-pmic: Constify struct regmap_config
mfd: wcd934x: Constify struct regmap_config
mfd: tps6105x: Constify struct regmap_config
mfd: rohm-bd9576: Constify struct regmap_config
mfd: intel-m10-bmc: Constify struct regmap_config

 drivers/mfd/da9062-core.c        | 4 ++--
 drivers/mfd/fsl-imx25-tsadc.c    | 2 +-
 drivers/mfd/hi655x-pmic.c        | 2 +-
 drivers/mfd/intel-m10-bmc-pmci.c | 2 +-
 drivers/mfd/intel-m10-bmc-spi.c  | 2 +-
 drivers/mfd/rohm-bd9576.c        | 2 +-
 drivers/mfd/tps6105x.c           | 2 +-
 drivers/mfd/wcd934x.c            | 2 +-
 8 files changed, 9 insertions(+), 9 deletions(-)

---
base-commit: 0b58e108042b0ed28a71cd7edf5175999955b233
change-id: 20240703-mfd-const-regmap_config-96da5e18a85f

Best regards,

Signature · 1 line
Javier Carrasco <[email protected]>
#1 lore raw

PATCH 1/7 mfd: da9062-core: Constify struct regmap_config

da9061_regmap_config and da9062_regmap_config are not modified and can be declared as const to move their data to a read-only section.

---
 drivers/mfd/da9062-core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mfd/da9062-core.c +2 -2
index dbbc4779170a..5e55c6cbf5e0 100644
@@ -470,7 +470,7 @@ static const struct regmap_range_cfg da9061_range_cfg[] = {
 	}
 };
 
-static struct regmap_config da9061_regmap_config = {
+static const struct regmap_config da9061_regmap_config = {
 	.reg_bits = 8,
 	.val_bits = 8,
 	.ranges = da9061_range_cfg,
@@ -576,7 +576,7 @@ static const struct regmap_range_cfg da9062_range_cfg[] = {
 	}
 };
 
-static struct regmap_config da9062_regmap_config = {
+static const struct regmap_config da9062_regmap_config = {
 	.reg_bits = 8,
 	.val_bits = 8,
 	.ranges = da9062_range_cfg,
Signature · 1 line
2.40.1
#2 lore raw

PATCH 2/7 mfd: fsl-imx25-tsadc: Constify struct regmap_config

In reply to Javier Carrasco

mx25_tsadc_regmap_config is not modified and can be declared as const to move its data to a read-only section.

---
 drivers/mfd/fsl-imx25-tsadc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mfd/fsl-imx25-tsadc.c +1 -1
index 74f38bf3778f..2e4ab2404154 100644
@@ -16,7 +16,7 @@
 #include <linux/platform_device.h>
 #include <linux/regmap.h>
 
-static struct regmap_config mx25_tsadc_regmap_config = {
+static const struct regmap_config mx25_tsadc_regmap_config = {
 	.fast_io = true,
 	.max_register = 8,
 	.reg_bits = 32,
Signature · 1 line
2.40.1
#3 lore raw

PATCH 3/7 mfd: hi655x-pmic: Constify struct regmap_config

In reply to Javier Carrasco

hi655x_regmap_config is not modified and can be declared as const to move its data to a read-only section.

---
 drivers/mfd/hi655x-pmic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mfd/hi655x-pmic.c +1 -1
index 042109304db4..5f61909c85e9 100644
@@ -41,7 +41,7 @@ static const struct regmap_irq_chip hi655x_irq_chip = {
 	.mask_base = HI655X_IRQ_MASK_BASE,
 };
 
-static struct regmap_config hi655x_regmap_config = {
+static const struct regmap_config hi655x_regmap_config = {
 	.reg_bits = 32,
 	.reg_stride = HI655X_STRIDE,
 	.val_bits = 8,
Signature · 1 line
2.40.1
#4 lore raw

PATCH 4/7 mfd: wcd934x: Constify struct regmap_config

In reply to Javier Carrasco

wcd934x_regmap_config is not modified and can be declared as const to move its data to a read-only section.

---
 drivers/mfd/wcd934x.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mfd/wcd934x.c +1 -1
index 7b9873b72c37..fcd182d51981 100644
@@ -109,7 +109,7 @@ static const struct regmap_range_cfg wcd934x_ranges[] = {
 	},
 };
 
-static struct regmap_config wcd934x_regmap_config = {
+static const struct regmap_config wcd934x_regmap_config = {
 	.reg_bits = 16,
 	.val_bits = 8,
 	.cache_type = REGCACHE_MAPLE,
Signature · 1 line
2.40.1
#5 lore raw

PATCH 5/7 mfd: tps6105x: Constify struct regmap_config

In reply to Javier Carrasco

tps6105x_regmap_config is not modified and can be declared as const to move its data to a read-only section.

---
 drivers/mfd/tps6105x.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mfd/tps6105x.c +1 -1
index 0da1cecb5af6..e2f6858d101e 100644
@@ -23,7 +23,7 @@
 #include <linux/mfd/core.h>
 #include <linux/mfd/tps6105x.h>
 
-static struct regmap_config tps6105x_regmap_config = {
+static const struct regmap_config tps6105x_regmap_config = {
 	.reg_bits = 8,
 	.val_bits = 8,
 	.max_register = TPS6105X_REG_3,
Signature · 1 line
2.40.1
#6 lore raw

PATCH 6/7 mfd: rohm-bd9576: Constify struct regmap_config

In reply to Javier Carrasco

bd957x_regmap is not modified and can be declared as const to move its data to a read-only section.

---
 drivers/mfd/rohm-bd9576.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mfd/rohm-bd9576.c +1 -1
index 3a9f61961721..634c65c7d108 100644
@@ -57,7 +57,7 @@ static const struct regmap_access_table volatile_regs = {
 	.n_yes_ranges = ARRAY_SIZE(volatile_ranges),
 };
 
-static struct regmap_config bd957x_regmap = {
+static const struct regmap_config bd957x_regmap = {
 	.reg_bits = 8,
 	.val_bits = 8,
 	.volatile_table = &volatile_regs,
Signature · 1 line
2.40.1
maintainer
#7 lore raw

Re: [PATCH 6/7] mfd: rohm-bd9576: Constify struct regmap_config

Quoted 14 lines · Javier Carrasco

bd957x_regmap is not modified and can be declared as const to move its data to a read-only section.

---
  drivers/mfd/rohm-bd9576.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mfd/rohm-bd9576.c +0 -0
index 3a9f61961721..634c65c7d108 100644

drivers/mfd/rohm-bd9576.c static const struct regmap_access_table volatile_regs = { · line 63

Quoted 8 lines
drivers/mfd/rohm-bd9576.c +1 -1
@@ -57,7 +57,7 @@ static const struct regmap_access_table volatile_regs = {
  	.n_yes_ranges = ARRAY_SIZE(volatile_ranges),
  };
 
-static struct regmap_config bd957x_regmap = {
+static const struct regmap_config bd957x_regmap = {
  	.reg_bits = 8,
  	.val_bits = 8,
  	.volatile_table = &volatile_regs,

Thanks a ton Javier. This looks good to me but if you feel like going an extra mile while you are at it... Do you think this could be extended to:

drivers/mfd/rohm-bd9576.c +3 -3
index 3a9f61961721..17323ae39803 100644
@@ -57,7 +57,7 @@ static const struct regmap_access_table volatile_regs = {
        .n_yes_ranges = ARRAY_SIZE(volatile_ranges),
 };
 
-static struct regmap_config bd957x_regmap = {
+static const struct regmap_config bd957x_regmap = {
        .reg_bits = 8,
        .val_bits = 8,
        .volatile_table = &volatile_regs,
@@ -65,7 +65,7 @@ static struct regmap_config bd957x_regmap = {
        .cache_type = REGCACHE_MAPLE,
 };
 
-static struct regmap_irq bd9576_irqs[] = {
+static const struct regmap_irq bd9576_irqs[] = {
        REGMAP_IRQ_REG(BD9576_INT_THERM, 0, BD957X_MASK_INT_MAIN_THERM),
        REGMAP_IRQ_REG(BD9576_INT_OVP, 0, BD957X_MASK_INT_MAIN_OVP),
        REGMAP_IRQ_REG(BD9576_INT_SCP, 0, BD957X_MASK_INT_MAIN_SCP),
@@ -76,7 +76,7 @@ static struct regmap_irq bd9576_irqs[] = {
        REGMAP_IRQ_REG(BD9576_INT_SYS, 0, BD957X_MASK_INT_MAIN_SYS),
 };
 
-static struct regmap_irq_chip bd9576_irq_chip = {
+static const struct regmap_irq_chip bd9576_irq_chip = {
        .name = "bd9576_irq",
        .irqs = &bd9576_irqs[0],
        .num_irqs = ARRAY_SIZE(bd9576_irqs),

Yours,
-- Matti

Signature · 5 lines
Matti Vaittinen
Linux kernel developer at ROHM Semiconductors
Oulu Finland

~~ When things go utterly wrong vim users can always type :help! ~~
#8 lore raw

Re: [PATCH 6/7] mfd: rohm-bd9576: Constify struct regmap_config

Quoted 61 lines · Matti Vaittinen
Quoted 20 lines · Javier Carrasco

bd957x_regmap is not modified and can be declared as const to move its data to a read-only section.

---
  drivers/mfd/rohm-bd9576.c | 2 +-

  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mfd/rohm-bd9576.c +1 -0
index 3a9f61961721..634c65c7d108 100644
@@ -57,7 +57,7 @@ static const struct regmap_access_table
 volatile_regs = {
       .n_yes_ranges = ARRAY_SIZE(volatile_ranges),
   };
   -static struct regmap_config bd957x_regmap = {
+static const struct regmap_config bd957x_regmap = {
       .reg_bits = 8,
       .val_bits = 8,
Quoted 2 lines

      .volatile_table = &volatile_regs,

Thanks a ton Javier. This looks good to me but if you feel like going an extra mile while you are at it... Do you think this could be extended to:

drivers/mfd/rohm-bd9576.c +3 -3
index 3a9f61961721..17323ae39803 100644
@@ -57,7 +57,7 @@ static const struct regmap_access_table volatile_regs = {
         .n_yes_ranges = ARRAY_SIZE(volatile_ranges),
  };
 
-static struct regmap_config bd957x_regmap = {
+static const struct regmap_config bd957x_regmap = {
         .reg_bits = 8,
         .val_bits = 8,
         .volatile_table = &volatile_regs,
@@ -65,7 +65,7 @@ static struct regmap_config bd957x_regmap = {
         .cache_type = REGCACHE_MAPLE,
  };
 
-static struct regmap_irq bd9576_irqs[] = {
+static const struct regmap_irq bd9576_irqs[] = {
         REGMAP_IRQ_REG(BD9576_INT_THERM, 0, BD957X_MASK_INT_MAIN_THERM),
         REGMAP_IRQ_REG(BD9576_INT_OVP, 0, BD957X_MASK_INT_MAIN_OVP),
         REGMAP_IRQ_REG(BD9576_INT_SCP, 0, BD957X_MASK_INT_MAIN_SCP),
@@ -76,7 +76,7 @@ static struct regmap_irq bd9576_irqs[] = {
         REGMAP_IRQ_REG(BD9576_INT_SYS, 0, BD957X_MASK_INT_MAIN_SYS),
  };
 
-static struct regmap_irq_chip bd9576_irq_chip = {
+static const struct regmap_irq_chip bd9576_irq_chip = {
         .name = "bd9576_irq",
         .irqs = &bd9576_irqs[0],
         .num_irqs = ARRAY_SIZE(bd9576_irqs),
Quoted 3 lines

Yours,
    -- Matti

Sure, I will generalize it and update the series to cover regmap_irq and regmap_irq_chip as well, of course including these two cases too.

Best regards,
Javier Carrasco

#9 lore raw

PATCH 7/7 mfd: intel-m10-bmc: Constify struct regmap_config

In reply to Javier Carrasco

m10bmc_pmci_regmap_config and intel_m10bmc_regmap_config are not modified and can be declared as const to move their data to a read-only section.

---
 drivers/mfd/intel-m10-bmc-pmci.c | 2 +-
 drivers/mfd/intel-m10-bmc-spi.c  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/mfd/intel-m10-bmc-pmci.c +1 -1
index 698c5933938b..4fa9d380c62b 100644
@@ -336,7 +336,7 @@ static const struct regmap_access_table m10bmc_pmci_access_table = {
 	.n_yes_ranges	= ARRAY_SIZE(m10bmc_pmci_regmap_range),
 };
 
-static struct regmap_config m10bmc_pmci_regmap_config = {
+static const struct regmap_config m10bmc_pmci_regmap_config = {
 	.reg_bits = 32,
 	.reg_stride = 4,
 	.val_bits = 32,
drivers/mfd/intel-m10-bmc-spi.c +1 -1
index d64d28199df6..36f631ef7a67 100644
@@ -24,7 +24,7 @@ static const struct regmap_access_table m10bmc_access_table = {
 	.n_yes_ranges	= ARRAY_SIZE(m10bmc_regmap_range),
 };
 
-static struct regmap_config intel_m10bmc_regmap_config = {
+static const struct regmap_config intel_m10bmc_regmap_config = {
 	.reg_bits = 32,
 	.val_bits = 32,
 	.reg_stride = 4,
Signature · 1 line
2.40.1