Skip to content

Commit 72f80ce

Browse files
committed
opp: Rename regulator_enabled and use it as status of all resources
Expand the scope of the regulator_enabled flag and use it to track status of all the resources. This will be used for other stuff in the next patch. Tested-by: Rajendra Nayak <rnayak@codeaurora.org> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
1 parent a4501ba commit 72f80ce

2 files changed

Lines changed: 11 additions & 12 deletions

File tree

‎drivers/opp/core.c‎

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -703,12 +703,10 @@ static int _generic_set_opp_regulator(struct opp_table *opp_table,
703703
* Enable the regulator after setting its voltages, otherwise it breaks
704704
* some boot-enabled regulators.
705705
*/
706-
if (unlikely(!opp_table->regulator_enabled)) {
706+
if (unlikely(!opp_table->enabled)) {
707707
ret = regulator_enable(reg);
708708
if (ret < 0)
709709
dev_warn(dev, "Failed to enable regulator: %d", ret);
710-
else
711-
opp_table->regulator_enabled = true;
712710
}
713711

714712
return 0;
@@ -909,12 +907,12 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq)
909907
if (ret)
910908
goto put_opp_table;
911909

912-
if (opp_table->regulator_enabled) {
910+
if (opp_table->regulators)
913911
regulator_disable(opp_table->regulators[0]);
914-
opp_table->regulator_enabled = false;
915-
}
916912

917913
ret = _set_required_opps(dev, opp_table, NULL);
914+
915+
opp_table->enabled = false;
918916
goto put_opp_table;
919917
}
920918

@@ -1001,8 +999,11 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq)
1001999
dev_err(dev, "Failed to set required opps: %d\n", ret);
10021000
}
10031001

1004-
if (!ret)
1002+
if (!ret) {
10051003
ret = _set_opp_bw(opp_table, opp, dev, false);
1004+
if (!ret)
1005+
opp_table->enabled = true;
1006+
}
10061007

10071008
put_opp:
10081009
dev_pm_opp_put(opp);
@@ -1796,11 +1797,9 @@ void dev_pm_opp_put_regulators(struct opp_table *opp_table)
17961797
/* Make sure there are no concurrent readers while updating opp_table */
17971798
WARN_ON(!list_empty(&opp_table->opp_list));
17981799

1799-
if (opp_table->regulator_enabled) {
1800+
if (opp_table->enabled) {
18001801
for (i = opp_table->regulator_count - 1; i >= 0; i--)
18011802
regulator_disable(opp_table->regulators[i]);
1802-
1803-
opp_table->regulator_enabled = false;
18041803
}
18051804

18061805
for (i = opp_table->regulator_count - 1; i >= 0; i--)

‎drivers/opp/opp.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,11 @@ enum opp_table_access {
147147
* @clk: Device's clock handle
148148
* @regulators: Supply regulators
149149
* @regulator_count: Number of power supply regulators. Its value can be -1
150-
* @regulator_enabled: Set to true if regulators were previously enabled.
151150
* (uninitialized), 0 (no opp-microvolt property) or > 0 (has opp-microvolt
152151
* property).
153152
* @paths: Interconnect path handles
154153
* @path_count: Number of interconnect paths
154+
* @enabled: Set to true if the device's resources are enabled/configured.
155155
* @genpd_performance_state: Device's power domain support performance state.
156156
* @is_genpd: Marks if the OPP table belongs to a genpd.
157157
* @set_opp: Platform specific set_opp callback
@@ -195,9 +195,9 @@ struct opp_table {
195195
struct clk *clk;
196196
struct regulator **regulators;
197197
int regulator_count;
198-
bool regulator_enabled;
199198
struct icc_path **paths;
200199
unsigned int path_count;
200+
bool enabled;
201201
bool genpd_performance_state;
202202
bool is_genpd;
203203

0 commit comments

Comments
 (0)