diff options
author | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2019-03-22 10:12:13 +0100 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2019-03-22 10:12:13 +0100 |
commit | 112a04f653ddf1d4246415e8e0d820002ebe8dca (patch) | |
tree | 8f8f77ed3d577b1bead58da68969f334368296b8 | |
parent | 2a95496634a017c19641f26f00907af75b962f01 (diff) | |
parent | 2071ac985d37efe496782c34318dbead93beb02f (diff) |
Merge branch 'pm-domains' into pm
* pm-domains:
PM / Domains: Avoid a potential deadlock
-rw-r--r-- | drivers/base/power/domain.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 76c9969b7124..96a6dc9d305c 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -1469,12 +1469,12 @@ static int genpd_add_device(struct generic_pm_domain *genpd, struct device *dev, if (IS_ERR(gpd_data)) return PTR_ERR(gpd_data); - genpd_lock(genpd); - ret = genpd->attach_dev ? genpd->attach_dev(genpd, dev) : 0; if (ret) goto out; + genpd_lock(genpd); + dev_pm_domain_set(dev, &genpd->domain); genpd->device_count++; @@ -1482,9 +1482,8 @@ static int genpd_add_device(struct generic_pm_domain *genpd, struct device *dev, list_add_tail(&gpd_data->base.list_node, &genpd->dev_list); - out: genpd_unlock(genpd); - + out: if (ret) genpd_free_dev_data(dev, gpd_data); else @@ -1533,15 +1532,15 @@ static int genpd_remove_device(struct generic_pm_domain *genpd, genpd->device_count--; genpd->max_off_time_changed = true; - if (genpd->detach_dev) - genpd->detach_dev(genpd, dev); - dev_pm_domain_set(dev, NULL); list_del_init(&pdd->list_node); genpd_unlock(genpd); + if (genpd->detach_dev) + genpd->detach_dev(genpd, dev); + genpd_free_dev_data(dev, gpd_data); return 0; |