Skip to content

Commit d9df93e

Browse files
committed
Merge branch 'pm-opp' into pm-cpufreq
2 parents 63431f7 + 4eafbd1 commit d9df93e

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

drivers/base/power/opp.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,36 @@ unsigned long dev_pm_opp_get_max_clock_latency(struct device *dev)
340340
}
341341
EXPORT_SYMBOL_GPL(dev_pm_opp_get_max_clock_latency);
342342

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+
*/
356+
struct 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+
}
371+
EXPORT_SYMBOL_GPL(dev_pm_opp_get_suspend_opp);
372+
343373
/**
344374
* dev_pm_opp_get_opp_count() - Get number of opps available in the opp list
345375
* @dev: device for which we do this operation

include/linux/pm_opp.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ bool dev_pm_opp_is_turbo(struct dev_pm_opp *opp);
3434

3535
int dev_pm_opp_get_opp_count(struct device *dev);
3636
unsigned long dev_pm_opp_get_max_clock_latency(struct device *dev);
37+
struct dev_pm_opp *dev_pm_opp_get_suspend_opp(struct device *dev);
3738

3839
struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev,
3940
unsigned long freq,
@@ -80,6 +81,11 @@ static inline unsigned long dev_pm_opp_get_max_clock_latency(struct device *dev)
8081
return 0;
8182
}
8283

84+
static inline struct dev_pm_opp *dev_pm_opp_get_suspend_opp(struct device *dev)
85+
{
86+
return NULL;
87+
}
88+
8389
static inline struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev,
8490
unsigned long freq, bool available)
8591
{

0 commit comments

Comments
 (0)