Skip to content

Commit

Permalink
PM / OPP: Return suspend_opp only if it is enabled
Browse files Browse the repository at this point in the history
There is no point returning suspend_opp, if it is disabled by the core.
As we can't use it at all. Fix it.

Fixes: 4eafbd1 ("PM / OPP: add dev_pm_opp_get_suspend_opp() helper")
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
  • Loading branch information
Viresh Kumar authored and Rafael J. Wysocki committed Sep 9, 2015
1 parent 4eafbd1 commit 1b2b90c
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions drivers/base/power/opp.c
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ EXPORT_SYMBOL_GPL(dev_pm_opp_get_max_clock_latency);
* @dev: device for which we do this operation
*
* Return: This function returns pointer to the suspend opp if it is
* defined, otherwise it returns NULL.
* defined and available, otherwise it returns NULL.
*
* Locking: This function must be called under rcu_read_lock(). opp is a rcu
* protected pointer. The reason for the same is that the opp pointer which is
Expand All @@ -356,17 +356,15 @@ EXPORT_SYMBOL_GPL(dev_pm_opp_get_max_clock_latency);
struct dev_pm_opp *dev_pm_opp_get_suspend_opp(struct device *dev)
{
struct device_opp *dev_opp;
struct dev_pm_opp *opp;

opp_rcu_lockdep_assert();

dev_opp = _find_device_opp(dev);
if (IS_ERR(dev_opp))
opp = NULL;
else
opp = dev_opp->suspend_opp;
if (IS_ERR(dev_opp) || !dev_opp->suspend_opp ||
!dev_opp->suspend_opp->available)
return NULL;

return opp;
return dev_opp->suspend_opp;
}
EXPORT_SYMBOL_GPL(dev_pm_opp_get_suspend_opp);

Expand Down

0 comments on commit 1b2b90c

Please sign in to comment.