History

PM / Domains: Allow OF lookup for multi PM domain case from ->attach_dev()

A genpd provider that uses the ->attach_dev() callback to look up resources for a device fails to do so when the device has multiple PM domains attached. That is because when genpd invokes the ->attach_dev() callback, it passes the allocated virtual device as the in-parameter. To address this problem, simply assign the dev->of_node for the virtual device, based upon the original device's OF node.

Ulf Hansson committed 7 years ago

Commit e8b04de1 parent 71b77691 file · +7 −5Browse files

Unified · Split

drivers/base/power/domain.c+7−5
@@ -2272,6 +2272,7 @@ EXPORT_SYMBOL_GPL(of_genpd_remove_last); · 2271 unmodified lines
22722272
22732273 static void genpd_release_dev(struct device *dev)
22742274 {
2275+ of_node_put(dev->of_node);
22752276 kfree(dev);
22762277 }
22772278
@@ -2333,14 +2334,14 @@ static void genpd_dev_pm_sync(struct device *dev) · 55 unmodified lines
23332334 genpd_queue_power_off_work(pd);
23342335 }
23352336
2336−static int __genpd_dev_pm_attach(struct device *dev, struct device_node *np,
2337− unsigned int index, bool power_on)
2337+static int __genpd_dev_pm_attach(struct device *dev, unsigned int index,
2338+ bool power_on)
23382339 {
23392340 struct of_phandle_args pd_args;
23402341 struct generic_pm_domain *pd;
23412342 int ret;
23422343
2343− ret = of_parse_phandle_with_args(np, "power-domains",
2344+ ret = of_parse_phandle_with_args(dev->of_node, "power-domains",
23442345 "#power-domain-cells", index, &pd_args);
23452346 if (ret < 0)
23462347 return ret;
@@ -2408,7 +2409,7 @@ int genpd_dev_pm_attach(struct device *dev) · 61 unmodified lines
24082409 "#power-domain-cells") != 1)
24092410 return 0;
24102411
2411− return __genpd_dev_pm_attach(dev, dev->of_node, 0, true);
2412+ return __genpd_dev_pm_attach(dev, 0, true);
24122413 }
24132414 EXPORT_SYMBOL_GPL(genpd_dev_pm_attach);
24142415
@@ -2452,6 +2453,7 @@ struct device *genpd_dev_pm_attach_by_id(struct device *dev, · 37 unmodified lines
24522453 dev_set_name(virt_dev, "genpd:%u:%s", index, dev_name(dev));
24532454 virt_dev->bus = &genpd_bus_type;
24542455 virt_dev->release = genpd_release_dev;
2456+ virt_dev->of_node = of_node_get(dev->of_node);
24552457
24562458 ret = device_register(virt_dev);
24572459 if (ret) {
@@ -2460,7 +2462,7 @@ struct device *genpd_dev_pm_attach_by_id(struct device *dev, · 2 unmodified lines
24602462 }
24612463
24622464 /* Try to attach the device to the PM domain at the specified index. */
2463− ret = __genpd_dev_pm_attach(virt_dev, dev->of_node, index, false);
2465+ ret = __genpd_dev_pm_attach(virt_dev, index, false);
24642466 if (ret < 1) {
24652467 device_unregister(virt_dev);
24662468 return ret ? ERR_PTR(ret) : NULL;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t