All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH -next v2 0/2] of: introduce of_address_count() helper
@ 2022-10-08 11:56 Yang Yingliang
  2022-10-08 11:56 ` [PATCH -next v2 1/2] of/address: " Yang Yingliang
  2022-10-08 11:56 ` [PATCH -next v2 2/2] of/platform: use " Yang Yingliang
  0 siblings, 2 replies; 5+ messages in thread
From: Yang Yingliang @ 2022-10-08 11:56 UTC (permalink / raw)
  To: devicetree; +Cc: robh+dt, frowand.list, yangyingliang

Introduce of_address_count() helper to count the IO resources, so
some drivers can use it instead of open-coding.

E.g. irq-orion and tegra194-cbb.

v1 -> v2:
  patch #1, make of_address_count() inline in of_address.h

Yang Yingliang (2):
  of/address: introduce of_address_count() helper
  of/platform: use of_address_count() helper

 drivers/of/platform.c      |  5 ++---
 include/linux/of_address.h | 11 +++++++++++
 2 files changed, 13 insertions(+), 3 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH -next v2 1/2] of/address: introduce of_address_count() helper
  2022-10-08 11:56 [PATCH -next v2 0/2] of: introduce of_address_count() helper Yang Yingliang
@ 2022-10-08 11:56 ` Yang Yingliang
  2022-10-14 21:10   ` Rob Herring
  2022-10-08 11:56 ` [PATCH -next v2 2/2] of/platform: use " Yang Yingliang
  1 sibling, 1 reply; 5+ messages in thread
From: Yang Yingliang @ 2022-10-08 11:56 UTC (permalink / raw)
  To: devicetree; +Cc: robh+dt, frowand.list, yangyingliang

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(+)

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 */
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH -next v2 2/2] of/platform: use of_address_count() helper
  2022-10-08 11:56 [PATCH -next v2 0/2] of: introduce of_address_count() helper Yang Yingliang
  2022-10-08 11:56 ` [PATCH -next v2 1/2] of/address: " Yang Yingliang
@ 2022-10-08 11:56 ` Yang Yingliang
  2022-10-14 21:10   ` Rob Herring
  1 sibling, 1 reply; 5+ messages in thread
From: Yang Yingliang @ 2022-10-08 11:56 UTC (permalink / raw)
  To: devicetree; +Cc: robh+dt, frowand.list, yangyingliang

Use of_address_count() to instead of open-coding it.

Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
 drivers/of/platform.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index 3507095a69f6..81c8c227ab6b 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -115,15 +115,14 @@ struct platform_device *of_device_alloc(struct device_node *np,
 {
 	struct platform_device *dev;
 	int rc, i, num_reg = 0;
-	struct resource *res, temp_res;
+	struct resource *res;
 
 	dev = platform_device_alloc("", PLATFORM_DEVID_NONE);
 	if (!dev)
 		return NULL;
 
 	/* count the io resources */
-	while (of_address_to_resource(np, num_reg, &temp_res) == 0)
-		num_reg++;
+	num_reg = of_address_count(np);
 
 	/* Populate the resource table */
 	if (num_reg) {
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH -next v2 1/2] of/address: introduce of_address_count() helper
  2022-10-08 11:56 ` [PATCH -next v2 1/2] of/address: " Yang Yingliang
@ 2022-10-14 21:10   ` Rob Herring
  0 siblings, 0 replies; 5+ messages in thread
From: Rob Herring @ 2022-10-14 21:10 UTC (permalink / raw)
  To: Yang Yingliang; +Cc: devicetree, robh+dt, frowand.list

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!

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH -next v2 2/2] of/platform: use of_address_count() helper
  2022-10-08 11:56 ` [PATCH -next v2 2/2] of/platform: use " Yang Yingliang
@ 2022-10-14 21:10   ` Rob Herring
  0 siblings, 0 replies; 5+ messages in thread
From: Rob Herring @ 2022-10-14 21:10 UTC (permalink / raw)
  To: Yang Yingliang; +Cc: robh+dt, frowand.list, devicetree

On Sat, 08 Oct 2022 19:56:17 +0800, Yang Yingliang wrote:
> Use of_address_count() to instead of open-coding it.
> 
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
> ---
>  drivers/of/platform.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 

Applied, thanks!

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-10-14 21:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-08 11:56 [PATCH -next v2 0/2] of: introduce of_address_count() helper Yang Yingliang
2022-10-08 11:56 ` [PATCH -next v2 1/2] of/address: " Yang Yingliang
2022-10-14 21:10   ` Rob Herring
2022-10-08 11:56 ` [PATCH -next v2 2/2] of/platform: use " Yang Yingliang
2022-10-14 21:10   ` Rob Herring

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.