While adding devices to the generic PM domain we allocate data for the
struct generic_pm_domain_data.

Don't allow existing generic_pm_domain_data in this case, since that
indicates the device is already being added from another context. Let's
instead return an error.

Signed-off-by: Ulf Hansson <[email protected]>
---
 drivers/base/power/domain.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
index 7546242..9d511c7 100644
--- a/drivers/base/power/domain.c
+++ b/drivers/base/power/domain.c
@@ -1423,9 +1423,9 @@ int __pm_genpd_add_device(struct generic_pm_domain 
*genpd, struct device *dev,
 
        spin_lock_irq(&dev->power.lock);
 
-       dev->pm_domain = &genpd->domain;
        if (dev->power.subsys_data->domain_data) {
-               gpd_data = to_gpd_data(dev->power.subsys_data->domain_data);
+               ret = -EINVAL;
+               goto out;
        } else {
                gpd_data = gpd_data_new;
                dev->power.subsys_data->domain_data = &gpd_data->base;
@@ -1433,6 +1433,8 @@ int __pm_genpd_add_device(struct generic_pm_domain 
*genpd, struct device *dev,
        if (td)
                gpd_data->td = *td;
 
+       dev->pm_domain = &genpd->domain;
+
        spin_unlock_irq(&dev->power.lock);
 
        if (genpd->attach_dev)
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to