aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichał Mirosław <mirq-linux@rere.qmqm.pl>2017-06-13 10:41:56 -0400
committerMark Brown <broonie@kernel.org>2017-06-13 13:46:48 -0400
commitfe953904f3463609a9a671f68148d8532f2a5d9f (patch)
tree216b6bed271058c459131a6f96c0c7ef07d022a7
parent2ea659a9ef488125eb46da6eb571de5eae5c43f6 (diff)
regulator: tps65910: check TPS65910_NUM_REGS at build time
Check TPS65910_NUM_REGS at build time instead of silently registering not all regulators at runtime. Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--drivers/regulator/tps65910-regulator.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/regulator/tps65910-regulator.c b/drivers/regulator/tps65910-regulator.c
index 696116ebdf50..81672a58fcc2 100644
--- a/drivers/regulator/tps65910-regulator.c
+++ b/drivers/regulator/tps65910-regulator.c
@@ -1107,6 +1107,7 @@ static int tps65910_probe(struct platform_device *pdev)
1107 1107
1108 switch (tps65910_chip_id(tps65910)) { 1108 switch (tps65910_chip_id(tps65910)) {
1109 case TPS65910: 1109 case TPS65910:
1110 BUILD_BUG_ON(TPS65910_NUM_REGS < ARRAY_SIZE(tps65910_regs));
1110 pmic->get_ctrl_reg = &tps65910_get_ctrl_register; 1111 pmic->get_ctrl_reg = &tps65910_get_ctrl_register;
1111 pmic->num_regulators = ARRAY_SIZE(tps65910_regs); 1112 pmic->num_regulators = ARRAY_SIZE(tps65910_regs);
1112 pmic->ext_sleep_control = tps65910_ext_sleep_control; 1113 pmic->ext_sleep_control = tps65910_ext_sleep_control;
@@ -1119,6 +1120,7 @@ static int tps65910_probe(struct platform_device *pdev)
1119 DCDCCTRL_DCDCCKSYNC_MASK); 1120 DCDCCTRL_DCDCCKSYNC_MASK);
1120 break; 1121 break;
1121 case TPS65911: 1122 case TPS65911:
1123 BUILD_BUG_ON(TPS65910_NUM_REGS < ARRAY_SIZE(tps65911_regs));
1122 pmic->get_ctrl_reg = &tps65911_get_ctrl_register; 1124 pmic->get_ctrl_reg = &tps65911_get_ctrl_register;
1123 pmic->num_regulators = ARRAY_SIZE(tps65911_regs); 1125 pmic->num_regulators = ARRAY_SIZE(tps65911_regs);
1124 pmic->ext_sleep_control = tps65911_ext_sleep_control; 1126 pmic->ext_sleep_control = tps65911_ext_sleep_control;
@@ -1144,8 +1146,7 @@ static int tps65910_probe(struct platform_device *pdev)
1144 if (!pmic->rdev) 1146 if (!pmic->rdev)
1145 return -ENOMEM; 1147 return -ENOMEM;
1146 1148
1147 for (i = 0; i < pmic->num_regulators && i < TPS65910_NUM_REGS; 1149 for (i = 0; i < pmic->num_regulators; i++, info++) {
1148 i++, info++) {
1149 /* Register the regulators */ 1150 /* Register the regulators */
1150 pmic->info[i] = info; 1151 pmic->info[i] = info;
1151 1152