aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorViresh Kumar <viresh.kumar@linaro.org>2017-05-23 00:02:11 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2017-06-21 21:15:30 -0400
commit478256bddb0323898694bd22acdf42a70d4ff024 (patch)
treee71235d1e388a265d04708a99ef33fb7c44dad02
parentc74b32fadc00f2412d86a19295eb867b1a772948 (diff)
PM / OPP: Don't create copy of regulators unnecessarily
This code was required while the OPP core was managed with help of RCUs, but not anymore. Get rid of unnecessary alloc/memcpy operations. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Stephen Boyd <sboyd@codeaurora.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r--drivers/base/power/opp/core.c14
1 files changed, 3 insertions, 11 deletions
diff --git a/drivers/base/power/opp/core.c b/drivers/base/power/opp/core.c
index c4590fc017ba..5ee7aadf0abf 100644
--- a/drivers/base/power/opp/core.c
+++ b/drivers/base/power/opp/core.c
@@ -180,7 +180,7 @@ unsigned long dev_pm_opp_get_max_volt_latency(struct device *dev)
180{ 180{
181 struct opp_table *opp_table; 181 struct opp_table *opp_table;
182 struct dev_pm_opp *opp; 182 struct dev_pm_opp *opp;
183 struct regulator *reg, **regulators; 183 struct regulator *reg;
184 unsigned long latency_ns = 0; 184 unsigned long latency_ns = 0;
185 int ret, i, count; 185 int ret, i, count;
186 struct { 186 struct {
@@ -198,15 +198,9 @@ unsigned long dev_pm_opp_get_max_volt_latency(struct device *dev)
198 if (!count) 198 if (!count)
199 goto put_opp_table; 199 goto put_opp_table;
200 200
201 regulators = kmalloc_array(count, sizeof(*regulators), GFP_KERNEL);
202 if (!regulators)
203 goto put_opp_table;
204
205 uV = kmalloc_array(count, sizeof(*uV), GFP_KERNEL); 201 uV = kmalloc_array(count, sizeof(*uV), GFP_KERNEL);
206 if (!uV) 202 if (!uV)
207 goto free_regulators; 203 goto put_opp_table;
208
209 memcpy(regulators, opp_table->regulators, count * sizeof(*regulators));
210 204
211 mutex_lock(&opp_table->lock); 205 mutex_lock(&opp_table->lock);
212 206
@@ -232,15 +226,13 @@ unsigned long dev_pm_opp_get_max_volt_latency(struct device *dev)
232 * isn't freed, while we are executing this routine. 226 * isn't freed, while we are executing this routine.
233 */ 227 */
234 for (i = 0; i < count; i++) { 228 for (i = 0; i < count; i++) {
235 reg = regulators[i]; 229 reg = opp_table->regulators[i];
236 ret = regulator_set_voltage_time(reg, uV[i].min, uV[i].max); 230 ret = regulator_set_voltage_time(reg, uV[i].min, uV[i].max);
237 if (ret > 0) 231 if (ret > 0)
238 latency_ns += ret * 1000; 232 latency_ns += ret * 1000;
239 } 233 }
240 234
241 kfree(uV); 235 kfree(uV);
242free_regulators:
243 kfree(regulators);
244put_opp_table: 236put_opp_table:
245 dev_pm_opp_put_opp_table(opp_table); 237 dev_pm_opp_put_opp_table(opp_table);
246 238