[V6,10/10] PM / OPP: Don't assume platform doesn't have regulators

Message ID f5e2c0fd4f075fd114a48080c5985af6e5abbadc.1480481312.git.viresh.kumar@linaro.org
State New
Headers show

Commit Message

Viresh Kumar Nov. 30, 2016, 5:14 a.m.
If the regulators aren't set explicitly by the platform, the OPP core
assumes that the platform doesn't have any regulator and uses the
clk-only callback.

If the platform failed to register a regulator with the core, then this
can turn out to be a dangerous assumption as the OPP core will try to
change clk without changing regulators.

Handle that properly by making sure that the DT didn't have any entries
for supply voltages as well.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>

Reviewed-by: Stephen Boyd <sboyd@codeaurora.org>

 drivers/base/power/opp/core.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)


To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


diff --git a/drivers/base/power/opp/core.c b/drivers/base/power/opp/core.c
index f60d7f943b64..979403448cd6 100644
--- a/drivers/base/power/opp/core.c
+++ b/drivers/base/power/opp/core.c
@@ -748,7 +748,20 @@  int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq)
 	/* Only frequency scaling */
 	if (!regulators) {
+		unsigned long u_volt = opp->supplies[0].u_volt;
+		/*
+		 * DT contained supply ratings? Consider platform failed to set
+		 * regulators.
+		 */
+		if (unlikely(u_volt)) {
+			dev_err(dev, "%s: Regulator not registered with OPP core\n",
+				__func__);
+			return -EINVAL;
+		}
 		return _generic_set_opp_clk_only(dev, clk, old_freq, freq);