Skip to content

Commit c5785a1

Browse files
hcodinabjorn-helgaas
authored andcommitted
PCI: of_property: Add support for NULL pdev in of_pci_set_address()
The pdev (pointer to a struct pci_dev) parameter of of_pci_set_address() cannot be NULL. In order to use of_pci_set_address() when creating the PCI root bus node, it needs to support a NULL pdev parameter. Indeed, in the case of the PCI root bus node creation, no pdev is available and of_pci_set_address() will be used with the bridge windows. Allow to call of_pci_set_address() with a NULL pdev. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Herve Codina <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]> Reviewed-by: Rob Herring (Arm) <[email protected]>
1 parent e226784 commit c5785a1

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

drivers/pci/of_property.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,13 @@ enum of_pci_prop_compatible {
5454
static void of_pci_set_address(struct pci_dev *pdev, u32 *prop, u64 addr,
5555
u32 reg_num, u32 flags, bool reloc)
5656
{
57-
prop[0] = FIELD_PREP(OF_PCI_ADDR_FIELD_BUS, pdev->bus->number) |
58-
FIELD_PREP(OF_PCI_ADDR_FIELD_DEV, PCI_SLOT(pdev->devfn)) |
59-
FIELD_PREP(OF_PCI_ADDR_FIELD_FUNC, PCI_FUNC(pdev->devfn));
57+
if (pdev) {
58+
prop[0] = FIELD_PREP(OF_PCI_ADDR_FIELD_BUS, pdev->bus->number) |
59+
FIELD_PREP(OF_PCI_ADDR_FIELD_DEV, PCI_SLOT(pdev->devfn)) |
60+
FIELD_PREP(OF_PCI_ADDR_FIELD_FUNC, PCI_FUNC(pdev->devfn));
61+
} else
62+
prop[0] = 0;
63+
6064
prop[0] |= flags | reg_num;
6165
if (!reloc) {
6266
prop[0] |= OF_PCI_ADDR_FIELD_NONRELOC;

0 commit comments

Comments
 (0)