of/address: Rework bus matching to avoid warnings
authorRob Herring (Arm) <robh@kernel.org>
Fri, 8 Nov 2024 19:35:48 +0000 (13:35 -0600)
committerRob Herring (Arm) <robh@kernel.org>
Fri, 8 Nov 2024 19:41:34 +0000 (13:41 -0600)
commit64ee3cf096ac590e7da2ceac1c390546bff5e240
tree7fc7d0e01ecbc3785afe952bed49f46f95ecce37
parent045b14ca5c3657dc6c16afa97a00dba17286d3e8
of/address: Rework bus matching to avoid warnings

With warnings added for deprecated #address-cells/#size-cells handling,
the DT address handling code causes warnings when used on nodes with no
address. This happens frequently with calls to of_platform_populate() as
it is perfectly acceptable to have devices without a 'reg' property. The
desired behavior is to just silently return an error when retrieving an
address.

The warnings can be avoided by checking for "#address-cells" presence
first and checking for an address property before fetching
"#address-cells" and "#size-cells".

Reported-by: Marek Szyprowski <m.szyprowski@samsung.com>
Reported-by: Steven Price <steven.price@arm.com>
Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
Link: https://lore.kernel.org/r/20241108193547.2647986-2-robh@kernel.org
Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
drivers/of/address.c