提交 efa69025 编写于 作者: R Rafael J. Wysocki

PM / Domains: Make device removal more straightforward

The removal of a device from a PM domain doesn't have to browse
the domain's device list, because it can check directly if the
device belongs to the given domain.  Moreover, it should clear
the domain_data pointer in dev->power.subsys_data, because
dev_pm_put_subsys_data(dev) may not remove dev->power.subsys_data
and the stale domain data pointer may cause problems to happen.

Rework pm_genpd_remove_device() taking the above observations into
account.
Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
上级 23e0fc5a
......@@ -1279,11 +1279,13 @@ int pm_genpd_remove_device(struct generic_pm_domain *genpd,
struct device *dev)
{
struct pm_domain_data *pdd;
int ret = -EINVAL;
int ret = 0;
dev_dbg(dev, "%s()\n", __func__);
if (IS_ERR_OR_NULL(genpd) || IS_ERR_OR_NULL(dev))
if (IS_ERR_OR_NULL(genpd) || IS_ERR_OR_NULL(dev)
|| IS_ERR_OR_NULL(dev->pm_domain)
|| pd_to_genpd(dev->pm_domain) != genpd)
return -EINVAL;
genpd_acquire_lock(genpd);
......@@ -1293,22 +1295,15 @@ int pm_genpd_remove_device(struct generic_pm_domain *genpd,
goto out;
}
list_for_each_entry(pdd, &genpd->dev_list, list_node) {
if (pdd->dev != dev)
continue;
dev->pm_domain = NULL;
pdd = dev->power.subsys_data->domain_data;
list_del_init(&pdd->list_node);
pdd->dev = NULL;
dev->power.subsys_data->domain_data = NULL;
dev_pm_put_subsys_data(dev);
dev->pm_domain = NULL;
kfree(to_gpd_data(pdd));
genpd->device_count--;
ret = 0;
break;
}
out:
genpd_release_lock(genpd);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册