]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
regulator: scmi: Fix off-by-one for linear regulators .n_voltages setting
authorAxel Lin <axel.lin@ingics.com>
Fri, 21 May 2021 07:30:20 +0000 (15:30 +0800)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Thu, 15 Jul 2021 17:24:20 +0000 (19:24 +0200)
BugLink: https://bugs.launchpad.net/bugs/1934012
commit 36cb555fae0875d5416e8514a84a427bec6e4cda upstream.

For linear regulators, the .n_voltages is (max_uv - min_uv) / uv_step + 1.

Fixes: 0fbeae70ee7c ("regulator: add SCMI driver")
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Reviewed-by: Cristian Marussi <cristian.marussi@arm.com>
Link: https://lore.kernel.org/r/20210521073020.1944981-1-axel.lin@ingics.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
drivers/regulator/scmi-regulator.c

index 0e8b3caa81461cd12d884298acccf31e90c42f9b..66ffc2d54e979ff730caa23586e35c75e82c0798 100644 (file)
@@ -176,7 +176,7 @@ scmi_config_linear_regulator_mappings(struct scmi_regulator *sreg,
                sreg->desc.uV_step =
                        vinfo->levels_uv[SCMI_VOLTAGE_SEGMENT_STEP];
                sreg->desc.linear_min_sel = 0;
-               sreg->desc.n_voltages = delta_uV / sreg->desc.uV_step;
+               sreg->desc.n_voltages = (delta_uV / sreg->desc.uV_step) + 1;
                sreg->desc.ops = &scmi_reg_linear_ops;
        }