PM / Domains: add setter for dev.pm_domain
Adds a function that sets the pointer to dev_pm_domain in struct device and that warns if the device has already finished probing. The reason why we want to enforce that is because in the general case that can cause problems and also that we can simplify code quite a bit if we can always assume that. This patch also changes all current code that directly sets the dev.pm_domain pointer. Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com> Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
This commit is contained in:

committed by
Rafael J. Wysocki

parent
6b9cb42752
commit
989561de9b
@@ -128,3 +128,24 @@ void dev_pm_domain_detach(struct device *dev, bool power_off)
|
||||
dev->pm_domain->detach(dev, power_off);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(dev_pm_domain_detach);
|
||||
|
||||
/**
|
||||
* dev_pm_domain_set - Set PM domain of a device.
|
||||
* @dev: Device whose PM domain is to be set.
|
||||
* @pd: PM domain to be set, or NULL.
|
||||
*
|
||||
* Sets the PM domain the device belongs to. The PM domain of a device needs
|
||||
* to be set before its probe finishes (it's bound to a driver).
|
||||
*
|
||||
* This function must be called with the device lock held.
|
||||
*/
|
||||
void dev_pm_domain_set(struct device *dev, struct dev_pm_domain *pd)
|
||||
{
|
||||
if (dev->pm_domain == pd)
|
||||
return;
|
||||
|
||||
WARN(device_is_bound(dev),
|
||||
"PM domains can only be changed for unbound devices\n");
|
||||
dev->pm_domain = pd;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(dev_pm_domain_set);
|
||||
|
Reference in New Issue
Block a user