Skip to contentSkip to conversation

regulator/tps*: Constify static regulator ops

PATCH In review Rikard Falkeborn 2 participants 10 messages Aug 29, 2020 – Sep 1, 2020

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

cover regulator/tps*: Constify static regulator ops

Constify static instances of struct regulator_ops to allow the compiler to put them in read-only memory. Patches are independent. Compile-tested only.

Rikard Falkeborn (8):
regulator: tps51632: Constify tps51632_dcdc_ops
regulator: tps6105x: Constify tps6105x_regulator_ops
regulator: tps62360: Constify tps62360_dcdc_ops
regulator: tps65086: Constify static regulator_ops
regulator: tps65090: constify static regulator_ops
regulator: tps6586x: Constify static regulator_ops
regulator: tps65912: Constify static regulator_ops
regulator: tps65910: Constify static regulator_ops

 drivers/regulator/tps51632-regulator.c |  2 +-
 drivers/regulator/tps6105x-regulator.c |  2 +-
 drivers/regulator/tps62360-regulator.c |  2 +-
 drivers/regulator/tps65086-regulator.c |  4 ++--
 drivers/regulator/tps65090-regulator.c |  8 ++++----
 drivers/regulator/tps6586x-regulator.c |  8 ++++----
 drivers/regulator/tps65910-regulator.c | 10 +++++-----
 drivers/regulator/tps65912-regulator.c |  4 ++--
 8 files changed, 20 insertions(+), 20 deletions(-)
Signature · 1 line
2.28.0
#1 lore raw

PATCH 1/8 regulator: tps51632: Constify tps51632_dcdc_ops

The only usage of tps51632_dcdc_ops is to assign its address to the ops field in the regulator_desc struct, which is a const pointer. Make it const to allow the compiler to put it in read-only memory.

---
 drivers/regulator/tps51632-regulator.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/regulator/tps51632-regulator.c +1 -1
index c139890c1514..a15e415e61d5 100644
@@ -108,7 +108,7 @@ static int tps51632_dcdc_set_ramp_delay(struct regulator_dev *rdev,
 	return ret;
 }
 
