mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-31 04:01:48 -04:00
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 <[email protected]> Reviewed-by: Ulf Hansson <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
This commit is contained in:
parent
6b9cb42752
commit
989561de9b
10 changed files with 54 additions and 19 deletions
|
|
@ -15,6 +15,7 @@
|
|||
#include <linux/clkdev.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/pm_domain.h>
|
||||
#include <linux/pm_runtime.h>
|
||||
|
||||
#ifdef CONFIG_PM_CLK
|
||||
|
|
@ -348,7 +349,7 @@ static int pm_clk_notify(struct notifier_block *nb,
|
|||
if (error)
|
||||
break;
|
||||
|
||||
dev->pm_domain = clknb->pm_domain;
|
||||
dev_pm_domain_set(dev, clknb->pm_domain);
|
||||
if (clknb->con_ids[0]) {
|
||||
for (con_id = clknb->con_ids; *con_id; con_id++)
|
||||
pm_clk_add(dev, *con_id);
|
||||
|
|
@ -361,7 +362,7 @@ static int pm_clk_notify(struct notifier_block *nb,
|
|||
if (dev->pm_domain != clknb->pm_domain)
|
||||
break;
|
||||
|
||||
dev->pm_domain = NULL;
|
||||
dev_pm_domain_set(dev, NULL);
|
||||
pm_clk_destroy(dev);
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -1177,10 +1177,11 @@ static struct generic_pm_domain_data *genpd_alloc_dev_data(struct device *dev,
|
|||
}
|
||||
|
||||
dev->power.subsys_data->domain_data = &gpd_data->base;
|
||||
dev->pm_domain = &genpd->domain;
|
||||
|
||||
spin_unlock_irq(&dev->power.lock);
|
||||
|
||||
dev_pm_domain_set(dev, &genpd->domain);
|
||||
|
||||
return gpd_data;
|
||||
|
||||
err_free:
|
||||
|
|
@ -1194,9 +1195,10 @@ static struct generic_pm_domain_data *genpd_alloc_dev_data(struct device *dev,
|
|||
static void genpd_free_dev_data(struct device *dev,
|
||||
struct generic_pm_domain_data *gpd_data)
|
||||
{
|
||||
dev_pm_domain_set(dev, NULL);
|
||||
|
||||
spin_lock_irq(&dev->power.lock);
|
||||
|
||||
dev->pm_domain = NULL;
|
||||
dev->power.subsys_data->domain_data = NULL;
|
||||
|
||||
spin_unlock_irq(&dev->power.lock);
|
||||
|
|
|
|||
Loading…
Reference in a new issue