All of lore.kernel.org
 help / color / mirror / Atom feed
From: Grant Likely <grant.likely@secretlab.ca>
To: Nicolas Pitre <nicolas.pitre@linaro.org>,
	Russell King <linux@arm.linux.org.uk>,
	Arnd Bergmann <arnd@arndb.de>,
	devicetree-discuss@lists.ozlabs.org,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org
Subject: [RFC PATCH 02/11] of/address: Add of_find_matching_node_by_address helper
Date: Wed, 15 Jun 2011 22:41:36 -0600	[thread overview]
Message-ID: <20110616044130.29371.31242.stgit@ponder> (raw)
In-Reply-To: <20110616042653.29371.2052.stgit@ponder>

of_find_matching_node_by_address() can be used to find a device tree
node for a device at a specific address.

Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
---
 drivers/of/address.c       |   18 ++++++++++++++++++
 include/linux/of_address.h |    4 ++++
 2 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/drivers/of/address.c b/drivers/of/address.c
index b4559c5..da1f4b9 100644
--- a/drivers/of/address.c
+++ b/drivers/of/address.c
@@ -577,6 +577,24 @@ int of_address_to_resource(struct device_node *dev, int index,
 }
 EXPORT_SYMBOL_GPL(of_address_to_resource);
 
+struct device_node *of_find_matching_node_by_address(struct device_node *from,
+					const struct of_device_id *matches,
+					u64 base_address)
+{
+	struct device_node *dn = of_find_matching_node(from, matches);
+	struct resource res;
+
+	while (dn) {
+		if (of_address_to_resource(dn, 0, &res))
+			continue;
+		if (res.start == base_address)
+			return dn;
+		dn = of_find_matching_node(dn, matches);
+	}
+
+	return NULL;
+}
+
 
 /**
  * of_iomap - Maps the memory mapped IO for a given device_node
diff --git a/include/linux/of_address.h b/include/linux/of_address.h
index 2feda6e..bdfc20d 100644
--- a/include/linux/of_address.h
+++ b/include/linux/of_address.h
@@ -6,6 +6,10 @@
 extern u64 of_translate_address(struct device_node *np, const __be32 *addr);
 extern int of_address_to_resource(struct device_node *dev, int index,
 				  struct resource *r);
+extern struct device_node *of_find_matching_node_by_address(
+					struct device_node *from,
+					const struct of_device_id *matches,
+					u64 base_address);
 extern void __iomem *of_iomap(struct device_node *device, int index);
 
 /* Extract an address from a device, returns the region size and


WARNING: multiple messages have this Message-ID (diff)
From: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
To: Nicolas Pitre
	<nicolas.pitre-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
	Russell King <linux-lFZ/pmaqli7XmaaqVzeoHQ@public.gmane.org>,
	Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org>,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.orglinu
Subject: [RFC PATCH 02/11] of/address: Add of_find_matching_node_by_address helper
Date: Wed, 15 Jun 2011 22:41:36 -0600	[thread overview]
Message-ID: <20110616044130.29371.31242.stgit@ponder> (raw)
In-Reply-To: <20110616042653.29371.2052.stgit@ponder>

of_find_matching_node_by_address() can be used to find a device tree
node for a device at a specific address.

Signed-off-by: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
---
 drivers/of/address.c       |   18 ++++++++++++++++++
 include/linux/of_address.h |    4 ++++
 2 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/drivers/of/address.c b/drivers/of/address.c
index b4559c5..da1f4b9 100644
--- a/drivers/of/address.c
+++ b/drivers/of/address.c
@@ -577,6 +577,24 @@ int of_address_to_resource(struct device_node *dev, int index,
 }
 EXPORT_SYMBOL_GPL(of_address_to_resource);
 
+struct device_node *of_find_matching_node_by_address(struct device_node *from,
+					const struct of_device_id *matches,
+					u64 base_address)
+{
+	struct device_node *dn = of_find_matching_node(from, matches);
+	struct resource res;
+
+	while (dn) {
+		if (of_address_to_resource(dn, 0, &res))
+			continue;
+		if (res.start == base_address)
+			return dn;
+		dn = of_find_matching_node(dn, matches);
+	}
+
+	return NULL;
+}
+
 
 /**
  * of_iomap - Maps the memory mapped IO for a given device_node
diff --git a/include/linux/of_address.h b/include/linux/of_address.h
index 2feda6e..bdfc20d 100644
--- a/include/linux/of_address.h
+++ b/include/linux/of_address.h
@@ -6,6 +6,10 @@
 extern u64 of_translate_address(struct device_node *np, const __be32 *addr);
 extern int of_address_to_resource(struct device_node *dev, int index,
 				  struct resource *r);
+extern struct device_node *of_find_matching_node_by_address(
+					struct device_node *from,
+					const struct of_device_id *matches,
+					u64 base_address);
 extern void __iomem *of_iomap(struct device_node *device, int index);
 
 /* Extract an address from a device, returns the region size and

WARNING: multiple messages have this Message-ID (diff)
From: grant.likely@secretlab.ca (Grant Likely)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC PATCH 02/11] of/address: Add of_find_matching_node_by_address helper
Date: Wed, 15 Jun 2011 22:41:36 -0600	[thread overview]
Message-ID: <20110616044130.29371.31242.stgit@ponder> (raw)
In-Reply-To: <20110616042653.29371.2052.stgit@ponder>

of_find_matching_node_by_address() can be used to find a device tree
node for a device at a specific address.

Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
---
 drivers/of/address.c       |   18 ++++++++++++++++++
 include/linux/of_address.h |    4 ++++
 2 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/drivers/of/address.c b/drivers/of/address.c
index b4559c5..da1f4b9 100644
--- a/drivers/of/address.c
+++ b/drivers/of/address.c
@@ -577,6 +577,24 @@ int of_address_to_resource(struct device_node *dev, int index,
 }
 EXPORT_SYMBOL_GPL(of_address_to_resource);
 
+struct device_node *of_find_matching_node_by_address(struct device_node *from,
+					const struct of_device_id *matches,
+					u64 base_address)
+{
+	struct device_node *dn = of_find_matching_node(from, matches);
+	struct resource res;
+
+	while (dn) {
+		if (of_address_to_resource(dn, 0, &res))
+			continue;
+		if (res.start == base_address)
+			return dn;
+		dn = of_find_matching_node(dn, matches);
+	}
+
+	return NULL;
+}
+
 
 /**
  * of_iomap - Maps the memory mapped IO for a given device_node
diff --git a/include/linux/of_address.h b/include/linux/of_address.h
index 2feda6e..bdfc20d 100644
--- a/include/linux/of_address.h
+++ b/include/linux/of_address.h
@@ -6,6 +6,10 @@
 extern u64 of_translate_address(struct device_node *np, const __be32 *addr);
 extern int of_address_to_resource(struct device_node *dev, int index,
 				  struct resource *r);
+extern struct device_node *of_find_matching_node_by_address(
+					struct device_node *from,
+					const struct of_device_id *matches,
+					u64 base_address);
 extern void __iomem *of_iomap(struct device_node *device, int index);
 
 /* Extract an address from a device, returns the region size and

  parent reply	other threads:[~2011-06-16  4:41 UTC|newest]

Thread overview: 66+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-16  4:40 [RFC PATCH 00/11] Full device tree support for ARM Versatile Grant Likely
2011-06-16  4:40 ` Grant Likely
2011-06-16  4:40 ` Grant Likely
2011-06-16  4:41 ` [RFC PATCH 01/11] irq: add irq_domain translation infrastructure Grant Likely
2011-06-16  4:41   ` Grant Likely
2011-06-16  4:41   ` Grant Likely
2011-06-20  9:54   ` Marc Zyngier
2011-06-20  9:54     ` Marc Zyngier
2011-06-20  9:54     ` Marc Zyngier
2011-06-16  4:41 ` Grant Likely [this message]
2011-06-16  4:41   ` [RFC PATCH 02/11] of/address: Add of_find_matching_node_by_address helper Grant Likely
2011-06-16  4:41   ` Grant Likely
2011-06-16  4:41 ` [RFC PATCH 03/11] dt/irq: add irq_domain_add_simple() helper Grant Likely
2011-06-16  4:41   ` Grant Likely
2011-06-16  4:41   ` Grant Likely
2011-06-16 14:04   ` Rob Herring
2011-06-16 14:04     ` Rob Herring
2011-06-16 14:04     ` Rob Herring
2011-06-16 14:21     ` Rob Herring
2011-06-16 14:21       ` Rob Herring
2011-06-16 14:21       ` Rob Herring
2011-06-16 16:57       ` Grant Likely
2011-06-16 16:57         ` Grant Likely
2011-06-16 16:57         ` Grant Likely
2011-06-16 16:56     ` Grant Likely
2011-06-16 16:56       ` Grant Likely
2011-06-16 16:56       ` Grant Likely
2011-06-16  4:41 ` [RFC PATCH 04/11] dt: add of_platform_populate() for creating device from the device tree Grant Likely
2011-06-16  4:41   ` Grant Likely
2011-06-16  4:41   ` Grant Likely
2011-06-16  4:42 ` [RFC PATCH 05/11] dt: Add default match table for bus ids Grant Likely
2011-06-16  4:42   ` Grant Likely
2011-06-16  4:42   ` Grant Likely
2011-06-16  4:42 ` [RFC PATCH 06/11] drivers/amba: create devices from device tree Grant Likely
2011-06-16  4:42   ` Grant Likely
2011-06-16  4:42   ` Grant Likely
2011-06-16  4:42 ` [RFC PATCH 07/11] dt/platform: allow device name to be overridden Grant Likely
2011-06-16  4:42   ` Grant Likely
2011-06-16  4:42   ` Grant Likely
2011-06-16  4:42 ` [RFC PATCH 08/11] powerpc/5200: convert mpc5200 to use of_platform_populate() Grant Likely
2011-06-16  4:42   ` Grant Likely
2011-06-16  4:42   ` Grant Likely
2011-06-16  4:42 ` [RFC PATCH 09/11] arm/dt: Add dt machine definition Grant Likely
2011-06-16  4:42   ` Grant Likely
2011-06-16  4:42   ` Grant Likely
2011-07-08 14:30   ` Rob Herring
2011-07-08 14:30     ` Rob Herring
2011-06-16  4:43 ` [RFC PATCH 10/11] arm/dt: Add skeleton dtsi file Grant Likely
2011-06-16  4:43   ` Grant Likely
2011-06-16  4:43   ` Grant Likely
2011-06-16  4:43 ` [RFC PATCH 11/11] arm/versatile: Add device tree support Grant Likely
2011-06-16  4:43   ` Grant Likely
2011-06-16  4:43   ` Grant Likely
2011-06-16 14:19   ` Rob Herring
2011-06-16 14:19     ` Rob Herring
2011-06-16 15:42     ` Grant Likely
2011-06-16 15:42       ` Grant Likely
2011-06-16 15:42       ` Grant Likely
2011-06-16 14:20   ` Arnd Bergmann
2011-06-16 14:20     ` Arnd Bergmann
2011-06-16 14:20     ` Arnd Bergmann
2011-06-16 14:56     ` Grant Likely
2011-06-16 14:56       ` Grant Likely
2011-06-17  1:11   ` Shawn Guo
2011-06-17  1:11     ` Shawn Guo
2011-06-17  1:11     ` Shawn Guo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110616044130.29371.31242.stgit@ponder \
    --to=grant.likely@secretlab.ca \
    --cc=arnd@arndb.de \
    --cc=devicetree-discuss@lists.ozlabs.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=nicolas.pitre@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.