diff mbox series

[-next,v2,1/2] of/address: introduce of_address_count() helper

Message ID 20221008115617.3583890-2-yangyingliang@huawei.com
State Accepted, archived
Headers show
Series of: introduce of_address_count() helper | expand

Checks

Context Check Description
robh/checkpatch success
robh/patch-applied fail build log

Commit Message

Yang Yingliang Oct. 8, 2022, 11:56 a.m. UTC
Introduce of_address_count() helper to count the IO resources
instead of open-coding it.

Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
 include/linux/of_address.h | 11 +++++++++++
 1 file changed, 11 insertions(+)

Comments

Rob Herring Oct. 14, 2022, 9:10 p.m. UTC | #1
On Sat, 08 Oct 2022 19:56:16 +0800, Yang Yingliang wrote:
> Introduce of_address_count() helper to count the IO resources
> instead of open-coding it.
> 
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
> ---
>  include/linux/of_address.h | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 

Applied, thanks!
diff mbox series

Patch

diff --git a/include/linux/of_address.h b/include/linux/of_address.h
index 45598dbec269..265f26eeaf6b 100644
--- a/include/linux/of_address.h
+++ b/include/linux/of_address.h
@@ -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);
 }
 
+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 */