aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base
diff options
context:
space:
mode:
authorRafael J. Wysocki <rjw@sisk.pl>2012-08-06 19:08:37 -0400
committerRafael J. Wysocki <rjw@sisk.pl>2012-09-03 19:36:52 -0400
commitfb7268be9f72bed6ae48554f00f2dcb2ef333bfc (patch)
tree2e77fa08d00b04cf4902f6906489ada6bc41fc2f /drivers/base
parentb5abb085f5540a612b0b7a6326ae2a07de2330dd (diff)
PM / Domains: Make it possible to use names when adding subdomains
Add a new helper function, pm_genpd_add_subdomain_names(), allowing the caller to add a subdomain to a generic PM domain using names for domain identification (both domains have to be initialized before). This function is useful for adding subdomains to PM domains whose representations are stored in tables, when the caller doesn't know the indices of the domain to add the subdomain to and of the subdomain itself, but it knows the domains' names. Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Diffstat (limited to 'drivers/base')
-rw-r--r--drivers/base/power/domain.c32
1 files changed, 31 insertions, 1 deletions
diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
index ac06d0280b42..cddf818f493c 100644
--- a/drivers/base/power/domain.c
+++ b/drivers/base/power/domain.c
@@ -1584,7 +1584,8 @@ int pm_genpd_add_subdomain(struct generic_pm_domain *genpd,
1584 struct gpd_link *link; 1584 struct gpd_link *link;
1585 int ret = 0; 1585 int ret = 0;
1586 1586
1587 if (IS_ERR_OR_NULL(genpd) || IS_ERR_OR_NULL(subdomain)) 1587 if (IS_ERR_OR_NULL(genpd) || IS_ERR_OR_NULL(subdomain)
1588 || genpd == subdomain)
1588 return -EINVAL; 1589 return -EINVAL;
1589 1590
1590 start: 1591 start:
@@ -1631,6 +1632,35 @@ int pm_genpd_add_subdomain(struct generic_pm_domain *genpd,
1631} 1632}
1632 1633
1633/** 1634/**
1635 * pm_genpd_add_subdomain_names - Add a subdomain to an I/O PM domain.
1636 * @master_name: Name of the master PM domain to add the subdomain to.
1637 * @subdomain_name: Name of the subdomain to be added.
1638 */
1639int pm_genpd_add_subdomain_names(const char *master_name,
1640 const char *subdomain_name)
1641{
1642 struct generic_pm_domain *master = NULL, *subdomain = NULL, *gpd;
1643
1644 if (IS_ERR_OR_NULL(master_name) || IS_ERR_OR_NULL(subdomain_name))
1645 return -EINVAL;
1646
1647 mutex_lock(&gpd_list_lock);
1648 list_for_each_entry(gpd, &gpd_list, gpd_list_node) {
1649 if (!master && !strcmp(gpd->name, master_name))
1650 master = gpd;
1651
1652 if (!subdomain && !strcmp(gpd->name, subdomain_name))
1653 subdomain = gpd;
1654
1655 if (master && subdomain)
1656 break;
1657 }
1658 mutex_unlock(&gpd_list_lock);
1659
1660 return pm_genpd_add_subdomain(master, subdomain);
1661}
1662
1663/**
1634 * pm_genpd_remove_subdomain - Remove a subdomain from an I/O PM domain. 1664 * pm_genpd_remove_subdomain - Remove a subdomain from an I/O PM domain.
1635 * @genpd: Master PM domain to remove the subdomain from. 1665 * @genpd: Master PM domain to remove the subdomain from.
1636 * @subdomain: Subdomain to be removed. 1666 * @subdomain: Subdomain to be removed.