diff options
author | Viresh Kumar <viresh.kumar@linaro.org> | 2015-11-05 14:21:21 +0530 |
---|---|---|
committer | Alex Shi <alex.shi@linaro.org> | 2016-04-01 13:24:12 +0800 |
commit | 9fbce7bb31236ba5219b6eaca54d8649576bbb9e (patch) | |
tree | dbfad5aaf3686ed55b65d0dfc30a1b2e13e1bc2c | |
parent | c8987bf82a7781afd5b1caebde030783704df60c (diff) |
PM / OPP: Add opp_rcu_lockdep_assert() to _find_device_opp()
_find_device_opp() should be called with rcu-read lock or
dev_opp_list_lock held. Add the opp_rcu_lockdep_assert() check to make
sure caller have taken appropriate locks.
Fix comment over the routine as well.
Suggested-by: Stephen Boyd <sboyd@codeaurora.org>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
(cherry picked from commit 0597e818501f595090a49a1779ab6ec377051b11)
Signed-off-by: Alex Shi <alex.shi@linaro.org>
-rw-r--r-- | drivers/base/power/opp/core.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/drivers/base/power/opp/core.c b/drivers/base/power/opp/core.c index 5189c814b0c6..ced5816d79a8 100644 --- a/drivers/base/power/opp/core.c +++ b/drivers/base/power/opp/core.c @@ -81,14 +81,18 @@ static struct device_opp *_managed_opp(const struct device_node *np) * Return: pointer to 'struct device_opp' if found, otherwise -ENODEV or * -EINVAL based on type of error. * - * Locking: This function must be called under rcu_read_lock(). device_opp - * is a RCU protected pointer. This means that device_opp is valid as long - * as we are under RCU lock. + * Locking: For readers, this function must be called under rcu_read_lock(). + * device_opp is a RCU protected pointer, which means that device_opp is valid + * as long as we are under RCU lock. + * + * For Writers, this function must be called with dev_opp_list_lock held. */ struct device_opp *_find_device_opp(struct device *dev) { struct device_opp *dev_opp; + opp_rcu_lockdep_assert(); + if (IS_ERR_OR_NULL(dev)) { pr_err("%s: Invalid parameters\n", __func__); return ERR_PTR(-EINVAL); |