diff options
author | Rafael J. Wysocki <rjw@sisk.pl> | 2012-08-07 01:06:11 +0200 |
---|---|---|
committer | Rafael J. Wysocki <rjw@sisk.pl> | 2012-09-04 01:36:52 +0200 |
commit | b5abb085f5540a612b0b7a6326ae2a07de2330dd (patch) | |
tree | 00098a48ea6b872e1d5f05939a30c0fbb9f5e779 | |
parent | feb70af0e3ac6817327be70b47731039ea135dbc (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>
-rw-r--r-- | drivers/base/power/domain.c | 27 | ||||
-rw-r--r-- | include/linux/pm_domain.h | 43 |
2 files changed, 57 insertions, 13 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, return __pm_genpd_add_device(genpd, dev, td); } + +/** + * __pm_genpd_name_add_device - Find I/O PM domain and add a device to it. + * @domain_name: Name of the PM domain to add the device to. + * @dev: Device to be added. + * @td: Set of PM QoS timing parameters to attach to the device. + */ +int __pm_genpd_name_add_device(const char *domain_name, struct device *dev, + struct gpd_timing_data *td) +{ + struct generic_pm_domain *genpd = NULL, *gpd; + + if (IS_ERR_OR_NULL(domain_name) || IS_ERR_OR_NULL(dev)) + return -EINVAL; + + mutex_lock(&gpd_list_lock); + list_for_each_entry(gpd, &gpd_list, gpd_list_node) { + if (!strcmp(gpd->name, domain_name)) { + genpd = gpd; + break; + } + } + mutex_unlock(&gpd_list_lock); + + return __pm_genpd_add_device(genpd, dev, td); +} + /** * pm_genpd_remove_device - Remove a device from an I/O PM domain. * @genpd: PM domain to remove the device from. diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index 08adf8e5a80e..1991a92b0567 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -138,17 +138,9 @@ extern int __pm_genpd_of_add_device(struct device_node *genpd_node, struct device *dev, struct gpd_timing_data *td); -static inline int pm_genpd_add_device(struct generic_pm_domain *genpd, - struct device *dev) -{ - return __pm_genpd_add_device(genpd, dev, NULL); -} - -static inline int pm_genpd_of_add_device(struct device_node *genpd_node, - struct device *dev) -{ - return __pm_genpd_of_add_device(genpd_node, dev, NULL); -} +extern int __pm_genpd_name_add_device(const char *domain_name, + struct device *dev, + struct gpd_timing_data *td); extern int pm_genpd_remove_device(struct generic_pm_domain *genpd, struct device *dev); @@ -187,8 +179,15 @@ static inline int __pm_genpd_add_device(struct generic_pm_domain *genpd, { return -ENOSYS; } -static inline int pm_genpd_add_device(struct generic_pm_domain *genpd, - struct device *dev) +static inline int __pm_genpd_of_add_device(struct device_node *genpd_node, + struct device *dev, + struct gpd_timing_data *td) +{ + return -ENOSYS; +} +static inline int __pm_genpd_name_add_device(const char *domain_name, + struct device *dev, + struct gpd_timing_data *td) { return -ENOSYS; } @@ -242,6 +241,24 @@ static inline bool default_stop_ok(struct device *dev) #define pm_domain_always_on_gov NULL #endif +static inline int pm_genpd_add_device(struct generic_pm_domain *genpd, + struct device *dev) +{ + return __pm_genpd_add_device(genpd, dev, NULL); +} + +static inline int pm_genpd_of_add_device(struct device_node *genpd_node, + struct device *dev) +{ + return __pm_genpd_of_add_device(genpd_node, dev, NULL); +} + +static inline int pm_genpd_name_add_device(const char *domain_name, + struct device *dev) +{ + return __pm_genpd_name_add_device(domain_name, dev, NULL); +} + static inline int pm_genpd_remove_callbacks(struct device *dev) { return __pm_genpd_remove_callbacks(dev, true); |