summaryrefslogtreecommitdiffstats
path: root/drivers/opp
diff options
context:
space:
mode:
authorViresh Kumar <viresh.kumar@linaro.org>2018-12-11 16:32:47 +0530
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-02-12 19:47:08 +0100
commita1ea1fb46fbf1b10f32c445aff558a6a9686691e (patch)
tree6e49cb6b98aee17d5a283e76d1ddba0538aafceb /drivers/opp
parent4c67633d4756a98087331614671d99788af12887 (diff)
downloadlinux-stable-a1ea1fb46fbf1b10f32c445aff558a6a9686691e.tar.gz
linux-stable-a1ea1fb46fbf1b10f32c445aff558a6a9686691e.tar.bz2
linux-stable-a1ea1fb46fbf1b10f32c445aff558a6a9686691e.zip
OPP: Use opp_table->regulators to verify no regulator case
[ Upstream commit 90e3577b5feb42bac1269e16bb3d2bdd8f6df40f ] The value of opp_table->regulator_count is not very consistent right now and it may end up being 0 while we do have a "opp-microvolt" property in the OPP table. It was kept that way as we used to check if any regulators are set with the OPP core for a device or not using value of regulator_count. Lets use opp_table->regulators for that purpose as the meaning of regulator_count is going to change in the later patches. Reported-by: Quentin Perret <quentin.perret@arm.com> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/opp')
-rw-r--r--drivers/opp/core.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/drivers/opp/core.c b/drivers/opp/core.c
index 31ff03dbeb83..f3433bf47b10 100644
--- a/drivers/opp/core.c
+++ b/drivers/opp/core.c
@@ -191,12 +191,12 @@ unsigned long dev_pm_opp_get_max_volt_latency(struct device *dev)
if (IS_ERR(opp_table))
return 0;
- count = opp_table->regulator_count;
-
/* Regulator may not be required for the device */
- if (!count)
+ if (!opp_table->regulators)
goto put_opp_table;
+ count = opp_table->regulator_count;
+
uV = kmalloc_array(count, sizeof(*uV), GFP_KERNEL);
if (!uV)
goto put_opp_table;
@@ -976,6 +976,9 @@ static bool _opp_supported_by_regulators(struct dev_pm_opp *opp,
struct regulator *reg;
int i;
+ if (!opp_table->regulators)
+ return true;
+
for (i = 0; i < opp_table->regulator_count; i++) {
reg = opp_table->regulators[i];
@@ -1263,7 +1266,7 @@ static int _allocate_set_opp_data(struct opp_table *opp_table)
struct dev_pm_set_opp_data *data;
int len, count = opp_table->regulator_count;
- if (WARN_ON(!count))
+ if (WARN_ON(!opp_table->regulators))
return -EINVAL;
/* space for set_opp_data */