PM / OPP: avoid maybe-uninitialized warning
[cascardo/linux.git] / drivers / base / power / opp / core.c
index 7c04c87..4c7c6da 100644 (file)
@@ -402,6 +402,22 @@ struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev,
 }
 EXPORT_SYMBOL_GPL(dev_pm_opp_find_freq_exact);
 
+static noinline struct dev_pm_opp *_find_freq_ceil(struct opp_table *opp_table,
+                                                  unsigned long *freq)
+{
+       struct dev_pm_opp *temp_opp, *opp = ERR_PTR(-ERANGE);
+
+       list_for_each_entry_rcu(temp_opp, &opp_table->opp_list, node) {
+               if (temp_opp->available && temp_opp->rate >= *freq) {
+                       opp = temp_opp;
+                       *freq = opp->rate;
+                       break;
+               }
+       }
+
+       return opp;
+}
+
 /**
  * dev_pm_opp_find_freq_ceil() - Search for an rounded ceil freq
  * @dev:       device for which we do this operation
@@ -427,7 +443,6 @@ struct dev_pm_opp *dev_pm_opp_find_freq_ceil(struct device *dev,
                                             unsigned long *freq)
 {
        struct opp_table *opp_table;
-       struct dev_pm_opp *temp_opp, *opp = ERR_PTR(-ERANGE);
 
        opp_rcu_lockdep_assert();
 
@@ -440,15 +455,7 @@ struct dev_pm_opp *dev_pm_opp_find_freq_ceil(struct device *dev,
        if (IS_ERR(opp_table))
                return ERR_CAST(opp_table);
 
-       list_for_each_entry_rcu(temp_opp, &opp_table->opp_list, node) {
-               if (temp_opp->available && temp_opp->rate >= *freq) {
-                       opp = temp_opp;
-                       *freq = opp->rate;
-                       break;
-               }
-       }
-
-       return opp;
+       return _find_freq_ceil(opp_table, freq);
 }
 EXPORT_SYMBOL_GPL(dev_pm_opp_find_freq_ceil);
 
@@ -577,7 +584,6 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq)
        struct clk *clk;
        unsigned long freq, old_freq;
        unsigned long u_volt, u_volt_min, u_volt_max;
-       unsigned long ou_volt, ou_volt_min, ou_volt_max;
        int ret;
 
        if (unlikely(!target_freq)) {
@@ -612,17 +618,13 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq)
                return PTR_ERR(opp_table);
        }
 
-       old_opp = dev_pm_opp_find_freq_ceil(dev, &old_freq);
-       if (!IS_ERR(old_opp)) {
-               ou_volt = old_opp->u_volt;
-               ou_volt_min = old_opp->u_volt_min;
-               ou_volt_max = old_opp->u_volt_max;
-       } else {
+       old_opp = _find_freq_ceil(opp_table, &old_freq);
+       if (IS_ERR(old_opp)) {
                dev_err(dev, "%s: failed to find current OPP for freq %lu (%ld)\n",
                        __func__, old_freq, PTR_ERR(old_opp));
        }
 
-       opp = dev_pm_opp_find_freq_ceil(dev, &freq);
+       opp = _find_freq_ceil(opp_table, &freq);
        if (IS_ERR(opp)) {
                ret = PTR_ERR(opp);
                dev_err(dev, "%s: failed to find OPP for freq %lu (%d)\n",
@@ -676,7 +678,8 @@ restore_freq:
 restore_voltage:
        /* This shouldn't harm even if the voltages weren't updated earlier */
        if (!IS_ERR(old_opp))
-               _set_opp_voltage(dev, reg, ou_volt, ou_volt_min, ou_volt_max);
+               _set_opp_voltage(dev, reg, old_opp->u_volt,
+                                old_opp->u_volt_min, old_opp->u_volt_max);
 
        return ret;
 }