Skip to contentSkip to conversation

regulator: Constify read-only regmap_config struct

PATCH In review Javier Carrasco 2 participants 4 messages Jul 4, 2024

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

cover regulator: Constify read-only regmap_config struct

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

---
Javier Carrasco (2):
regulator: da9121: Constify struct regmap_config
regulator: max77857: Constify struct regmap_config

 drivers/regulator/da9121-regulator.c   | 6 +++---
 drivers/regulator/max77857-regulator.c | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

---
base-commit: 0b58e108042b0ed28a71cd7edf5175999955b233
change-id: 20240704-regulator-const-regmap-2701f2387dad

Best regards,

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

PATCH 1/2 regulator: da9121: Constify struct regmap_config

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

The pointer that references those structs has been converted to const accordingly.

---
 drivers/regulator/da9121-regulator.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/regulator/da9121-regulator.c +3 -3
index 3571b6242e3a..d97162f73793 100644
@@ -865,7 +865,7 @@ static const struct regmap_access_table da9121_volatile_table = {
 };
 
 /* DA9121 regmap config for 1 channel variants */
-static struct regmap_config da9121_1ch_regmap_config = {
+static const struct regmap_config da9121_1ch_regmap_config = {
 	.reg_bits = 8,
 	.val_bits = 8,
 	.max_register = DA9121_REG_OTP_CONFIG_ID,
@@ -876,7 +876,7 @@ static struct regmap_config da9121_1ch_regmap_config = {
 };
 
 /* DA9121 regmap config for 2 channel variants */
-static struct regmap_config da9121_2ch_regmap_config = {
+static const struct regmap_config da9121_2ch_regmap_config = {
 	.reg_bits = 8,
 	.val_bits = 8,
 	.max_register = DA9121_REG_OTP_CONFIG_ID,
@@ -993,7 +993,7 @@ static int da9121_check_device_type(struct i2c_client *i2c, struct da9121 *chip)
 static int da9121_assign_chip_model(struct i2c_client *i2c,
 			struct da9121 *chip)
 {
-	struct regmap_config *regmap;
+	const struct regmap_config *regmap;
 	int ret = 0;
 
 	chip->dev = &i2c->dev;
Signature · 1 line
2.40.1
#2 lore raw

PATCH 2/2 regulator: max77857: Constify struct regmap_config

In reply to Javier Carrasco

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

---
 drivers/regulator/max77857-regulator.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/regulator/max77857-regulator.c +1 -1
index 145ad0281857..bc28dc8503a8 100644
@@ -67,7 +67,7 @@ static bool max77857_volatile_reg(struct device *dev, unsigned int reg)
 	}
 }
 
-static struct regmap_config max77857_regmap_config = {
+static const struct regmap_config max77857_regmap_config = {
 	.reg_bits = 8,
 	.val_bits = 8,
 	.cache_type = REGCACHE_MAPLE,
Signature · 1 line
2.40.1
maintainer
#3 lore raw
In reply to Javier Carrasco
Quoted 5 lines · Javier Carrasco

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

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-next

Thanks!

[1/2] regulator: da9121: Constify struct regmap_config

      commit: 05db2e27b92302a43f996561dbb58ecabc3cc85d
[2/2] regulator: max77857: Constify struct regmap_config
      commit: 32d1171014a74c788218e0a8a5fd6fef65fb10ba

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark