If a call to dev_pm_domain_attach() succeeds to attach a device to its single PM domain, the important point is to prevent subsequent dev_pm_domain_attach_by_name|id() calls from failing. That is done by checking the dev->pm_domain pointer and then returning -EEXIST, rather than continuing to call genpd_dev_pm_attach_by_id|name(). For this reason, enable genpd_dev_pm_attach_by_id|name() to be used for single PM domains too. This simplifies future users, so they only need to use dev_pm_domain_attach_by_id|name() instead of having to combine it with dev_pm_domain_attach().
Unified · Split
| @@ -2439,10 +2439,10 @@ struct device *genpd_dev_pm_attach_by_id(struct device *dev, · 2438 unmodified lines | ||
| 2439 | 2439 | if (!dev->of_node) |
| 2440 | 2440 | return NULL; |
| 2441 | 2441 | |
| 2442 | − /* Deal only with devices using multiple PM domains. */ | |
| 2442 | + /* Verify that the index is within a valid range. */ | |
| 2443 | 2443 | num_domains = of_count_phandle_with_args(dev->of_node, "power-domains", |
| 2444 | 2444 | "#power-domain-cells"); |
| 2445 | − if (num_domains < 2 || index >= num_domains) | |
| 2445 | + if (index >= num_domains) | |
| 2446 | 2446 | return NULL; |
| 2447 | 2447 | |
| 2448 | 2448 | /* Allocate and register device on the genpd bus. */ |