aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base
diff options
context:
space:
mode:
authorRafael J. Wysocki <rjw@sisk.pl>2012-08-06 19:06:11 -0400
committerRafael J. Wysocki <rjw@sisk.pl>2012-09-03 19:36:52 -0400
commitb5abb085f5540a612b0b7a6326ae2a07de2330dd (patch)
tree00098a48ea6b872e1d5f05939a30c0fbb9f5e779 /drivers/base
parentfeb70af0e3ac6817327be70b47731039ea135dbc (diff)
PM / Domains: Make it possible to use domain names when adding devices
Add a new helper function __pm_genpd_name_add_device() allowing a device to be added to a (registered) generic PM domain identified by name. Add a wrapper around it, pm_genpd_name_add_device(), passing NULL as the last argument and reorganize pm_domains.h for the new functions to be defined consistently with the existing ones. These functions are useful for adding devices to PM domains whose representations are stored in tables, when the caller doesn't know the index of the domain to add the device to, but it knows the domain's name. Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Diffstat (limited to 'drivers/base')
-rw-r--r--drivers/base/power/domain.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
index 5f4606f13be6..ac06d0280b42 100644
--- a/drivers/base/power/domain.c
+++ b/drivers/base/power/domain.c
@@ -1465,6 +1465,33 @@ int __pm_genpd_of_add_device(struct device_node *genpd_node, struct device *dev,
1465 return __pm_genpd_add_device(genpd, dev, td); 1465 return __pm_genpd_add_device(genpd, dev, td);
1466} 1466}
1467 1467
1468
1469/**
1470 * __pm_genpd_name_add_device - Find I/O PM domain and add a device to it.
1471 * @domain_name: Name of the PM domain to add the device to.
1472 * @dev: Device to be added.
1473 * @td: Set of PM QoS timing parameters to attach to the device.
1474 */
1475int __pm_genpd_name_add_device(const char *domain_name, struct device *dev,
1476 struct gpd_timing_data *td)
1477{
1478 struct generic_pm_domain *genpd = NULL, *gpd;
1479
1480 if (IS_ERR_OR_NULL(domain_name) || IS_ERR_OR_NULL(dev))
1481 return -EINVAL;
1482
1483 mutex_lock(&gpd_list_lock);
1484 list_for_each_entry(gpd, &gpd_list, gpd_list_node) {
1485 if (!strcmp(gpd->name, domain_name)) {
1486 genpd = gpd;
1487 break;
1488 }
1489 }
1490 mutex_unlock(&gpd_list_lock);
1491
1492 return __pm_genpd_add_device(genpd, dev, td);
1493}
1494
1468/** 1495/**
1469 * pm_genpd_remove_device - Remove a device from an I/O PM domain. 1496 * pm_genpd_remove_device - Remove a device from an I/O PM domain.
1470 * @genpd: PM domain to remove the device from. 1497 * @genpd: PM domain to remove the device from.