aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2015-09-11 09:37:17 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2015-09-11 09:37:17 -0400
commit7c976664d537bca19c9bf892b4d9e5ab7ecea927 (patch)
treedf910dfff1eef04c3d5e9dc585579ae4e96c42ba
parentae982073095a44f004d7ffb9f271077abef9dbcf (diff)
parent1b2b90cbea00670221f062814dc8bcecb3af7b90 (diff)
Merge branch 'pm-opp'
* pm-opp: PM / OPP: Return suspend_opp only if it is enabled PM / OPP: add dev_pm_opp_get_suspend_opp() helper
-rw-r--r--drivers/base/power/opp.c28
-rw-r--r--include/linux/pm_opp.h6
2 files changed, 34 insertions, 0 deletions
diff --git a/drivers/base/power/opp.c b/drivers/base/power/opp.c
index eb254497a494..28cd75c535b0 100644
--- a/drivers/base/power/opp.c
+++ b/drivers/base/power/opp.c
@@ -341,6 +341,34 @@ unsigned long dev_pm_opp_get_max_clock_latency(struct device *dev)
341EXPORT_SYMBOL_GPL(dev_pm_opp_get_max_clock_latency); 341EXPORT_SYMBOL_GPL(dev_pm_opp_get_max_clock_latency);
342 342
343/** 343/**
344 * dev_pm_opp_get_suspend_opp() - Get suspend opp
345 * @dev: device for which we do this operation
346 *
347 * Return: This function returns pointer to the suspend opp if it is
348 * defined and available, otherwise it returns NULL.
349 *
350 * Locking: This function must be called under rcu_read_lock(). opp is a rcu
351 * protected pointer. The reason for the same is that the opp pointer which is
352 * returned will remain valid for use with opp_get_{voltage, freq} only while
353 * under the locked area. The pointer returned must be used prior to unlocking
354 * with rcu_read_unlock() to maintain the integrity of the pointer.
355 */
356struct dev_pm_opp *dev_pm_opp_get_suspend_opp(struct device *dev)
357{
358 struct device_opp *dev_opp;
359
360 opp_rcu_lockdep_assert();
361
362 dev_opp = _find_device_opp(dev);
363 if (IS_ERR(dev_opp) || !dev_opp->suspend_opp ||
364 !dev_opp->suspend_opp->available)
365 return NULL;
366
367 return dev_opp->suspend_opp;
368}
369EXPORT_SYMBOL_GPL(dev_pm_opp_get_suspend_opp);
370
371/**
344 * dev_pm_opp_get_opp_count() - Get number of opps available in the opp list 372 * dev_pm_opp_get_opp_count() - Get number of opps available in the opp list
345 * @dev: device for which we do this operation 373 * @dev: device for which we do this operation
346 * 374 *
diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h
index cab7ba55bedb..e817722ee3f0 100644
--- a/include/linux/pm_opp.h
+++ b/include/linux/pm_opp.h
@@ -34,6 +34,7 @@ bool dev_pm_opp_is_turbo(struct dev_pm_opp *opp);
34 34
35int dev_pm_opp_get_opp_count(struct device *dev); 35int dev_pm_opp_get_opp_count(struct device *dev);
36unsigned long dev_pm_opp_get_max_clock_latency(struct device *dev); 36unsigned long dev_pm_opp_get_max_clock_latency(struct device *dev);
37struct dev_pm_opp *dev_pm_opp_get_suspend_opp(struct device *dev);
37 38
38struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev, 39struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev,
39 unsigned long freq, 40 unsigned long freq,
@@ -80,6 +81,11 @@ static inline unsigned long dev_pm_opp_get_max_clock_latency(struct device *dev)
80 return 0; 81 return 0;
81} 82}
82 83
84static inline struct dev_pm_opp *dev_pm_opp_get_suspend_opp(struct device *dev)
85{
86 return NULL;
87}
88
83static inline struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev, 89static inline struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev,
84 unsigned long freq, bool available) 90 unsigned long freq, bool available)
85{ 91{