[rtems-libbsd commit] linux/of.h: Add of_read_number()

Sebastian Huber sebh at rtems.org
Tue Jan 23 13:57:42 UTC 2018


Module:    rtems-libbsd
Branch:    master
Commit:    44fca38058e84442940cad05a0a53696f2744729
Changeset: http://git.rtems.org/rtems-libbsd/commit/?id=44fca38058e84442940cad05a0a53696f2744729

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Wed Jan 17 14:14:10 2018 +0100

linux/of.h: Add of_read_number()

Update #3277.

---

 rtemsbsd/powerpc/include/linux/of.h |  2 ++
 rtemsbsd/sys/powerpc/compat.c       | 16 ++++++++++++++++
 2 files changed, 18 insertions(+)

diff --git a/rtemsbsd/powerpc/include/linux/of.h b/rtemsbsd/powerpc/include/linux/of.h
index 5ab5431..8ef0469 100644
--- a/rtemsbsd/powerpc/include/linux/of.h
+++ b/rtemsbsd/powerpc/include/linux/of.h
@@ -76,6 +76,8 @@ of_property_read_u32(const struct device_node *dn, const char *name, u32 *val)
 	return (of_property_read_u32_array(dn, name, val, 1));
 }
 
+uint64_t of_read_number(const uint32_t *cell, int size);
+
 struct device_node *of_parse_phandle(struct device_node *dns,
     struct device_node *dn, const char *phandle_name, int index);
 
diff --git a/rtemsbsd/sys/powerpc/compat.c b/rtemsbsd/sys/powerpc/compat.c
index 2ff85f4..400eac5 100644
--- a/rtemsbsd/sys/powerpc/compat.c
+++ b/rtemsbsd/sys/powerpc/compat.c
@@ -121,6 +121,22 @@ of_find_compatible_node(struct device_node *dns, const struct device_node *dn,
 	}
 }
 
+uint64_t
+of_read_number(const uint32_t *cell, int size)
+{
+	uint64_t number;
+
+	number = 0;
+
+	while (size > 0) {
+		number = (number << 32) | fdt32_to_cpu(*cell);
+		++cell;
+		--size;
+	}
+
+	return (number);
+}
+
 struct device_node *
 of_parse_phandle(struct device_node *dns, struct device_node *dn,
     const char *phandle_name, int index)




More information about the vc mailing list