Commit ee226656 authored by Manivannan Sadhasivam's avatar Manivannan Sadhasivam Committed by Bjorn Helgaas
Browse files

PCI/pwrctrl: Create pwrctrl devices only for PCI device nodes



A PCI host bridge node can have non-PCI child nodes (OPP tables, USB
hub, etc.) as well as PCI device child nodes.

Ensure that pwrctrl devices are only created for PCI device nodes by
checking for the 'pci' prefix in the compatible property.

Fixes: 4c413248 ("PCI/pwrctrl: Add APIs to create, destroy pwrctrl devices")
Reported-by: default avatarBjorn Andersson <bjorn.andersson@oss.qualcomm.com>
Closes: https://lore.kernel.org/all/20260212-rb3gen2-upd-gl3590-v1-1-18fb04bb32b0@oss.qualcomm.com


Signed-off-by: default avatarManivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
Link: https://patch.msgid.link/20260223-pwrctrl-fixes-7-0-v2-2-97566dfb1809@oss.qualcomm.com
parent cf3287fb
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -272,7 +272,8 @@ EXPORT_SYMBOL_GPL(pci_pwrctrl_power_on_devices);
 * Check whether the pwrctrl device really needs to be created or not. The
 * pwrctrl device will only be created if the node satisfies below requirements:
 *
 * 1. Presence of compatible property to match against the pwrctrl driver (AND)
 * 1. Presence of compatible property with "pci" prefix to match against the
 *    pwrctrl driver (AND)
 * 2. At least one of the power supplies defined in the devicetree node of the
 *    device (OR) in the remote endpoint parent node to indicate pwrctrl
 *    requirement.
@@ -280,8 +281,14 @@ EXPORT_SYMBOL_GPL(pci_pwrctrl_power_on_devices);
static bool pci_pwrctrl_is_required(struct device_node *np)
{
	struct device_node *endpoint;
	const char *compat;
	int ret;

	ret = of_property_read_string(np, "compatible", &compat);
	if (ret < 0)
		return false;

	if (!of_property_present(np, "compatible"))
	if (!strstarts(compat, "pci"))
		return false;

	if (of_pci_supply_present(np))