msm: clock: Keep proper track of current voltage level
Fix a bug where vdd_class->cur_level is not updated when regulator api
calls are successful. The impact of the bug is unnecessary calls to
regulator APIs but not additional RPM calls since the regulator APIs
will optimize out repeated requests for the same voltage/current.
In case the regulator APIs fail, this bug might also result in
undervolting. But that's an unlikely case in a real product.
Change-Id: Ibe3574b6b72fcf898a5bfe9b5b253a8d0e0125ae
Signed-off-by: Patrick Daly <pdaly@codeaurora.org>
diff --git a/arch/arm/mach-msm/clock.c b/arch/arm/mach-msm/clock.c
index 527d73d..e3c11c5 100644
--- a/arch/arm/mach-msm/clock.c
+++ b/arch/arm/mach-msm/clock.c
@@ -90,16 +90,17 @@
continue;
rc = regulator_set_optimum_mode(r[i], ua[lvl_base + i]);
- if (rc < 0)
+ rc = rc > 0 ? 0 : rc;
+ if (rc)
goto set_mode_fail;
}
if (vdd_class->set_vdd && !vdd_class->num_regulators)
rc = vdd_class->set_vdd(vdd_class, level);
- if (rc < 0)
+ if (!rc)
vdd_class->cur_level = level;
- return 0;
+ return rc;
set_mode_fail:
regulator_set_voltage(r[i], uv[vdd_class->cur_level * n_reg + i],