OPP: Reuse _opp_compare_key() in _opp_add_static_v2()
authorViresh Kumar <viresh.kumar@linaro.org>
Fri, 10 Jun 2022 05:02:50 +0000 (10:32 +0530)
committerViresh Kumar <viresh.kumar@linaro.org>
Fri, 8 Jul 2022 05:57:51 +0000 (11:27 +0530)
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 <dmitry.osipenko@collabora.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
drivers/opp/core.c
drivers/opp/of.c

index ae5949656d77b27a996dcdf9746340c82400110d..00d5911b20f8102b4a18c5308035f2c8ddae4abb 100644 (file)
@@ -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)
index bec9644a7260425fe0e7fc3b7149a5a3600a03cb..bb49057cb1fc406cc6d0fba7b99055671516c543 100644 (file)
@@ -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;