Skip to content

Commit

Permalink
OPP: Reuse _opp_compare_key() in _opp_add_static_v2()
Browse files Browse the repository at this point in the history
Reuse _opp_compare_key() in _opp_add_static_v2() instead of just
comparing frequency while finding suspend frequency. Also add a comment
over _opp_compare_key() explaining its return values.

Tested-by: Dmitry Osipenko <[email protected]>
Signed-off-by: Viresh Kumar <[email protected]>
  • Loading branch information
vireshk committed Jul 8, 2022
1 parent 4768914 commit 8bdac14
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions drivers/opp/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1636,6 +1636,12 @@ static bool _opp_supported_by_regulators(struct dev_pm_opp *opp,
return true;
}

/*
* Returns
* 0: opp1 == opp2
* 1: opp1 > opp2
* -1: opp1 < opp2
*/
int _opp_compare_key(struct dev_pm_opp *opp1, struct dev_pm_opp *opp2)
{
if (opp1->rate != opp2->rate)
Expand Down
4 changes: 2 additions & 2 deletions drivers/opp/of.c
Original file line number Diff line number Diff line change
Expand Up @@ -929,8 +929,8 @@ static struct dev_pm_opp *_opp_add_static_v2(struct opp_table *opp_table,
/* OPP to select on device suspend */
if (of_property_read_bool(np, "opp-suspend")) {
if (opp_table->suspend_opp) {
/* Pick the OPP with higher rate as suspend OPP */
if (new_opp->rate > opp_table->suspend_opp->rate) {
/* Pick the OPP with higher rate/bw/level as suspend OPP */
if (_opp_compare_key(new_opp, opp_table->suspend_opp) == 1) {
opp_table->suspend_opp->suspend = false;
new_opp->suspend = true;
opp_table->suspend_opp = new_opp;
Expand Down

0 comments on commit 8bdac14

Please sign in to comment.