Skip to content

Commit ee22665

Browse files
Mani-Sadhasivambjorn-helgaas
authored andcommitted
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: 4c41324 ("PCI/pwrctrl: Add APIs to create, destroy pwrctrl devices") Reported-by: Bjorn Andersson <[email protected]> Closes: https://lore.kernel.org/all/[email protected] Signed-off-by: Manivannan Sadhasivam <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]> Link: https://patch.msgid.link/[email protected]
1 parent cf3287f commit ee22665

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

drivers/pci/pwrctrl/core.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,16 +272,23 @@ EXPORT_SYMBOL_GPL(pci_pwrctrl_power_on_devices);
272272
* Check whether the pwrctrl device really needs to be created or not. The
273273
* pwrctrl device will only be created if the node satisfies below requirements:
274274
*
275-
* 1. Presence of compatible property to match against the pwrctrl driver (AND)
275+
* 1. Presence of compatible property with "pci" prefix to match against the
276+
* pwrctrl driver (AND)
276277
* 2. At least one of the power supplies defined in the devicetree node of the
277278
* device (OR) in the remote endpoint parent node to indicate pwrctrl
278279
* requirement.
279280
*/
280281
static bool pci_pwrctrl_is_required(struct device_node *np)
281282
{
282283
struct device_node *endpoint;
284+
const char *compat;
285+
int ret;
286+
287+
ret = of_property_read_string(np, "compatible", &compat);
288+
if (ret < 0)
289+
return false;
283290

284-
if (!of_property_present(np, "compatible"))
291+
if (!strstarts(compat, "pci"))
285292
return false;
286293

287294
if (of_pci_supply_present(np))

0 commit comments

Comments
 (0)