]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-4.14/opp-use-opp_table-regulators-to-verify-no-regulator-.patch
autosel patches for 4.14
[thirdparty/kernel/stable-queue.git] / queue-4.14 / opp-use-opp_table-regulators-to-verify-no-regulator-.patch
1 From a1cd749f049a318a4ba33896f34604f383b24ae0 Mon Sep 17 00:00:00 2001
2 From: Viresh Kumar <viresh.kumar@linaro.org>
3 Date: Tue, 11 Dec 2018 16:32:47 +0530
4 Subject: OPP: Use opp_table->regulators to verify no regulator case
5
6 [ Upstream commit 90e3577b5feb42bac1269e16bb3d2bdd8f6df40f ]
7
8 The value of opp_table->regulator_count is not very consistent right now
9 and it may end up being 0 while we do have a "opp-microvolt" property in
10 the OPP table. It was kept that way as we used to check if any
11 regulators are set with the OPP core for a device or not using value of
12 regulator_count.
13
14 Lets use opp_table->regulators for that purpose as the meaning of
15 regulator_count is going to change in the later patches.
16
17 Reported-by: Quentin Perret <quentin.perret@arm.com>
18 Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
19 Signed-off-by: Sasha Levin <sashal@kernel.org>
20 ---
21 drivers/base/power/opp/core.c | 11 +++++++----
22 1 file changed, 7 insertions(+), 4 deletions(-)
23
24 diff --git a/drivers/base/power/opp/core.c b/drivers/base/power/opp/core.c
25 index d4862775b9f6..d5e7e8cc4f22 100644
26 --- a/drivers/base/power/opp/core.c
27 +++ b/drivers/base/power/opp/core.c
28 @@ -192,12 +192,12 @@ unsigned long dev_pm_opp_get_max_volt_latency(struct device *dev)
29 if (IS_ERR(opp_table))
30 return 0;
31
32 - count = opp_table->regulator_count;
33 -
34 /* Regulator may not be required for the device */
35 - if (!count)
36 + if (!opp_table->regulators)
37 goto put_opp_table;
38
39 + count = opp_table->regulator_count;
40 +
41 uV = kmalloc_array(count, sizeof(*uV), GFP_KERNEL);
42 if (!uV)
43 goto put_opp_table;
44 @@ -921,6 +921,9 @@ static bool _opp_supported_by_regulators(struct dev_pm_opp *opp,
45 struct regulator *reg;
46 int i;
47
48 + if (!opp_table->regulators)
49 + return true;
50 +
51 for (i = 0; i < opp_table->regulator_count; i++) {
52 reg = opp_table->regulators[i];
53
54 @@ -1226,7 +1229,7 @@ static int _allocate_set_opp_data(struct opp_table *opp_table)
55 struct dev_pm_set_opp_data *data;
56 int len, count = opp_table->regulator_count;
57
58 - if (WARN_ON(!count))
59 + if (WARN_ON(!opp_table->regulators))
60 return -EINVAL;
61
62 /* space for set_opp_data */
63 --
64 2.19.1
65