From: Bjorn Helgaas <bhelgaas@google.com>
Date: Mon, 25 Nov 2024 19:40:54 +0000 (-0600)
Subject: Merge branch 'pci/pwrctl'
X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=ce1deca962e3f67442dba834c8e1ba3629db6159;p=users%2Fjedix%2Flinux-maple.git

Merge branch 'pci/pwrctl'

- Use of_platform_device_create() instead of of_platform_populate() to
  create pwrctl platform devices so we can control it based on the child
  nodes (Manivannan Sadhasivam)

- Create pwrctrl platform devices only if there's a relevant power supply
  property (Manivannan Sadhasivam)

- Add device link from the pwrctl supplier to the PCI dev to ensure pwrctl
  drivers are probed before the PCI dev driver; this avoids a race where
  pwrctl could change device power state while the PCI driver was active
  (Manivannan Sadhasivam)

- Find pwrctl device for removal with of_find_device_by_node() instead of
  searching all children of the parent (Manivannan Sadhasivam)

- Rename 'pwrctl' to 'pwrctrl' to use the same 'ctrl' suffix as 'bwctrl'
  and other PCI files to reduce confusion (Bjorn Helgaas)

* pci/pwrctl:
  PCI/pwrctrl: Rename pwrctrl functions and structures
  PCI/pwrctrl: Rename pwrctl files to pwrctrl
  PCI/pwrctl: Remove pwrctl device without iterating over all children of pwrctl parent
  PCI/pwrctl: Ensure that pwrctl drivers are probed before PCI client drivers
  PCI/pwrctl: Create pwrctl device only if at least one power supply is present
  PCI/pwrctl: Use of_platform_device_create() to create pwrctl devices

# Conflicts:
#	drivers/pci/bus.c
#	drivers/pci/remove.c
---

ce1deca962e3f67442dba834c8e1ba3629db6159
diff --cc drivers/pci/bus.c
index d015d5821cef,0d27809746df..98910bc0fcc4
--- a/drivers/pci/bus.c
+++ b/drivers/pci/bus.c
@@@ -358,15 -407,7 +417,7 @@@ void pci_bus_add_device(struct pci_dev 
  	if (retval < 0 && retval != -EPROBE_DEFER)
  		pci_warn(dev, "device attach failed (%d)\n", retval);
  
 -	pci_dev_assign_added(dev, true);
 +	pci_dev_assign_added(dev);
- 
- 	if (dev_of_node(&dev->dev) && pci_is_bridge(dev)) {
- 		retval = of_platform_populate(dev_of_node(&dev->dev), NULL, NULL,
- 					      &dev->dev);
- 		if (retval)
- 			pci_err(dev, "failed to populate child OF nodes (%d)\n",
- 				retval);
- 	}
  }
  EXPORT_SYMBOL_GPL(pci_bus_add_device);
  
diff --cc drivers/pci/remove.c
index 1f35945459fd,27ef371a8443..963b8d2855c1
--- a/drivers/pci/remove.c
+++ b/drivers/pci/remove.c
@@@ -33,15 -33,15 +33,14 @@@ static void pci_stop_dev(struct pci_de
  {
  	pci_pme_active(dev, false);
  
 -	if (pci_dev_is_added(dev)) {
 -		pci_pwrctrl_unregister(&dev->dev);
 -		device_release_driver(&dev->dev);
 -		pci_proc_detach_device(dev);
 -		pci_remove_sysfs_dev_files(dev);
 -		of_pci_remove_node(dev);
 +	if (!pci_dev_test_and_clear_added(dev))
 +		return;
  
- 	device_for_each_child(dev->dev.parent, dev_of_node(&dev->dev),
- 			      pci_pwrctl_unregister);
 -		pci_dev_assign_added(dev, false);
 -	}
++	pci_pwrctrl_unregister(&dev->dev);
 +	device_release_driver(&dev->dev);
 +	pci_proc_detach_device(dev);
 +	pci_remove_sysfs_dev_files(dev);
 +	of_pci_remove_node(dev);
  }
  
  static void pci_destroy_dev(struct pci_dev *dev)