Skip to content

Commit 2489eeb

Browse files
Mani-Sadhasivamkwilczynski
authored andcommitted
PCI/pwrctrl: Skip scanning for the device further if pwrctrl device is created
The pwrctrl core will rescan the bus once the device is powered on. So there is no need to continue scanning for the device further. Reviewed-by: Bartosz Golaszewski <[email protected]> Tested-by: Bartosz Golaszewski <[email protected]> Signed-off-by: Manivannan Sadhasivam <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Krzysztof Wilczyński <[email protected]>
1 parent 2d92393 commit 2489eeb

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

drivers/pci/probe.c

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2495,19 +2495,15 @@ bool pci_bus_read_dev_vendor_id(struct pci_bus *bus, int devfn, u32 *l,
24952495
}
24962496
EXPORT_SYMBOL(pci_bus_read_dev_vendor_id);
24972497

2498-
/*
2499-
* Create pwrctrl device (if required) for the PCI device to handle the power
2500-
* state.
2501-
*/
2502-
static void pci_pwrctrl_create_device(struct pci_bus *bus, int devfn)
2498+
static struct platform_device *pci_pwrctrl_create_device(struct pci_bus *bus, int devfn)
25032499
{
25042500
struct pci_host_bridge *host = pci_find_host_bridge(bus);
25052501
struct platform_device *pdev;
25062502
struct device_node *np;
25072503

25082504
np = of_pci_find_child_device(dev_of_node(&bus->dev), devfn);
25092505
if (!np || of_find_device_by_node(np))
2510-
return;
2506+
return NULL;
25112507

25122508
/*
25132509
* First check whether the pwrctrl device really needs to be created or
@@ -2516,13 +2512,17 @@ static void pci_pwrctrl_create_device(struct pci_bus *bus, int devfn)
25162512
*/
25172513
if (!of_pci_supply_present(np)) {
25182514
pr_debug("PCI/pwrctrl: Skipping OF node: %s\n", np->name);
2519-
return;
2515+
return NULL;
25202516
}
25212517

25222518
/* Now create the pwrctrl device */
25232519
pdev = of_platform_device_create(np, NULL, &host->dev);
2524-
if (!pdev)
2525-
pr_err("PCI/pwrctrl: Failed to create pwrctrl device for OF node: %s\n", np->name);
2520+
if (!pdev) {
2521+
pr_err("PCI/pwrctrl: Failed to create pwrctrl device for node: %s\n", np->name);
2522+
return NULL;
2523+
}
2524+
2525+
return pdev;
25262526
}
25272527

25282528
/*
@@ -2534,7 +2534,14 @@ static struct pci_dev *pci_scan_device(struct pci_bus *bus, int devfn)
25342534
struct pci_dev *dev;
25352535
u32 l;
25362536

2537-
pci_pwrctrl_create_device(bus, devfn);
2537+
/*
2538+
* Create pwrctrl device (if required) for the PCI device to handle the
2539+
* power state. If the pwrctrl device is created, then skip scanning
2540+
* further as the pwrctrl core will rescan the bus after powering on
2541+
* the device.
2542+
*/
2543+
if (pci_pwrctrl_create_device(bus, devfn))
2544+
return NULL;
25382545

25392546
if (!pci_bus_read_dev_vendor_id(bus, devfn, &l, 60*1000))
25402547
return NULL;

0 commit comments

Comments
 (0)