@@ -2495,19 +2495,15 @@ bool pci_bus_read_dev_vendor_id(struct pci_bus *bus, int devfn, u32 *l,
2495
2495
}
2496
2496
EXPORT_SYMBOL (pci_bus_read_dev_vendor_id );
2497
2497
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 )
2503
2499
{
2504
2500
struct pci_host_bridge * host = pci_find_host_bridge (bus );
2505
2501
struct platform_device * pdev ;
2506
2502
struct device_node * np ;
2507
2503
2508
2504
np = of_pci_find_child_device (dev_of_node (& bus -> dev ), devfn );
2509
2505
if (!np || of_find_device_by_node (np ))
2510
- return ;
2506
+ return NULL ;
2511
2507
2512
2508
/*
2513
2509
* 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)
2516
2512
*/
2517
2513
if (!of_pci_supply_present (np )) {
2518
2514
pr_debug ("PCI/pwrctrl: Skipping OF node: %s\n" , np -> name );
2519
- return ;
2515
+ return NULL ;
2520
2516
}
2521
2517
2522
2518
/* Now create the pwrctrl device */
2523
2519
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 ;
2526
2526
}
2527
2527
2528
2528
/*
@@ -2534,7 +2534,14 @@ static struct pci_dev *pci_scan_device(struct pci_bus *bus, int devfn)
2534
2534
struct pci_dev * dev ;
2535
2535
u32 l ;
2536
2536
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 ;
2538
2545
2539
2546
if (!pci_bus_read_dev_vendor_id (bus , devfn , & l , 60 * 1000 ))
2540
2547
return NULL ;
0 commit comments