drivers/regulator: Constify static variables
cover drivers/regulator: Constify static variables
Constify a couple of static variables, most importantly regulator_ops to allow the compiler to put them in read-only memory.
Rikard Falkeborn (5):
regulator: dummy: Constify dummy_initdata and dummy_ops
regulator: fixed: Constify static regulator_ops
regulator: stw481x-vmmc: Constify static structs
regulator: pca9450: Constify static regulator_ops
regulator: ti-abb: Constify ti_abb_reg_ops
drivers/regulator/dummy.c | 4 ++-- drivers/regulator/fixed.c | 4 ++-- drivers/regulator/pca9450-regulator.c | 6 +++--- drivers/regulator/stw481x-vmmc.c | 4 ++-- drivers/regulator/ti-abb-regulator.c | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-)
Signature · 1 line
2.28.0
PATCH 1/5 regulator: dummy: Constify dummy_initdata and dummy_ops
The only usage of dummy_initdata is to assign its address to the init_data field of the regulator_config struct and the only usage dummy_ops is to assign its address to the ops field in the regulator_desc struct, both which are const pointers. Make them const to allow the compiler to put them in read-only memory.
--- drivers/regulator/dummy.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/regulator/dummy.c +2 -2
@@ -21,13 +21,13 @@struct regulator_dev *dummy_regulator_rdev; -static struct regulator_init_data dummy_initdata = { +static const struct regulator_init_data dummy_initdata = { .constraints = { .always_on =1 , }, }; -static struct regulator_ops dummy_ops; +static const struct regulator_ops dummy_ops;static const struct regulator_desc dummy_desc = { .name ="regulator-dummy" ,
Signature · 1 line
2.28.0
PATCH 2/5 regulator: fixed: Constify static regulator_ops
In reply to Rikard FalkebornThe only usage of fixed_voltage_ops and fixed_voltage_clkenabled_ops is to assign their address 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.
make them const to allow the compiler to put them in read-only memory.
--- drivers/regulator/fixed.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/regulator/fixed.c +2 -2
@@ -123,10 +123,10 @@ of_get_fixed_voltage_config(struct device *dev,return config; } -static struct regulator_ops fixed_voltage_ops = { +static const struct regulator_ops fixed_voltage_ops = { }; -static struct regulator_ops fixed_voltage_clkenabled_ops = { +static const struct regulator_ops fixed_voltage_clkenabled_ops = { .enable = reg_clock_enable, .disable = reg_clock_disable, .is_enabled = reg_clock_is_enabled,
Signature · 1 line
2.28.0
PATCH 3/5 regulator: stw481x-vmmc: Constify static structs
In reply to Rikard FalkebornThe only usage of stw481x_vmmc_ops is to assign its address to the ops field in the regulator_desc struct which is a const pointer.
The only usage of vmmc_regulator is to pass its address to of_get_regulator_init_data() and devm_regulator_register(), both which take const pointers.
Make both of them const to allow the compiler to put them in read-only memory.
--- drivers/regulator/stw481x-vmmc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/regulator/stw481x-vmmc.c +2 -2
@@ -27,7 +27,7 @@ static const unsigned int stw481x_vmmc_voltages[] = { 3300000, }; -static struct regulator_ops stw481x_vmmc_ops = { +static const struct regulator_ops stw481x_vmmc_ops = { .list_voltage = regulator_list_voltage_table, .enable = regulator_enable_regmap, .disable = regulator_disable_regmap,
@@ -36,7 +36,7 @@ static struct regulator_ops stw481x_vmmc_ops = { .set_voltage_sel = regulator_set_voltage_sel_regmap, }; -static struct regulator_desc vmmc_regulator = { +static const struct regulator_desc vmmc_regulator = { .name ="VMMC" , .id =0 , .ops = &stw481x_vmmc_ops,
Signature · 1 line
2.28.0
PATCH 4/5 regulator: pca9450: Constify static regulator_ops
In reply to Rikard FalkebornThe only usages 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/pca9450-regulator.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/regulator/pca9450-regulator.c +3 -3
@@ -90,7 +90,7 @@ static int pca9450_dvs_set_ramp_delay(struct regulator_dev *rdev, BUCK1_RAMP_MASK, ramp_value << 6); } -static struct regulator_ops pca9450_dvs_buck_regulator_ops = { +static const struct regulator_ops pca9450_dvs_buck_regulator_ops = { .enable = regulator_enable_regmap, .disable = regulator_disable_regmap, .is_enabled = regulator_is_enabled_regmap,
@@ -101,7 +101,7 @@ static struct regulator_ops pca9450_dvs_buck_regulator_ops = { .set_ramp_delay = pca9450_dvs_set_ramp_delay, }; -static struct regulator_ops pca9450_buck_regulator_ops = { +static const struct regulator_ops pca9450_buck_regulator_ops = { .enable = regulator_enable_regmap, .disable = regulator_disable_regmap, .is_enabled = regulator_is_enabled_regmap,
@@ -111,7 +111,7 @@ static struct regulator_ops pca9450_buck_regulator_ops = { .set_voltage_time_sel = regulator_set_voltage_time_sel, }; -static struct regulator_ops pca9450_ldo_regulator_ops = { +static const struct regulator_ops pca9450_ldo_regulator_ops = { .enable = regulator_enable_regmap, .disable = regulator_disable_regmap, .is_enabled = regulator_is_enabled_regmap,
Signature · 1 line
2.28.0
PATCH 5/5 regulator: ti-abb: Constify ti_abb_reg_ops
In reply to Rikard FalkebornThe only usage of ti_abb_reg_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/ti-abb-regulator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/regulator/ti-abb-regulator.c +1 -1
@@ -619,7 +619,7 @@ static int ti_abb_init_table(struct device *dev, struct ti_abb *abb,return 0 ; } -static struct regulator_ops ti_abb_reg_ops = { +static const struct regulator_ops ti_abb_reg_ops = { .list_voltage = regulator_list_voltage_table, .set_voltage_sel = ti_abb_set_voltage_sel,
Signature · 1 line
2.28.0
Mark Brown
maintainerQuoted 11 lines · Rikard Falkeborn
Constify a couple of static variables, most importantly
regulator_opsto allow the compiler to put them in read-only memory.Rikard Falkeborn (5):
regulator: dummy: Constifydummy_initdataanddummy_ops
regulator: fixed: Constify staticregulator_ops
regulator: stw481x-vmmc: Constify static structs
regulator: pca9450: Constify staticregulator_ops
regulator: ti-abb: Constifyti_abb_reg_ops[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-next
Thanks!
[1/5] regulator: dummy: Constify dummy_initdata and dummy_ops
commit: 087c09c2d273823bac906d590280f7e8052f7eff
[2/5] regulator: fixed: Constify static regulator_ops
commit: 96ee75ffd4f63a3d5f9d6a3ea592b2c0ee97acb0
[3/5] regulator: stw481x-vmmc: Constify static structs
commit: 9032693e218e69a9527fd5d08c4ce5cdbe90820f
[4/5] regulator: pca9450: Constify static regulator_ops
commit: 72f2746c52e3fa6c0f6740df2d4fb70419533084
[5/5] regulator: ti-abb: Constify ti_abb_reg_ops
commit: 2b37a18b58ed12b711591ec54c2b2a0e2068cf6eAll 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