]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commitdiff
Merge branch 'pm-opp'
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 11 Sep 2015 13:37:17 +0000 (15:37 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 11 Sep 2015 13:37:17 +0000 (15:37 +0200)
* pm-opp:
  PM / OPP: Return suspend_opp only if it is enabled
  PM / OPP: add dev_pm_opp_get_suspend_opp() helper

1  2 
drivers/base/power/opp.c

diff --combined drivers/base/power/opp.c
index eb254497a4944454650fb220e4967f5110cec737,4eff4cd7eb546ba46f177d90846178ebd04c69a6..28cd75c535b047f2c4276fed4308fa8159491007
@@@ -148,8 -148,8 +148,8 @@@ static DEFINE_MUTEX(dev_opp_list_lock)
  
  #define opp_rcu_lockdep_assert()                                      \
  do {                                                                  \
 -      rcu_lockdep_assert(rcu_read_lock_held() ||                      \
 -                              lockdep_is_held(&dev_opp_list_lock),    \
 +      RCU_LOCKDEP_WARN(!rcu_read_lock_held() &&                       \
 +                              !lockdep_is_held(&dev_opp_list_lock),   \
                           "Missing rcu_read_lock() or "                \
                           "dev_opp_list_lock protection");             \
  } while (0)
@@@ -340,6 -340,34 +340,34 @@@ unsigned long dev_pm_opp_get_max_clock_
  }
  EXPORT_SYMBOL_GPL(dev_pm_opp_get_max_clock_latency);
  
+ /**
+  * dev_pm_opp_get_suspend_opp() - Get suspend opp
+  * @dev:      device for which we do this operation
+  *
+  * Return: This function returns pointer to the suspend opp if it is
+  * 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
+  * returned will remain valid for use with opp_get_{voltage, freq} only while
+  * under the locked area. The pointer returned must be used prior to unlocking
+  * with rcu_read_unlock() to maintain the integrity of the pointer.
+  */
+ struct dev_pm_opp *dev_pm_opp_get_suspend_opp(struct device *dev)
+ {
+       struct device_opp *dev_opp;
+       opp_rcu_lockdep_assert();
+       dev_opp = _find_device_opp(dev);
+       if (IS_ERR(dev_opp) || !dev_opp->suspend_opp ||
+           !dev_opp->suspend_opp->available)
+               return NULL;
+       return dev_opp->suspend_opp;
+ }
+ EXPORT_SYMBOL_GPL(dev_pm_opp_get_suspend_opp);
  /**
   * dev_pm_opp_get_opp_count() - Get number of opps available in the opp list
   * @dev:      device for which we do this operation