Skip to content

Commit fe0c2ba

Browse files
storulfrafaeljw
authored andcommitted
PM / Domains: Convert to dev_to_genpd_safe() in genpd_syscore_switch()
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 <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 1b32999 commit fe0c2ba

File tree

1 file changed

+12
-20
lines changed

1 file changed

+12
-20
lines changed

drivers/base/power/domain.c

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -929,24 +929,6 @@ static int __init genpd_power_off_unused(void)
929929
}
930930
late_initcall(genpd_power_off_unused);
931931

932-
#if defined(CONFIG_PM_SLEEP) || defined(CONFIG_PM_GENERIC_DOMAINS_OF)
933-
934-
static bool genpd_present(const struct generic_pm_domain *genpd)
935-
{
936-
const struct generic_pm_domain *gpd;
937-
938-
if (IS_ERR_OR_NULL(genpd))
939-
return false;
940-
941-
list_for_each_entry(gpd, &gpd_list, gpd_list_node)
942-
if (gpd == genpd)
943-
return true;
944-
945-
return false;
946-
}
947-
948-
#endif
949-
950932
#ifdef CONFIG_PM_SLEEP
951933

952934
/**
@@ -1361,8 +1343,8 @@ static void genpd_syscore_switch(struct device *dev, bool suspend)
13611343
{
13621344
struct generic_pm_domain *genpd;
13631345

1364-
genpd = dev_to_genpd(dev);
1365-
if (!genpd_present(genpd))
1346+
genpd = dev_to_genpd_safe(dev);
1347+
if (!genpd)
13661348
return;
13671349

13681350
if (suspend) {
@@ -2028,6 +2010,16 @@ static int genpd_add_provider(struct device_node *np, genpd_xlate_t xlate,
20282010
return 0;
20292011
}
20302012

2013+
static bool genpd_present(const struct generic_pm_domain *genpd)
2014+
{
2015+
const struct generic_pm_domain *gpd;
2016+
2017+
list_for_each_entry(gpd, &gpd_list, gpd_list_node)
2018+
if (gpd == genpd)
2019+
return true;
2020+
return false;
2021+
}
2022+
20312023
/**
20322024
* of_genpd_add_provider_simple() - Register a simple PM domain provider
20332025
* @np: Device node pointer associated with the PM domain provider.

0 commit comments

Comments
 (0)