提交 a7f3987e 编写于 作者: V Viresh Kumar 提交者: Rafael J. Wysocki

PM / OPP: Simplify _opp_set_availability()

As we don't use RCU locking anymore, there is no need to replace an
earlier OPP node with a new one. Just update the existing one.
Signed-off-by: NViresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: NStephen Boyd <sboyd@codeaurora.org>
Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
上级 052c6f19
...@@ -1510,20 +1510,15 @@ static int _opp_set_availability(struct device *dev, unsigned long freq, ...@@ -1510,20 +1510,15 @@ static int _opp_set_availability(struct device *dev, unsigned long freq,
bool availability_req) bool availability_req)
{ {
struct opp_table *opp_table; struct opp_table *opp_table;
struct dev_pm_opp *new_opp, *tmp_opp, *opp = ERR_PTR(-ENODEV); struct dev_pm_opp *tmp_opp, *opp = ERR_PTR(-ENODEV);
int r = 0; int r = 0;
/* keep the node allocated */
new_opp = kmalloc(sizeof(*new_opp), GFP_KERNEL);
if (!new_opp)
return -ENOMEM;
/* Find the opp_table */ /* Find the opp_table */
opp_table = _find_opp_table(dev); opp_table = _find_opp_table(dev);
if (IS_ERR(opp_table)) { if (IS_ERR(opp_table)) {
r = PTR_ERR(opp_table); r = PTR_ERR(opp_table);
dev_warn(dev, "%s: Device OPP not found (%d)\n", __func__, r); dev_warn(dev, "%s: Device OPP not found (%d)\n", __func__, r);
goto free_opp; return r;
} }
mutex_lock(&opp_table->lock); mutex_lock(&opp_table->lock);
...@@ -1544,32 +1539,20 @@ static int _opp_set_availability(struct device *dev, unsigned long freq, ...@@ -1544,32 +1539,20 @@ static int _opp_set_availability(struct device *dev, unsigned long freq,
/* Is update really needed? */ /* Is update really needed? */
if (opp->available == availability_req) if (opp->available == availability_req)
goto unlock; goto unlock;
/* copy the old data over */
*new_opp = *opp;
/* plug in new node */
new_opp->available = availability_req;
list_replace(&opp->node, &new_opp->node); opp->available = availability_req;
kfree(opp);
/* Notify the change of the OPP availability */ /* Notify the change of the OPP availability */
if (availability_req) if (availability_req)
blocking_notifier_call_chain(&opp_table->head, OPP_EVENT_ENABLE, blocking_notifier_call_chain(&opp_table->head, OPP_EVENT_ENABLE,
new_opp); opp);
else else
blocking_notifier_call_chain(&opp_table->head, blocking_notifier_call_chain(&opp_table->head,
OPP_EVENT_DISABLE, new_opp); OPP_EVENT_DISABLE, opp);
mutex_unlock(&opp_table->lock);
dev_pm_opp_put_opp_table(opp_table);
return 0;
unlock: unlock:
mutex_unlock(&opp_table->lock); mutex_unlock(&opp_table->lock);
dev_pm_opp_put_opp_table(opp_table); dev_pm_opp_put_opp_table(opp_table);
free_opp:
kfree(new_opp);
return r; return r;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册