[PATCH 6/7] Add dcr_map_reg() helper

Michael Ellerman michael at ellerman.id.au
Mon Sep 17 16:05:04 EST 2007


Add a helper routine to map dcr's based on the "dcr-reg" property of
a device node.

Signed-off-by: Michael Ellerman <michael at ellerman.id.au>
---
 arch/powerpc/sysdev/dcr.c |   17 +++++++++++++++++
 include/asm-powerpc/dcr.h |    1 +
 2 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/arch/powerpc/sysdev/dcr.c b/arch/powerpc/sysdev/dcr.c
index ab11c0b..da4f9c6 100644
--- a/arch/powerpc/sysdev/dcr.c
+++ b/arch/powerpc/sysdev/dcr.c
@@ -126,6 +126,23 @@ dcr_host_t dcr_map(struct device_node *dev, unsigned int dcr_n,
 }
 EXPORT_SYMBOL_GPL(dcr_map);
 
+dcr_host_t dcr_map_reg(struct device_node *dev, unsigned int index)
+{
+	dcr_host_t ret = { .token = NULL };
+
+	unsigned int dcr_n, dcr_c;
+
+	dcr_n = dcr_resource_start(dev, index);
+	if (!dcr_n)
+		return ret;
+
+	dcr_c = dcr_resource_len(dev, index);
+	if (!dcr_c)
+		return ret;
+
+	return dcr_map(dev, dcr_n, dcr_c);
+}
+
 void dcr_unmap(dcr_host_t host, unsigned int dcr_n, unsigned int dcr_c)
 {
 	dcr_host_t h = host;
diff --git a/include/asm-powerpc/dcr.h b/include/asm-powerpc/dcr.h
index 9338d50..4d42f01 100644
--- a/include/asm-powerpc/dcr.h
+++ b/include/asm-powerpc/dcr.h
@@ -38,6 +38,7 @@ extern unsigned int dcr_resource_start(struct device_node *np,
 				       unsigned int index);
 extern unsigned int dcr_resource_len(struct device_node *np,
 				     unsigned int index);
+extern dcr_host_t dcr_map_reg(struct device_node *np, unsigned int index);
 #endif /* CONFIG_PPC_MERGE */
 
 #endif /* CONFIG_PPC_DCR */
-- 
1.5.1.3.g7a33b




More information about the Linuxppc-dev mailing list