aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>2015-09-08 12:41:01 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2015-09-08 20:20:39 -0400
commit4eafbd15b6c84cd3f6c76022c8a6c27f7cc076e1 (patch)
tree830405d520490c0ad7d7620551910fbb95508459
parent50a3cb04a5f9cd5323a76db9ee409a7f3004259a (diff)
PM / OPP: add dev_pm_opp_get_suspend_opp() helper
Add dev_pm_opp_get_suspend_opp() helper to obtain suspend opp. Acked-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r--drivers/base/power/opp.c30
-rw-r--r--include/linux/pm_opp.h6
2 files changed, 36 insertions, 0 deletions
diff --git a/drivers/base/power/opp.c b/drivers/base/power/opp.c
index bb703b5ebaff..3df62dbcec3a 100644
--- a/drivers/base/power/opp.c
+++ b/drivers/base/power/opp.c
@@ -341,6 +341,36 @@ 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, 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 struct dev_pm_opp *opp;
360
361 opp_rcu_lockdep_assert();
362
363 dev_opp = _find_device_opp(dev);
364 if (IS_ERR(dev_opp))
365 opp = NULL;
366 else
367 opp = dev_opp->suspend_opp;
368
369 return opp;
370}
371EXPORT_SYMBOL_GPL(dev_pm_opp_get_suspend_opp);
372
373/**
344 * dev_pm_opp_get_opp_count() - Get number of opps available in the opp list 374 * dev_pm_opp_get_opp_count() - Get number of opps available in the opp list
345 * @dev: device for which we do this operation 375 * @dev: device for which we do this operation
346 * 376 *
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{