Skip to content

Commit 681725a

Browse files
Mani-Sadhasivamkwilczynski
authored andcommitted
PCI/pwrctl: Remove pwrctl device without iterating over all children of pwrctl parent
There is no need to iterate over all children of the pwrctl device parent to remove the pwrctl device. Since the pwrctl device associated with the PCI device can be found using of_find_device_by_node() API, use it directly instead. Any pwrctl devices lying around without getting associated with the PCI devices will be removed once their parent device gets removed. Link: https://lore.kernel.org/r/[email protected] Tested-by: Bartosz Golaszewski <[email protected]> Tested-by: Krishna chaitanya chundru <[email protected]> Signed-off-by: Manivannan Sadhasivam <[email protected]> [bhelgaas: commit log] Signed-off-by: Bjorn Helgaas <[email protected]> Signed-off-by: Krzysztof Wilczyński <[email protected]> Reviewed-by: Bartosz Golaszewski <[email protected]>
1 parent b458ff7 commit 681725a

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

drivers/pci/remove.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,24 @@ static void pci_free_resources(struct pci_dev *dev)
1717
}
1818
}
1919

20-
static int pci_pwrctl_unregister(struct device *dev, void *data)
20+
static void pci_pwrctl_unregister(struct device *dev)
2121
{
22-
struct device_node *pci_node = data, *plat_node = dev_of_node(dev);
22+
struct platform_device *pdev;
2323

24-
if (dev_is_platform(dev) && plat_node && plat_node == pci_node) {
25-
of_device_unregister(to_platform_device(dev));
26-
of_node_clear_flag(plat_node, OF_POPULATED);
27-
}
24+
pdev = of_find_device_by_node(dev_of_node(dev));
25+
if (!pdev)
26+
return;
2827

29-
return 0;
28+
of_device_unregister(pdev);
29+
of_node_clear_flag(dev_of_node(dev), OF_POPULATED);
3030
}
3131

3232
static void pci_stop_dev(struct pci_dev *dev)
3333
{
3434
pci_pme_active(dev, false);
3535

3636
if (pci_dev_is_added(dev)) {
37-
device_for_each_child(dev->dev.parent, dev_of_node(&dev->dev),
38-
pci_pwrctl_unregister);
37+
pci_pwrctl_unregister(&dev->dev);
3938
device_release_driver(&dev->dev);
4039
pci_proc_detach_device(dev);
4140
pci_remove_sysfs_dev_files(dev);

0 commit comments

Comments
 (0)