diff options
author | Ulf Hansson <ulf.hansson@linaro.org> | 2018-06-29 07:04:32 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2018-07-09 06:11:02 -0400 |
commit | 27dceb81f445c58b1d10d27d26eaf4ac2e9e0b00 (patch) | |
tree | 9f66e6b98015b5ebf2e1939029907e3286861151 | |
parent | 5d6be70add65e3f236642ab0029e356261617cd0 (diff) |
PM / Domains: Introduce dev_pm_domain_attach_by_name()
For the multiple PM domain case, let's introduce a new API called
dev_pm_domain_attach_by_name(). This allows a consumer driver to associate
its device with one of its PM domains, by using a name based lookup.
Do note that, currently it's only genpd that supports multiple PM domains
per device, but dev_pm_domain_attach_by_name() can easily by extended to
cover other PM domain types, if/when needed.
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Tested-by: Rajendra Nayak <rnayak@codeaurora.org>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r-- | drivers/base/power/common.c | 17 | ||||
-rw-r--r-- | include/linux/pm_domain.h | 7 |
2 files changed, 24 insertions, 0 deletions
diff --git a/drivers/base/power/common.c b/drivers/base/power/common.c index df41b4780b3b..b413951c6abc 100644 --- a/drivers/base/power/common.c +++ b/drivers/base/power/common.c | |||
@@ -153,6 +153,23 @@ struct device *dev_pm_domain_attach_by_id(struct device *dev, | |||
153 | EXPORT_SYMBOL_GPL(dev_pm_domain_attach_by_id); | 153 | EXPORT_SYMBOL_GPL(dev_pm_domain_attach_by_id); |
154 | 154 | ||
155 | /** | 155 | /** |
156 | * dev_pm_domain_attach_by_name - Associate a device with one of its PM domains. | ||
157 | * @dev: The device used to lookup the PM domain. | ||
158 | * @name: The name of the PM domain. | ||
159 | * | ||
160 | * For a detailed function description, see dev_pm_domain_attach_by_id(). | ||
161 | */ | ||
162 | struct device *dev_pm_domain_attach_by_name(struct device *dev, | ||
163 | char *name) | ||
164 | { | ||
165 | if (dev->pm_domain) | ||
166 | return ERR_PTR(-EEXIST); | ||
167 | |||
168 | return genpd_dev_pm_attach_by_name(dev, name); | ||
169 | } | ||
170 | EXPORT_SYMBOL_GPL(dev_pm_domain_attach_by_name); | ||
171 | |||
172 | /** | ||
156 | * dev_pm_domain_detach - Detach a device from its PM domain. | 173 | * dev_pm_domain_detach - Detach a device from its PM domain. |
157 | * @dev: Device to detach. | 174 | * @dev: Device to detach. |
158 | * @power_off: Used to indicate whether we should power off the device. | 175 | * @power_off: Used to indicate whether we should power off the device. |
diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index 03e14a38462d..776c546d581a 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h | |||
@@ -309,6 +309,8 @@ struct generic_pm_domain *of_genpd_remove_last(struct device_node *np) | |||
309 | int dev_pm_domain_attach(struct device *dev, bool power_on); | 309 | int dev_pm_domain_attach(struct device *dev, bool power_on); |
310 | struct device *dev_pm_domain_attach_by_id(struct device *dev, | 310 | struct device *dev_pm_domain_attach_by_id(struct device *dev, |
311 | unsigned int index); | 311 | unsigned int index); |
312 | struct device *dev_pm_domain_attach_by_name(struct device *dev, | ||
313 | char *name); | ||
312 | void dev_pm_domain_detach(struct device *dev, bool power_off); | 314 | void dev_pm_domain_detach(struct device *dev, bool power_off); |
313 | void dev_pm_domain_set(struct device *dev, struct dev_pm_domain *pd); | 315 | void dev_pm_domain_set(struct device *dev, struct dev_pm_domain *pd); |
314 | #else | 316 | #else |
@@ -321,6 +323,11 @@ static inline struct device *dev_pm_domain_attach_by_id(struct device *dev, | |||
321 | { | 323 | { |
322 | return NULL; | 324 | return NULL; |
323 | } | 325 | } |
326 | static inline struct device *dev_pm_domain_attach_by_name(struct device *dev, | ||
327 | char *name) | ||
328 | { | ||
329 | return NULL; | ||
330 | } | ||
324 | static inline void dev_pm_domain_detach(struct device *dev, bool power_off) {} | 331 | static inline void dev_pm_domain_detach(struct device *dev, bool power_off) {} |
325 | static inline void dev_pm_domain_set(struct device *dev, | 332 | static inline void dev_pm_domain_set(struct device *dev, |
326 | struct dev_pm_domain *pd) {} | 333 | struct dev_pm_domain *pd) {} |