[PATCH 3/4] PCI: of: make a flags argument optional

From: Alex Elder

Date: Fri Aug 07 2026 - 15:42:10 EST


The address of a u32 object is passed to of_pci_get_addr_flags() so
it can be filled with the computed flags value.

Allow a null pointer to be passed, so that the validity of the
resource's flags can be checked without filling in the flags value.

Signed-off-by: Alex Elder <elder@xxxxxxxxxxxx>
---
drivers/pci/of_property.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/pci/of_property.c b/drivers/pci/of_property.c
index 22fea1905a080..5e1820b8bb79b 100644
--- a/drivers/pci/of_property.c
+++ b/drivers/pci/of_property.c
@@ -82,9 +82,11 @@ static int of_pci_get_addr_flags(const struct resource *res, u32 *flags)
else
return -EINVAL;

- *flags = FIELD_PREP(OF_PCI_ADDR_FIELD_SS, ss);
- if (res->flags & IORESOURCE_PREFETCH)
- *flags |= OF_PCI_ADDR_FIELD_PREFETCH;
+ if (flags) {
+ *flags = FIELD_PREP(OF_PCI_ADDR_FIELD_SS, ss);
+ if (res->flags & IORESOURCE_PREFETCH)
+ *flags |= OF_PCI_ADDR_FIELD_PREFETCH;
+ }

return 0;
}
--
2.53.0