Skip to content

Commit 14b5306

Browse files
storulfrafaeljw
authored andcommitted
PM / Domains: Don't allow an existing generic_pm_domain_data
When adding a device to a genpd, a struct generic_pm_domain_data is allocated per device. Verify that there are no existing generic_pm_domain_data for the device we are about to add, since that tells us it has already been added to a genpd. When genpd supported PM domain device callbacks, this was a valid scenario. Now it isn't so let's return an error code. Signed-off-by: Ulf Hansson <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent c1dbe2f commit 14b5306

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

drivers/base/power/domain.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1444,26 +1444,30 @@ int __pm_genpd_add_device(struct generic_pm_domain *genpd, struct device *dev,
14441444
if (ret)
14451445
goto out;
14461446

1447-
genpd->device_count++;
1448-
genpd->max_off_time_changed = true;
1449-
14501447
spin_lock_irq(&dev->power.lock);
14511448

1452-
dev->pm_domain = &genpd->domain;
14531449
if (dev->power.subsys_data->domain_data) {
1454-
gpd_data = to_gpd_data(dev->power.subsys_data->domain_data);
1455-
} else {
1456-
gpd_data = gpd_data_new;
1457-
dev->power.subsys_data->domain_data = &gpd_data->base;
1450+
spin_unlock_irq(&dev->power.lock);
1451+
ret = -EINVAL;
1452+
goto out;
14581453
}
1454+
1455+
gpd_data = gpd_data_new;
1456+
dev->power.subsys_data->domain_data = &gpd_data->base;
1457+
14591458
if (td)
14601459
gpd_data->td = *td;
14611460

1461+
dev->pm_domain = &genpd->domain;
1462+
14621463
spin_unlock_irq(&dev->power.lock);
14631464

14641465
if (genpd->attach_dev)
14651466
genpd->attach_dev(genpd, dev);
14661467

1468+
genpd->device_count++;
1469+
genpd->max_off_time_changed = true;
1470+
14671471
mutex_lock(&gpd_data->lock);
14681472
gpd_data->base.dev = dev;
14691473
list_add_tail(&gpd_data->base.list_node, &genpd->dev_list);

0 commit comments

Comments
 (0)