Commit 16988c74 authored by Yang Yingliang's avatar Yang Yingliang Committed by Rob Herring

of/address: introduce of_address_count() helper

Introduce of_address_count() helper to count the IO resources
instead of open-coding it.
Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
Link: https://lore.kernel.org/r/20221008115617.3583890-2-yangyingliang@huawei.comSigned-off-by: default avatarRob Herring <robh@kernel.org>
parent 9abf2313
...@@ -154,4 +154,15 @@ static inline const __be32 *of_get_pci_address(struct device_node *dev, int bar_ ...@@ -154,4 +154,15 @@ static inline const __be32 *of_get_pci_address(struct device_node *dev, int bar_
return __of_get_address(dev, -1, bar_no, size, flags); return __of_get_address(dev, -1, bar_no, size, flags);
} }
static inline int of_address_count(struct device_node *np)
{
struct resource res;
int count = 0;
while (of_address_to_resource(np, count, &res) == 0)
count++;
return count;
}
#endif /* __OF_ADDRESS_H */ #endif /* __OF_ADDRESS_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment