ipq806x: opp/core: update patch updating voltage tolerance on voltage adjust
authorAnsuel Smith <ansuelsmth@gmail.com>
Sun, 15 Dec 2019 02:01:29 +0000 (03:01 +0100)
committerPetr Štetiar <ynezz@true.cz>
Thu, 26 Dec 2019 07:31:41 +0000 (08:31 +0100)
Rework 0052-PM-OPP-Update-the-voltage-tolerance-when-adjusting-t
to reflect changes upstream.

- Skip unnecessary allocation of buffer to set u_volt
- Change opp u_volt directly

Tested-by: Stefan Lippers-Hollmann <s.l-h@gmx.de> [nbg6817/ipq8065]
Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
target/linux/ipq806x/patches-4.19/0052-PM-OPP-Update-the-voltage-tolerance-when-adjusting-t.patch

index 2882f505d918411840bc8ececd0689c9a65a62e4..f940d8ca624be6e35c35d7fe2df396b17b11fa7d 100644 (file)
@@ -17,22 +17,31 @@ Signed-off-by: Georgi Djakov <georgi.djakov@linaro.org>
 
 --- a/drivers/opp/core.c
 +++ b/drivers/opp/core.c
-@@ -1669,6 +1669,7 @@ int dev_pm_opp_adjust_voltage(struct dev
+@@ -1663,6 +1663,7 @@
        struct opp_table *opp_table;
-       struct dev_pm_opp *new_opp, *tmp_opp, *opp = ERR_PTR(-ENODEV);
+       struct dev_pm_opp *tmp_opp, *opp = ERR_PTR(-ENODEV);
        int r = 0;
 +      unsigned long tol;
  
-       /* keep the node allocated */
-       new_opp = kmalloc(sizeof(*new_opp), GFP_KERNEL);
-@@ -1705,6 +1706,10 @@ int dev_pm_opp_adjust_voltage(struct dev
+       /* Find the opp_table */
+       opp_table = _find_opp_table(dev);
+@@ -1692,8 +1693,17 @@
+               goto adjust_unlock;
  
-       /* plug in new node */
-       new_opp->supplies[0].u_volt = u_volt;
+       opp->supplies->u_volt = u_volt;
+-      opp->supplies->u_volt_min = u_volt_min;
+-      opp->supplies->u_volt_max = u_volt_max;
++
 +      tol = u_volt * opp_table->voltage_tolerance_v1 / 100;
-+      new_opp->supplies[0].u_volt = u_volt;
-+      new_opp->supplies[0].u_volt_min = u_volt - tol;
-+      new_opp->supplies[0].u_volt_max = u_volt + tol;
++      if ( u_volt_min == u_volt )
++              opp->supplies->u_volt_min = u_volt - tol;
++      else
++              opp->supplies->u_volt_min = u_volt_min;
++
++      if ( u_volt_max == u_volt )
++              opp->supplies->u_volt_max = u_volt + tol;
++      else
++              opp->supplies->u_volt_max = u_volt_max;
  
-       list_replace(&opp->node, &new_opp->node);
-       mutex_unlock(&opp_table_lock);
+       dev_pm_opp_get(opp);
+       mutex_unlock(&opp_table->lock);