Skip to content

Commit fe95390

Browse files
osctobebroonie
authored andcommitted
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 <[email protected]> Signed-off-by: Mark Brown <[email protected]>
1 parent 2ea659a commit fe95390

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

drivers/regulator/tps65910-regulator.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1107,6 +1107,7 @@ static int tps65910_probe(struct platform_device *pdev)
11071107

11081108
switch (tps65910_chip_id(tps65910)) {
11091109
case TPS65910:
1110+
BUILD_BUG_ON(TPS65910_NUM_REGS < ARRAY_SIZE(tps65910_regs));
11101111
pmic->get_ctrl_reg = &tps65910_get_ctrl_register;
11111112
pmic->num_regulators = ARRAY_SIZE(tps65910_regs);
11121113
pmic->ext_sleep_control = tps65910_ext_sleep_control;
@@ -1119,6 +1120,7 @@ static int tps65910_probe(struct platform_device *pdev)
11191120
DCDCCTRL_DCDCCKSYNC_MASK);
11201121
break;
11211122
case TPS65911:
1123+
BUILD_BUG_ON(TPS65910_NUM_REGS < ARRAY_SIZE(tps65911_regs));
11221124
pmic->get_ctrl_reg = &tps65911_get_ctrl_register;
11231125
pmic->num_regulators = ARRAY_SIZE(tps65911_regs);
11241126
pmic->ext_sleep_control = tps65911_ext_sleep_control;
@@ -1144,8 +1146,7 @@ static int tps65910_probe(struct platform_device *pdev)
11441146
if (!pmic->rdev)
11451147
return -ENOMEM;
11461148

1147-
for (i = 0; i < pmic->num_regulators && i < TPS65910_NUM_REGS;
1148-
i++, info++) {
1149+
for (i = 0; i < pmic->num_regulators; i++, info++) {
11491150
/* Register the regulators */
11501151
pmic->info[i] = info;
11511152

0 commit comments

Comments
 (0)