summaryrefslogtreecommitdiffstats
path: root/drivers/base
diff options
context:
space:
mode:
authorViresh Kumar <viresh.kumar@linaro.org>2016-12-01 05:58:18 -0500
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2016-12-05 20:27:59 -0500
commitce31781a7574ac1b11b1b66e0d54c8bab41f56eb (patch)
treedd2a07ccc13aff75ce51f892d2deaf507ab5dee3 /drivers/base
parent0f0fe7e01327b3d524787a2e8b7e78f010db2bb8 (diff)
PM / OPP: Pass struct dev_pm_opp_supply to _set_opp_voltage()
Pass the entire supply structure instead of all of its fields. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Tested-by: Dave Gerlach <d-gerlach@ti.com> Reviewed-by: Stephen Boyd <sboyd@codeaurora.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/base')
-rw-r--r--drivers/base/power/opp/core.c44
1 files changed, 17 insertions, 27 deletions
diff --git a/drivers/base/power/opp/core.c b/drivers/base/power/opp/core.c
index 188048d3d203..46ad8470c438 100644
--- a/drivers/base/power/opp/core.c
+++ b/drivers/base/power/opp/core.c
@@ -542,8 +542,7 @@ unlock:
542} 542}
543 543
544static int _set_opp_voltage(struct device *dev, struct regulator *reg, 544static int _set_opp_voltage(struct device *dev, struct regulator *reg,
545 unsigned long u_volt, unsigned long u_volt_min, 545 struct dev_pm_opp_supply *supply)
546 unsigned long u_volt_max)
547{ 546{
548 int ret; 547 int ret;
549 548
@@ -554,14 +553,15 @@ static int _set_opp_voltage(struct device *dev, struct regulator *reg,
554 return 0; 553 return 0;
555 } 554 }
556 555
557 dev_dbg(dev, "%s: voltages (mV): %lu %lu %lu\n", __func__, u_volt_min, 556 dev_dbg(dev, "%s: voltages (mV): %lu %lu %lu\n", __func__,
558 u_volt, u_volt_max); 557 supply->u_volt_min, supply->u_volt, supply->u_volt_max);
559 558
560 ret = regulator_set_voltage_triplet(reg, u_volt_min, u_volt, 559 ret = regulator_set_voltage_triplet(reg, supply->u_volt_min,
561 u_volt_max); 560 supply->u_volt, supply->u_volt_max);
562 if (ret) 561 if (ret)
563 dev_err(dev, "%s: failed to set voltage (%lu %lu %lu mV): %d\n", 562 dev_err(dev, "%s: failed to set voltage (%lu %lu %lu mV): %d\n",
564 __func__, u_volt_min, u_volt, u_volt_max, ret); 563 __func__, supply->u_volt_min, supply->u_volt,
564 supply->u_volt_max, ret);
565 565
566 return ret; 566 return ret;
567} 567}
@@ -583,8 +583,7 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq)
583 struct regulator *reg; 583 struct regulator *reg;
584 struct clk *clk; 584 struct clk *clk;
585 unsigned long freq, old_freq; 585 unsigned long freq, old_freq;
586 unsigned long u_volt, u_volt_min, u_volt_max; 586 struct dev_pm_opp_supply old_supply, new_supply;
587 unsigned long old_u_volt, old_u_volt_min, old_u_volt_max;
588 int ret; 587 int ret;
589 588
590 if (unlikely(!target_freq)) { 589 if (unlikely(!target_freq)) {
@@ -634,17 +633,12 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq)
634 return ret; 633 return ret;
635 } 634 }
636 635
637 if (IS_ERR(old_opp)) { 636 if (IS_ERR(old_opp))
638 old_u_volt = 0; 637 old_supply.u_volt = 0;
639 } else { 638 else
640 old_u_volt = old_opp->supply.u_volt; 639 memcpy(&old_supply, &old_opp->supply, sizeof(old_supply));
641 old_u_volt_min = old_opp->supply.u_volt_min;
642 old_u_volt_max = old_opp->supply.u_volt_max;
643 }
644 640
645 u_volt = opp->supply.u_volt; 641 memcpy(&new_supply, &opp->supply, sizeof(new_supply));
646 u_volt_min = opp->supply.u_volt_min;
647 u_volt_max = opp->supply.u_volt_max;
648 642
649 reg = opp_table->regulator; 643 reg = opp_table->regulator;
650 644
@@ -652,8 +646,7 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq)
652 646
653 /* Scaling up? Scale voltage before frequency */ 647 /* Scaling up? Scale voltage before frequency */
654 if (freq > old_freq) { 648 if (freq > old_freq) {
655 ret = _set_opp_voltage(dev, reg, u_volt, u_volt_min, 649 ret = _set_opp_voltage(dev, reg, &new_supply);
656 u_volt_max);
657 if (ret) 650 if (ret)
658 goto restore_voltage; 651 goto restore_voltage;
659 } 652 }
@@ -672,8 +665,7 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq)
672 665
673 /* Scaling down? Scale voltage after frequency */ 666 /* Scaling down? Scale voltage after frequency */
674 if (freq < old_freq) { 667 if (freq < old_freq) {
675 ret = _set_opp_voltage(dev, reg, u_volt, u_volt_min, 668 ret = _set_opp_voltage(dev, reg, &new_supply);
676 u_volt_max);
677 if (ret) 669 if (ret)
678 goto restore_freq; 670 goto restore_freq;
679 } 671 }
@@ -686,10 +678,8 @@ restore_freq:
686 __func__, old_freq); 678 __func__, old_freq);
687restore_voltage: 679restore_voltage:
688 /* This shouldn't harm even if the voltages weren't updated earlier */ 680 /* This shouldn't harm even if the voltages weren't updated earlier */
689 if (old_u_volt) { 681 if (old_supply.u_volt)
690 _set_opp_voltage(dev, reg, old_u_volt, old_u_volt_min, 682 _set_opp_voltage(dev, reg, &old_supply);
691 old_u_volt_max);
692 }
693 683
694 return ret; 684 return ret;
695} 685}