Skip to content

Commit 8141b6d

Browse files
thom24broonie
authored andcommitted
regulator: tps6594-regulator: Fix the number of irqs for TPS65224 and TPS6594
The number of irqs is computed to allocate the right amount of memory for the irq data. An array of struct tps6594_regulator_irq_data is allocated one time for all the irqs. Each irq uses one cell of the array. If the computed number of irqs is not correct, not allocated memory could be used. Fix the values used in the calculation for TPS6594 and TPS65224. Fixes: 00c8265 (regulator: tps6594-regulator: Add TI TPS65224 PMIC regulators) Signed-off-by: Thomas Richard <thomas.richard@bootlin.com> Tested-by: Nishanth Menon <nm@ti.com> Link: https://msgid.link/r/20240603170100.2394402-1-thomas.richard@bootlin.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent c3f38fa commit 8141b6d

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

drivers/regulator/tps6594-regulator.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -653,18 +653,14 @@ static int tps6594_regulator_probe(struct platform_device *pdev)
653653
}
654654
}
655655

656-
if (tps->chip_id == LP8764) {
657-
nr_buck = ARRAY_SIZE(buck_regs);
658-
nr_ldo = 0;
659-
nr_types = REGS_INT_NB;
660-
} else if (tps->chip_id == TPS65224) {
656+
if (tps->chip_id == TPS65224) {
661657
nr_buck = ARRAY_SIZE(tps65224_buck_regs);
662658
nr_ldo = ARRAY_SIZE(tps65224_ldo_regs);
663-
nr_types = REGS_INT_NB;
659+
nr_types = TPS65224_REGS_INT_NB;
664660
} else {
665661
nr_buck = ARRAY_SIZE(buck_regs);
666-
nr_ldo = ARRAY_SIZE(tps6594_ldo_regs);
667-
nr_types = TPS65224_REGS_INT_NB;
662+
nr_ldo = (tps->chip_id == LP8764) ? 0 : ARRAY_SIZE(tps6594_ldo_regs);
663+
nr_types = REGS_INT_NB;
668664
}
669665

670666
reg_irq_nb = nr_types * (nr_buck + nr_ldo);

0 commit comments

Comments
 (0)