-static struct regulator_ops tps51632_dcdc_ops = {
+static const struct regulator_ops tps51632_dcdc_ops = {
 	.get_voltage_sel	= regulator_get_voltage_sel_regmap,
 	.set_voltage_sel	= regulator_set_voltage_sel_regmap,
 	.list_voltage		= regulator_list_voltage_linear,
Signature · 1 line
2.28.0
#2 lore raw

PATCH 2/8 regulator: tps6105x: Constify tps6105x_regulator_ops

In reply to Rikard Falkeborn

The only usage of tps6105x_regulator_ops is to assign its address to the ops field in the regulator_desc struct, which is a const pointer. Make it const to allow the compiler to put it in read-only memory.

---
 drivers/regulator/tps6105x-regulator.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/regulator/tps6105x-regulator.c +1 -1
index f8939af0bd2c..a6469fe05635 100644
@@ -26,7 +26,7 @@ static const unsigned int tps6105x_voltages[] = {
 	5000000, /* There is an additional 5V */
 };
 
-static struct regulator_ops tps6105x_regulator_ops = {
+static const struct regulator_ops tps6105x_regulator_ops = {
 	.enable		= regulator_enable_regmap,
 	.disable	= regulator_disable_regmap,
 	.is_enabled	= regulator_is_enabled_regmap,
Signature · 1 line
2.28.0
#3 lore raw

PATCH 3/8 regulator: tps62360: Constify tps62360_dcdc_ops

In reply to Rikard Falkeborn

The only usage of tps62360_dcdc_ops is to assign its address to the ops field in the regulator_desc struct, which is a const pointer. Make it const to allow the compiler to put it in read-only memory.

---
 drivers/regulator/tps62360-regulator.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/regulator/tps62360-regulator.c +1 -1
index f6a6d36a6533..315cd5daf480 100644
@@ -233,7 +233,7 @@ static unsigned int tps62360_get_mode(struct regulator_dev *rdev)
 				REGULATOR_MODE_FAST : REGULATOR_MODE_NORMAL;
 }
 
-static struct regulator_ops tps62360_dcdc_ops = {
+static const struct regulator_ops tps62360_dcdc_ops = {
 	.get_voltage_sel	= tps62360_dcdc_get_voltage_sel,
 	.set_voltage_sel	= tps62360_dcdc_set_voltage_sel,
 	.list_voltage		= regulator_list_voltage_linear,
Signature · 1 line
2.28.0
#4 lore raw

PATCH 4/8 regulator: tps65086: Constify static regulator_ops

In reply to Rikard Falkeborn

The only usage of reg_ops and switch_ops is to assign their addresses to the ops field in the regulator_desc struct, which is a const pointer. Make them const to allow the compiler to put them in read-only memory.

---
 drivers/regulator/tps65086-regulator.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/regulator/tps65086-regulator.c +2 -2
index 23528475a962..070c956216b0 100644
@@ -101,7 +101,7 @@ static const struct linear_range tps65086_ldoa23_ranges[] = {
 };
 
 /* Operations permitted on regulators */
-static struct regulator_ops reg_ops = {
+static const struct regulator_ops reg_ops = {
 	.enable			= regulator_enable_regmap,
 	.disable		= regulator_disable_regmap,
 	.is_enabled		= regulator_is_enabled_regmap,
@@ -112,7 +112,7 @@ static struct regulator_ops reg_ops = {
 };
 
 /* Operations permitted on load switches */
-static struct regulator_ops switch_ops = {
+static const struct regulator_ops switch_ops = {
 	.enable			= regulator_enable_regmap,
 	.disable		= regulator_disable_regmap,
 	.is_enabled		= regulator_is_enabled_regmap,
Signature · 1 line
2.28.0
#5 lore raw

PATCH 5/8 regulator: tps65090: constify static regulator_ops

In reply to Rikard Falkeborn

The only usages of these are to assign their address to the ops field in the regulator_desc struct, which is a const pointer. Make them const to allow the compiler to put them in read-only memory.

---
 drivers/regulator/tps65090-regulator.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/regulator/tps65090-regulator.c +4 -4
index f0b660e9f15f..1d2e04f452d4 100644
@@ -47,7 +47,7 @@ struct tps65090_regulator {
 	int			overcurrent_wait;
 };
 
-static struct regulator_ops tps65090_ext_control_ops = {
+static const struct regulator_ops tps65090_ext_control_ops = {
 };
 
 /**
@@ -167,19 +167,19 @@ static int tps65090_fet_enable(struct regulator_dev *rdev)
 	return ret;
 }
 
-static struct regulator_ops tps65090_reg_control_ops = {
+static const struct regulator_ops tps65090_reg_control_ops = {
 	.enable		= regulator_enable_regmap,
 	.disable	= regulator_disable_regmap,
 	.is_enabled	= regulator_is_enabled_regmap,
 };
 
-static struct regulator_ops tps65090_fet_control_ops = {
+static const struct regulator_ops tps65090_fet_control_ops = {
 	.enable		= tps65090_fet_enable,
 	.disable	= regulator_disable_regmap,
 	.is_enabled	= regulator_is_enabled_regmap,
 };
 
-static struct regulator_ops tps65090_ldo_ops = {
+static const struct regulator_ops tps65090_ldo_ops = {
 };
 
 #define tps65090_REG_DESC(_id, _sname, _en_reg, _en_bits, _nvolt, _volt, _ops) \
Signature · 1 line
2.28.0
#6 lore raw

PATCH 6/8 regulator: tps6586x: Constify static regulator_ops

In reply to Rikard Falkeborn

The only usage of these are to assign their address to the ops field in the regulator_desc struct, which is a const pointer. Make them const to allow the compiler to put them in read-only memory.

---
 drivers/regulator/tps6586x-regulator.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/regulator/tps6586x-regulator.c +4 -4
index 09e994e1f9a9..18bf4b885b08 100644
@@ -60,7 +60,7 @@ struct tps6586x_regulator {
 	int enable_reg[2];
 };
 
-static struct regulator_ops tps6586x_rw_regulator_ops = {
+static const struct regulator_ops tps6586x_rw_regulator_ops = {
 	.list_voltage = regulator_list_voltage_table,
 	.map_voltage = regulator_map_voltage_ascend,
 	.get_voltage_sel = regulator_get_voltage_sel_regmap,
@@ -71,7 +71,7 @@ static struct regulator_ops tps6586x_rw_regulator_ops = {
 	.disable = regulator_disable_regmap,
 };
 
-static struct regulator_ops tps6586x_rw_linear_regulator_ops = {
+static const struct regulator_ops tps6586x_rw_linear_regulator_ops = {
 	.list_voltage = regulator_list_voltage_linear,
 	.get_voltage_sel = regulator_get_voltage_sel_regmap,
 	.set_voltage_sel = regulator_set_voltage_sel_regmap,
@@ -81,7 +81,7 @@ static struct regulator_ops tps6586x_rw_linear_regulator_ops = {
 	.disable = regulator_disable_regmap,
 };
 
-static struct regulator_ops tps6586x_ro_regulator_ops = {
+static const struct regulator_ops tps6586x_ro_regulator_ops = {
 	.list_voltage = regulator_list_voltage_table,
 	.map_voltage = regulator_map_voltage_ascend,
 	.get_voltage_sel = regulator_get_voltage_sel_regmap,
@@ -91,7 +91,7 @@ static struct regulator_ops tps6586x_ro_regulator_ops = {
 	.disable = regulator_disable_regmap,
 };
 
-static struct regulator_ops tps6586x_sys_regulator_ops = {
+static const struct regulator_ops tps6586x_sys_regulator_ops = {
 };
 
 static const unsigned int tps6586x_ldo0_voltages[] = {
Signature · 1 line
2.28.0
#7 lore raw

PATCH 7/8 regulator: tps65912: Constify static regulator_ops

In reply to Rikard Falkeborn

The only usage of tps65912_ops_dcdc and tps65912_ops_ldo is to assign their address to the ops field in the regulator_desc struct, which is a const pointer. Make them const to allow the compiler to put them in read-only memory.

---
 drivers/regulator/tps65912-regulator.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/regulator/tps65912-regulator.c +2 -2
index 63d6bbd4969b..b52d4f2874b7 100644
@@ -57,7 +57,7 @@ static const struct linear_range tps65912_ldo_ranges[] = {
 };
 
 /* Operations permitted on DCDCx */
-static struct regulator_ops tps65912_ops_dcdc = {
+static const struct regulator_ops tps65912_ops_dcdc = {
 	.is_enabled		= regulator_is_enabled_regmap,
 	.enable			= regulator_enable_regmap,
 	.disable		= regulator_disable_regmap,
@@ -67,7 +67,7 @@ static struct regulator_ops tps65912_ops_dcdc = {
 };
 
 /* Operations permitted on LDOx */
-static struct regulator_ops tps65912_ops_ldo = {
+static const struct regulator_ops tps65912_ops_ldo = {
 	.is_enabled		= regulator_is_enabled_regmap,
 	.enable			= regulator_enable_regmap,
 	.disable		= regulator_disable_regmap,
Signature · 1 line
2.28.0
#8 lore raw

PATCH 8/8 regulator: tps65910: Constify static regulator_ops

In reply to Rikard Falkeborn

The only usage of these is to assign their address to the ops field in the regulator_desc struct, which is a const pointer. Make them const to allow the compiler to put them in read-only memory.

---
 drivers/regulator/tps65910-regulator.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/regulator/tps65910-regulator.c +5 -5
index 4eb5b19d2344..faa5b3538167 100644
@@ -757,7 +757,7 @@ static int tps65911_list_voltage(struct regulator_dev *dev, unsigned selector)
 }
 
 /* Regulator ops (except VRTC) */
-static struct regulator_ops tps65910_ops_dcdc = {
+static const struct regulator_ops tps65910_ops_dcdc = {
 	.is_enabled		= regulator_is_enabled_regmap,
 	.enable			= regulator_enable_regmap,
 	.disable		= regulator_disable_regmap,
@@ -770,7 +770,7 @@ static struct regulator_ops tps65910_ops_dcdc = {
 	.map_voltage		= regulator_map_voltage_ascend,
 };
 
-static struct regulator_ops tps65910_ops_vdd3 = {
+static const struct regulator_ops tps65910_ops_vdd3 = {
 	.is_enabled		= regulator_is_enabled_regmap,
 	.enable			= regulator_enable_regmap,
 	.disable		= regulator_disable_regmap,
@@ -781,7 +781,7 @@ static struct regulator_ops tps65910_ops_vdd3 = {
 	.map_voltage		= regulator_map_voltage_ascend,
 };
 
-static struct regulator_ops tps65910_ops_vbb = {
+static const struct regulator_ops tps65910_ops_vbb = {
 	.is_enabled		= regulator_is_enabled_regmap,
 	.enable			= regulator_enable_regmap,
 	.disable		= regulator_disable_regmap,
@@ -793,7 +793,7 @@ static struct regulator_ops tps65910_ops_vbb = {
 	.map_voltage		= regulator_map_voltage_iterate,
 };
 
-static struct regulator_ops tps65910_ops = {
+static const struct regulator_ops tps65910_ops = {
 	.is_enabled		= regulator_is_enabled_regmap,
 	.enable			= regulator_enable_regmap,
 	.disable		= regulator_disable_regmap,
@@ -805,7 +805,7 @@ static struct regulator_ops tps65910_ops = {
 	.map_voltage		= regulator_map_voltage_ascend,
 };
 
-static struct regulator_ops tps65911_ops = {
+static const struct regulator_ops tps65911_ops = {
 	.is_enabled		= regulator_is_enabled_regmap,
 	.enable			= regulator_enable_regmap,
 	.disable		= regulator_disable_regmap,
Signature · 1 line
2.28.0
maintainer
#9 lore raw
In reply to Rikard Falkeborn
Quoted 14 lines · Rikard Falkeborn

Constify static instances of struct regulator_ops to allow the compiler to put them in read-only memory. Patches are independent. Compile-tested only.

Rikard Falkeborn (8):
regulator: tps51632: Constify tps51632_dcdc_ops
regulator: tps6105x: Constify tps6105x_regulator_ops
regulator: tps62360: Constify tps62360_dcdc_ops
regulator: tps65086: Constify static regulator_ops
regulator: tps65090: constify static regulator_ops
regulator: tps6586x: Constify static regulator_ops
regulator: tps65912: Constify static regulator_ops
regulator: tps65910: Constify static regulator_ops

Quoted 1 line

[...]

Applied to

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

Thanks!

[1/8] regulator: tps51632: Constify tps51632_dcdc_ops

      commit: dcb97c10f967c2cfea4c6316f026bc4a4a165f1e
[2/8] regulator: tps6105x: Constify tps6105x_regulator_ops
      commit: 55c81934e7040c1e0c26b72ee752203ccf190b51
[3/8] regulator: tps62360: Constify tps62360_dcdc_ops
      commit: 01167e88e9372f9748e94a7322b0d43ccb980d9f
[4/8] regulator: tps65086: Constify static regulator_ops
      commit: 2e6d9db83ac7c65b986d3037620dc735dee7383f
[5/8] regulator: tps65090: constify static regulator_ops
      commit: 7d844ac3b5a8a97ae4a05d9f545346a4fca77cea
[6/8] regulator: tps6586x: Constify static regulator_ops
      commit: 25c8044502ca9fb684fe7a0612985069e27e01eb
[7/8] regulator: tps65912: Constify static regulator_ops
      commit: e92b8ef87a8a4a95056d6b5852bd4b5288f34540
[8/8] regulator: tps65910: Constify static regulator_ops
      commit: 385d41d7edbc37d6b30197672b744021ce3baccf

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