Skip to content

Commit

Permalink
PM / Domains: Convert to dev_to_genpd_safe() in genpd_syscore_switch()
Browse files Browse the repository at this point in the history
The intent with walking the gpd_list via calling genpd_present() from
genpd_syscore_switch(), is to make sure the dev->pm_domain pointer belongs
to a registered genpd. However, as a genpd can't be removed if there is a
device attached to it, let's convert to use the quicker dev_to_genpd_safe()
instead.

Due to the above change, this allows us to clean up genpd_present() and
move it inside CONFIG_PM_GENERIC_DOMAINS_OF, so let's do that as well.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
  • Loading branch information
Ulf Hansson authored and Rafael J. Wysocki committed Nov 13, 2019
1 parent 1b32999 commit fe0c2ba
Showing 1 changed file with 12 additions and 20 deletions.
32 changes: 12 additions & 20 deletions drivers/base/power/domain.c
Original file line number Diff line number Diff line change
Expand Up @@ -929,24 +929,6 @@ static int __init genpd_power_off_unused(void)
}
late_initcall(genpd_power_off_unused);

#if defined(CONFIG_PM_SLEEP) || defined(CONFIG_PM_GENERIC_DOMAINS_OF)

static bool genpd_present(const struct generic_pm_domain *genpd)
{
const struct generic_pm_domain *gpd;

if (IS_ERR_OR_NULL(genpd))
return false;

list_for_each_entry(gpd, &gpd_list, gpd_list_node)
if (gpd == genpd)
return true;

return false;
}

#endif

#ifdef CONFIG_PM_SLEEP

/**
Expand Down Expand Up @@ -1361,8 +1343,8 @@ static void genpd_syscore_switch(struct device *dev, bool suspend)
{
struct generic_pm_domain *genpd;

genpd = dev_to_genpd(dev);
if (!genpd_present(genpd))
genpd = dev_to_genpd_safe(dev);
if (!genpd)
return;

if (suspend) {
Expand Down Expand Up @@ -2028,6 +2010,16 @@ static int genpd_add_provider(struct device_node *np, genpd_xlate_t xlate,
return 0;
}

static bool genpd_present(const struct generic_pm_domain *genpd)
{
const struct generic_pm_domain *gpd;

list_for_each_entry(gpd, &gpd_list, gpd_list_node)
if (gpd == genpd)
return true;
return false;
}

/**
* of_genpd_add_provider_simple() - Register a simple PM domain provider
* @np: Device node pointer associated with the PM domain provider.
Expand Down

0 comments on commit fe0c2ba

Please sign in to comment.