PM / Domains: Move the Subdomain check into _genpd_power_off

Move the Subdomain check into _genpd_power_off, then the caller does
not have to check it each time. This also ensures a double check
of &genpd->sd_count before really power off domain in case it's
increased asychronously by subdomains. This is the same behavior
as the original genpd_power_off() does.

Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
This commit is contained in:
Dong Aisheng 2019-03-05 17:34:00 +08:00
parent 8102eb7211
commit 070d55393a
1 changed files with 4 additions and 5 deletions

View File

@ -448,6 +448,9 @@ static int _genpd_power_off(struct generic_pm_domain *genpd, bool timed)
if (!genpd->power_off)
return 0;
if (atomic_read(&genpd->sd_count) > 0)
return -EBUSY;
if (!timed)
return genpd->power_off(genpd);
@ -545,9 +548,6 @@ static int genpd_power_off(struct generic_pm_domain *genpd, bool one_dev_on,
if (!genpd->gov)
genpd->state_idx = 0;
if (atomic_read(&genpd->sd_count) > 0)
return -EBUSY;
/*
* If sd_count > 0 at this point, one of the subdomains hasn't
* managed to call genpd_power_on() for the master yet after
@ -960,8 +960,7 @@ static void genpd_sync_power_off(struct generic_pm_domain *genpd, bool use_lock,
if (!genpd_status_on(genpd) || genpd_is_always_on(genpd))
return;
if (genpd->suspended_count != genpd->device_count
|| atomic_read(&genpd->sd_count) > 0)
if (genpd->suspended_count != genpd->device_count)
return;
/* Choose the deepest state when suspending */