diff --git a/target/linux/ipq806x/patches-4.19/0052-PM-OPP-Update-the-voltage-tolerance-when-adjusting-t.patch b/target/linux/ipq806x/patches-4.19/0052-PM-OPP-Update-the-voltage-tolerance-when-adjusting-t.patch index 2882f505d91..f940d8ca624 100644 --- a/target/linux/ipq806x/patches-4.19/0052-PM-OPP-Update-the-voltage-tolerance-when-adjusting-t.patch +++ b/target/linux/ipq806x/patches-4.19/0052-PM-OPP-Update-the-voltage-tolerance-when-adjusting-t.patch @@ -17,22 +17,31 @@ Signed-off-by: Georgi Djakov --- 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);