summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2007-11-20 13:35:46 +1100
committerJon Loeliger <jdl@freescale.com>2007-11-20 09:00:37 -0600
commit9521dc5ecc66c158cd6853cabba2c29f545780f6 (patch)
tree066c76f58e756bc166b2ed9d670c8975ecc04961
parent682576d85bd159fc25ef99ab35a997fda172592e (diff)
downloaddtc-9521dc5ecc66c158cd6853cabba2c29f545780f6.tar.gz
libfdt: Abolish _typed() variants, add _cell() variants
In a number of places through libfdt and its tests, we have *_typed() macro variants on functions which use gcc's typeof and statement expression extensions to allow passing literals where the underlying function takes a buffer and size. These seemed like a good idea at the time, but in fact they have some problems. They use typeof and statement expressions, extensions I'd prefer to avoid for portability. Plus, they have potential gotchas - although they'll deal with the size of the thing passed, they won't deal with other representation issues (like endianness) and results could be very strange if the type of the expression passed isn't what you think it is. In fact, the only users of these _typed() macros were when the value passed is a single cell (32-bit integer). Therefore, this patch removes all these _typed() macros and replaces them with explicit _cell() variants which handle a single 32-bit integer, and which also perform endian convesions as appropriate. With this in place, it now becomes easy to use standardized big-endian representation for integer valued properties in the testcases, regardless of the platform we're running on. We therefore do that, which has the additional advantage that all the example trees created during a test run are now byte-for-byte identical regardless of platform. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
-rw-r--r--libfdt/libfdt.h33
-rw-r--r--tests/del_node.c10
-rw-r--r--tests/del_property.c2
-rw-r--r--tests/find_property.c2
-rw-r--r--tests/getprop.c2
-rw-r--r--tests/node_offset_by_prop_value.c14
-rw-r--r--tests/nop_node.c10
-rw-r--r--tests/nop_property.c2
-rw-r--r--tests/rw_tree1.c16
-rw-r--r--tests/setprop.c2
-rw-r--r--tests/setprop_inplace.c6
-rw-r--r--tests/subnode_offset.c10
-rw-r--r--tests/sw_tree1.c14
-rw-r--r--tests/testdata.h4
-rw-r--r--tests/tests.h8
-rw-r--r--tests/trees.S7
16 files changed, 70 insertions, 72 deletions
diff --git a/libfdt/libfdt.h b/libfdt/libfdt.h
index d2f8320..a61e50d 100644
--- a/libfdt/libfdt.h
+++ b/libfdt/libfdt.h
@@ -663,12 +663,12 @@ int fdt_node_offset_by_compatible(const void *fdt, int startoffset,
int fdt_setprop_inplace(void *fdt, int nodeoffset, const char *name,
const void *val, int len);
-
-#define fdt_setprop_inplace_typed(fdt, nodeoffset, name, val) \
- ({ \
- typeof(val) x = val; \
- fdt_setprop_inplace(fdt, nodeoffset, name, &x, sizeof(x)); \
- })
+static inline int fdt_setprop_inplace_cell(void *fdt, int nodeoffset,
+ const char *name, uint32_t val)
+{
+ val = cpu_to_fdt32(val);
+ return fdt_setprop_inplace(fdt, nodeoffset, name, &val, sizeof(val));
+}
int fdt_nop_property(void *fdt, int nodeoffset, const char *name);
int fdt_nop_node(void *fdt, int nodeoffset);
@@ -682,11 +682,11 @@ int fdt_add_reservemap_entry(void *fdt, uint64_t addr, uint64_t size);
int fdt_finish_reservemap(void *fdt);
int fdt_begin_node(void *fdt, const char *name);
int fdt_property(void *fdt, const char *name, const void *val, int len);
-#define fdt_property_typed(fdt, name, val) \
- ({ \
- typeof(val) x = (val); \
- fdt_property((fdt), (name), &x, sizeof(x)); \
- })
+static inline int fdt_property_cell(void *fdt, const char *name, uint32_t val)
+{
+ val = cpu_to_fdt32(val);
+ return fdt_property(fdt, name, &val, sizeof(val));
+}
#define fdt_property_string(fdt, name, str) \
fdt_property(fdt, name, str, strlen(str)+1)
int fdt_end_node(void *fdt);
@@ -704,11 +704,12 @@ int fdt_del_mem_rsv(void *fdt, int n);
int fdt_setprop(void *fdt, int nodeoffset, const char *name,
const void *val, int len);
-#define fdt_setprop_typed(fdt, nodeoffset, name, val) \
- ({ \
- typeof(val) x = (val); \
- fdt_setprop((fdt), (nodeoffset), (name), &x, sizeof(x)); \
- })
+static inline int fdt_setprop_cell(void *fdt, int nodeoffset, const char *name,
+ uint32_t val)
+{
+ val = cpu_to_fdt32(val);
+ return fdt_setprop(fdt, nodeoffset, name, &val, sizeof(val));
+}
#define fdt_setprop_string(fdt, nodeoffset, name, str) \
fdt_setprop((fdt), (nodeoffset), (name), (str), strlen(str)+1)
int fdt_delprop(void *fdt, int nodeoffset, const char *name);
diff --git a/tests/del_node.c b/tests/del_node.c
index fad777e..afad502 100644
--- a/tests/del_node.c
+++ b/tests/del_node.c
@@ -48,19 +48,19 @@ int main(int argc, char *argv[])
if (subnode1_offset < 0)
FAIL("Couldn't find \"/subnode@1\": %s",
fdt_strerror(subnode1_offset));
- check_getprop_typed(fdt, subnode1_offset, "prop-int", TEST_VALUE_1);
+ check_getprop_cell(fdt, subnode1_offset, "prop-int", TEST_VALUE_1);
subnode2_offset = fdt_path_offset(fdt, "/subnode@2");
if (subnode2_offset < 0)
FAIL("Couldn't find \"/subnode@2\": %s",
fdt_strerror(subnode2_offset));
- check_getprop_typed(fdt, subnode2_offset, "prop-int", TEST_VALUE_2);
+ check_getprop_cell(fdt, subnode2_offset, "prop-int", TEST_VALUE_2);
subsubnode2_offset = fdt_path_offset(fdt, "/subnode@2/subsubnode");
if (subsubnode2_offset < 0)
FAIL("Couldn't find \"/subnode@2/subsubnode\": %s",
fdt_strerror(subsubnode2_offset));
- check_getprop_typed(fdt, subsubnode2_offset, "prop-int", TEST_VALUE_2);
+ check_getprop_cell(fdt, subsubnode2_offset, "prop-int", TEST_VALUE_2);
err = fdt_del_node(fdt, subnode1_offset);
if (err)
@@ -76,13 +76,13 @@ int main(int argc, char *argv[])
if (subnode2_offset < 0)
FAIL("Couldn't find \"/subnode2\": %s",
fdt_strerror(subnode2_offset));
- check_getprop_typed(fdt, subnode2_offset, "prop-int", TEST_VALUE_2);
+ check_getprop_cell(fdt, subnode2_offset, "prop-int", TEST_VALUE_2);
subsubnode2_offset = fdt_path_offset(fdt, "/subnode@2/subsubnode");
if (subsubnode2_offset < 0)
FAIL("Couldn't find \"/subnode@2/subsubnode\": %s",
fdt_strerror(subsubnode2_offset));
- check_getprop_typed(fdt, subsubnode2_offset, "prop-int", TEST_VALUE_2);
+ check_getprop_cell(fdt, subsubnode2_offset, "prop-int", TEST_VALUE_2);
err = fdt_del_node(fdt, subnode2_offset);
if (err)
diff --git a/tests/del_property.c b/tests/del_property.c
index 2c412c3..449eca6 100644
--- a/tests/del_property.c
+++ b/tests/del_property.c
@@ -45,7 +45,7 @@ int main(int argc, char *argv[])
oldsize = fdt_totalsize(fdt);
- intp = check_getprop_typed(fdt, 0, "prop-int", TEST_VALUE_1);
+ intp = check_getprop_cell(fdt, 0, "prop-int", TEST_VALUE_1);
verbose_printf("int value was 0x%08x\n", *intp);
err = fdt_delprop(fdt, 0, "prop-int");
diff --git a/tests/find_property.c b/tests/find_property.c
index ced14ae..74a6965 100644
--- a/tests/find_property.c
+++ b/tests/find_property.c
@@ -35,7 +35,7 @@ int main(int argc, char *argv[])
test_init(argc, argv);
fdt = load_blob_arg(argc, argv);
- check_property_typed(fdt, 0, "prop-int", TEST_VALUE_1);
+ check_property_cell(fdt, 0, "prop-int", TEST_VALUE_1);
check_property(fdt, 0, "prop-str", strlen(TEST_STRING_1)+1, TEST_STRING_1);
PASS();
diff --git a/tests/getprop.c b/tests/getprop.c
index f124951..239856e 100644
--- a/tests/getprop.c
+++ b/tests/getprop.c
@@ -36,7 +36,7 @@ int main(int argc, char *argv[])
test_init(argc, argv);
fdt = load_blob_arg(argc, argv);
- check_getprop_typed(fdt, 0, "prop-int", TEST_VALUE_1);
+ check_getprop_cell(fdt, 0, "prop-int", TEST_VALUE_1);
check_getprop(fdt, 0, "prop-str", strlen(TEST_STRING_1)+1, TEST_STRING_1);
PASS();
diff --git a/tests/node_offset_by_prop_value.c b/tests/node_offset_by_prop_value.c
index 651bc05..c55110a 100644
--- a/tests/node_offset_by_prop_value.c
+++ b/tests/node_offset_by_prop_value.c
@@ -67,9 +67,9 @@ void check_search_str(void *fdt, const char *propname, const char *propval, ...)
va_end(ap);
}
-#define check_search_val(fdt, propname, propval, ...) \
+#define check_search_cell(fdt, propname, propval, ...) \
{ \
- typeof(propval) val = (propval); \
+ uint32_t val = cpu_to_fdt32(propval); \
check_search((fdt), (propname), &val, sizeof(val), \
##__VA_ARGS__); \
}
@@ -92,17 +92,17 @@ int main(int argc, char *argv[])
|| (subsubnode1_offset < 0) || (subsubnode2_offset < 0))
FAIL("Can't find required nodes");
- check_search_val(fdt, "prop-int", TEST_VALUE_1, 0, subnode1_offset,
- subsubnode1_offset, -FDT_ERR_NOTFOUND);
+ check_search_cell(fdt, "prop-int", TEST_VALUE_1, 0, subnode1_offset,
+ subsubnode1_offset, -FDT_ERR_NOTFOUND);
- check_search_val(fdt, "prop-int", TEST_VALUE_2, subnode2_offset,
- subsubnode2_offset, -FDT_ERR_NOTFOUND);
+ check_search_cell(fdt, "prop-int", TEST_VALUE_2, subnode2_offset,
+ subsubnode2_offset, -FDT_ERR_NOTFOUND);
check_search_str(fdt, "prop-str", TEST_STRING_1, 0, -FDT_ERR_NOTFOUND);
check_search_str(fdt, "prop-str", "no such string", -FDT_ERR_NOTFOUND);
- check_search_val(fdt, "prop-int", TEST_VALUE_1+1, -FDT_ERR_NOTFOUND);
+ check_search_cell(fdt, "prop-int", TEST_VALUE_1+1, -FDT_ERR_NOTFOUND);
check_search(fdt, "no-such-prop", NULL, 0, -FDT_ERR_NOTFOUND);
diff --git a/tests/nop_node.c b/tests/nop_node.c
index ab487a4..ea3a18f 100644
--- a/tests/nop_node.c
+++ b/tests/nop_node.c
@@ -43,19 +43,19 @@ int main(int argc, char *argv[])
if (subnode1_offset < 0)
FAIL("Couldn't find \"/subnode1\": %s",
fdt_strerror(subnode1_offset));
- check_getprop_typed(fdt, subnode1_offset, "prop-int", TEST_VALUE_1);
+ check_getprop_cell(fdt, subnode1_offset, "prop-int", TEST_VALUE_1);
subnode2_offset = fdt_path_offset(fdt, "/subnode@2");
if (subnode2_offset < 0)
FAIL("Couldn't find \"/subnode2\": %s",
fdt_strerror(subnode2_offset));
- check_getprop_typed(fdt, subnode2_offset, "prop-int", TEST_VALUE_2);
+ check_getprop_cell(fdt, subnode2_offset, "prop-int", TEST_VALUE_2);
subsubnode2_offset = fdt_path_offset(fdt, "/subnode@2/subsubnode");
if (subsubnode2_offset < 0)
FAIL("Couldn't find \"/subnode@2/subsubnode\": %s",
fdt_strerror(subsubnode2_offset));
- check_getprop_typed(fdt, subsubnode2_offset, "prop-int", TEST_VALUE_2);
+ check_getprop_cell(fdt, subsubnode2_offset, "prop-int", TEST_VALUE_2);
err = fdt_nop_node(fdt, subnode1_offset);
if (err)
@@ -71,13 +71,13 @@ int main(int argc, char *argv[])
if (subnode2_offset < 0)
FAIL("Couldn't find \"/subnode2\": %s",
fdt_strerror(subnode2_offset));
- check_getprop_typed(fdt, subnode2_offset, "prop-int", TEST_VALUE_2);
+ check_getprop_cell(fdt, subnode2_offset, "prop-int", TEST_VALUE_2);
subsubnode2_offset = fdt_path_offset(fdt, "/subnode@2/subsubnode");
if (subsubnode2_offset < 0)
FAIL("Couldn't find \"/subnode@2/subsubnode\": %s",
fdt_strerror(subsubnode2_offset));
- check_getprop_typed(fdt, subsubnode2_offset, "prop-int", TEST_VALUE_2);
+ check_getprop_cell(fdt, subsubnode2_offset, "prop-int", TEST_VALUE_2);
err = fdt_nop_node(fdt, subnode2_offset);
if (err)
diff --git a/tests/nop_property.c b/tests/nop_property.c
index 02371ac..e6ef4d9 100644
--- a/tests/nop_property.c
+++ b/tests/nop_property.c
@@ -41,7 +41,7 @@ int main(int argc, char *argv[])
test_init(argc, argv);
fdt = load_blob_arg(argc, argv);
- intp = check_getprop_typed(fdt, 0, "prop-int", TEST_VALUE_1);
+ intp = check_getprop_cell(fdt, 0, "prop-int", TEST_VALUE_1);
verbose_printf("int value was 0x%08x\n", *intp);
err = fdt_nop_property(fdt, 0, "prop-int");
diff --git a/tests/rw_tree1.c b/tests/rw_tree1.c
index 71f7b98..8f335c9 100644
--- a/tests/rw_tree1.c
+++ b/tests/rw_tree1.c
@@ -73,27 +73,25 @@ int main(int argc, char *argv[])
CHECK(fdt_add_mem_rsv(fdt, TEST_ADDR_2, TEST_SIZE_2));
CHECK(fdt_setprop_string(fdt, 0, "compatible", "test_tree1"));
- CHECK(fdt_setprop_typed(fdt, 0, "prop-int", TEST_VALUE_1));
+ CHECK(fdt_setprop_cell(fdt, 0, "prop-int", TEST_VALUE_1));
CHECK(fdt_setprop_string(fdt, 0, "prop-str", TEST_STRING_1));
OFF_CHECK(offset, fdt_add_subnode(fdt, 0, "subnode@1"));
CHECK(fdt_setprop_string(fdt, offset, "compatible", "subnode1"));
- CHECK(fdt_setprop_typed(fdt, offset, "prop-int", TEST_VALUE_1));
+ CHECK(fdt_setprop_cell(fdt, offset, "prop-int", TEST_VALUE_1));
OFF_CHECK(offset, fdt_add_subnode(fdt, offset, "subsubnode"));
CHECK(fdt_setprop(fdt, offset, "compatible",
"subsubnode1\0subsubnode", 23));
- CHECK(fdt_setprop_typed(fdt, offset, "prop-int", TEST_VALUE_1));
+ CHECK(fdt_setprop_cell(fdt, offset, "prop-int", TEST_VALUE_1));
OFF_CHECK(offset, fdt_add_subnode(fdt, 0, "subnode@2"));
- CHECK(fdt_setprop_typed(fdt, offset, "linux,phandle",
- cpu_to_fdt32(PHANDLE_1)));
- CHECK(fdt_setprop_typed(fdt, offset, "prop-int", TEST_VALUE_2));
+ CHECK(fdt_setprop_cell(fdt, offset, "linux,phandle", PHANDLE_1));
+ CHECK(fdt_setprop_cell(fdt, offset, "prop-int", TEST_VALUE_2));
OFF_CHECK(offset, fdt_add_subnode(fdt, offset, "subsubnode@0"));
- CHECK(fdt_setprop_typed(fdt, offset, "linux,phandle",
- cpu_to_fdt32(PHANDLE_2)));
+ CHECK(fdt_setprop_cell(fdt, offset, "linux,phandle", PHANDLE_2));
CHECK(fdt_setprop(fdt, offset, "compatible",
"subsubnode2\0subsubnode", 23));
- CHECK(fdt_setprop_typed(fdt, offset, "prop-int", TEST_VALUE_2));
+ CHECK(fdt_setprop_cell(fdt, offset, "prop-int", TEST_VALUE_2));
CHECK(fdt_pack(fdt));
diff --git a/tests/setprop.c b/tests/setprop.c
index d771954..386b87b 100644
--- a/tests/setprop.c
+++ b/tests/setprop.c
@@ -52,7 +52,7 @@ int main(int argc, char *argv[])
fdt = buf;
- intp = check_getprop_typed(fdt, 0, "prop-int", TEST_VALUE_1);
+ intp = check_getprop_cell(fdt, 0, "prop-int", TEST_VALUE_1);
verbose_printf("Old int value was 0x%08x\n", *intp);
err = fdt_setprop_string(fdt, 0, "prop-int", NEW_STRING);
diff --git a/tests/setprop_inplace.c b/tests/setprop_inplace.c
index 590dfeb..aa0cd96 100644
--- a/tests/setprop_inplace.c
+++ b/tests/setprop_inplace.c
@@ -42,14 +42,14 @@ int main(int argc, char *argv[])
test_init(argc, argv);
fdt = load_blob_arg(argc, argv);
- intp = check_getprop_typed(fdt, 0, "prop-int", TEST_VALUE_1);
+ intp = check_getprop_cell(fdt, 0, "prop-int", TEST_VALUE_1);
verbose_printf("Old int value was 0x%08x\n", *intp);
- err = fdt_setprop_inplace_typed(fdt, 0, "prop-int", ~TEST_VALUE_1);
+ err = fdt_setprop_inplace_cell(fdt, 0, "prop-int", ~TEST_VALUE_1);
if (err)
FAIL("Failed to set \"prop-int\" to 0x08%x: %s",
~TEST_VALUE_1, fdt_strerror(err));
- intp = check_getprop_typed(fdt, 0, "prop-int", ~TEST_VALUE_1);
+ intp = check_getprop_cell(fdt, 0, "prop-int", ~TEST_VALUE_1);
verbose_printf("New int value is 0x%08x\n", *intp);
strp = check_getprop(fdt, 0, "prop-str", strlen(TEST_STRING_1)+1,
diff --git a/tests/subnode_offset.c b/tests/subnode_offset.c
index eafce2c..f5b88e1 100644
--- a/tests/subnode_offset.c
+++ b/tests/subnode_offset.c
@@ -70,16 +70,16 @@ int main(int argc, char *argv[])
if (subnode1_offset == subnode2_offset)
FAIL("Different subnodes have same offset");
- check_property_typed(fdt, subnode1_offset, "prop-int", TEST_VALUE_1);
- check_property_typed(fdt, subnode2_offset, "prop-int", TEST_VALUE_2);
+ check_property_cell(fdt, subnode1_offset, "prop-int", TEST_VALUE_1);
+ check_property_cell(fdt, subnode2_offset, "prop-int", TEST_VALUE_2);
subsubnode1_offset = check_subnode(fdt, subnode1_offset, "subsubnode");
subsubnode2_offset = check_subnode(fdt, subnode2_offset, "subsubnode@0");
subsubnode2_offset2 = check_subnode(fdt, subnode2_offset, "subsubnode");
- check_property_typed(fdt, subsubnode1_offset, "prop-int", TEST_VALUE_1);
- check_property_typed(fdt, subsubnode2_offset, "prop-int", TEST_VALUE_2);
- check_property_typed(fdt, subsubnode2_offset2, "prop-int", TEST_VALUE_2);
+ check_property_cell(fdt, subsubnode1_offset, "prop-int", TEST_VALUE_1);
+ check_property_cell(fdt, subsubnode2_offset, "prop-int", TEST_VALUE_2);
+ check_property_cell(fdt, subsubnode2_offset2, "prop-int", TEST_VALUE_2);
if (subsubnode2_offset != subsubnode2_offset2)
FAIL("Different offsets with and without unit address");
diff --git a/tests/sw_tree1.c b/tests/sw_tree1.c
index 215d515..2a94b63 100644
--- a/tests/sw_tree1.c
+++ b/tests/sw_tree1.c
@@ -55,27 +55,27 @@ int main(int argc, char *argv[])
CHECK(fdt_begin_node(fdt, ""));
CHECK(fdt_property_string(fdt, "compatible", "test_tree1"));
- CHECK(fdt_property_typed(fdt, "prop-int", TEST_VALUE_1));
+ CHECK(fdt_property_cell(fdt, "prop-int", TEST_VALUE_1));
CHECK(fdt_property_string(fdt, "prop-str", TEST_STRING_1));
CHECK(fdt_begin_node(fdt, "subnode@1"));
CHECK(fdt_property_string(fdt, "compatible", "subnode1"));
- CHECK(fdt_property_typed(fdt, "prop-int", TEST_VALUE_1));
+ CHECK(fdt_property_cell(fdt, "prop-int", TEST_VALUE_1));
CHECK(fdt_begin_node(fdt, "subsubnode"));
CHECK(fdt_property(fdt, "compatible", "subsubnode1\0subsubnode",
23));
- CHECK(fdt_property_typed(fdt, "prop-int", TEST_VALUE_1));
+ CHECK(fdt_property_cell(fdt, "prop-int", TEST_VALUE_1));
CHECK(fdt_end_node(fdt));
CHECK(fdt_end_node(fdt));
CHECK(fdt_begin_node(fdt, "subnode@2"));
- CHECK(fdt_property_typed(fdt, "linux,phandle", cpu_to_fdt32(PHANDLE_1)));
- CHECK(fdt_property_typed(fdt, "prop-int", TEST_VALUE_2));
+ CHECK(fdt_property_cell(fdt, "linux,phandle", PHANDLE_1));
+ CHECK(fdt_property_cell(fdt, "prop-int", TEST_VALUE_2));
CHECK(fdt_begin_node(fdt, "subsubnode@0"));
- CHECK(fdt_property_typed(fdt, "linux,phandle", cpu_to_fdt32(PHANDLE_2)));
+ CHECK(fdt_property_cell(fdt, "linux,phandle", PHANDLE_2));
CHECK(fdt_property(fdt, "compatible", "subsubnode2\0subsubnode",
23));
- CHECK(fdt_property_typed(fdt, "prop-int", TEST_VALUE_2));
+ CHECK(fdt_property_cell(fdt, "prop-int", TEST_VALUE_2));
CHECK(fdt_end_node(fdt));
CHECK(fdt_end_node(fdt));
diff --git a/tests/testdata.h b/tests/testdata.h
index 130026f..0f7f2fa 100644
--- a/tests/testdata.h
+++ b/tests/testdata.h
@@ -20,8 +20,8 @@
#define TEST_ADDR_2 ASM_CONST_LL(123456789)
#define TEST_SIZE_2 ASM_CONST_LL(010000)
-#define TEST_VALUE_1 cell_to_fdt(0xdeadbeef)
-#define TEST_VALUE_2 cell_to_fdt(123456789)
+#define TEST_VALUE_1 0xdeadbeef
+#define TEST_VALUE_2 123456789
#define PHANDLE_1 0x2000
#define PHANDLE_2 0x2001
diff --git a/tests/tests.h b/tests/tests.h
index f6dcd15..c273f3c 100644
--- a/tests/tests.h
+++ b/tests/tests.h
@@ -112,18 +112,18 @@ void check_mem_rsv(void *fdt, int n, uint64_t addr, uint64_t size);
void check_property(void *fdt, int nodeoffset, const char *name,
int len, const void *val);
-#define check_property_typed(fdt, nodeoffset, name, val) \
+#define check_property_cell(fdt, nodeoffset, name, val) \
({ \
- typeof(val) x = val; \
+ uint32_t x = cpu_to_fdt32(val); \
check_property(fdt, nodeoffset, name, sizeof(x), &x); \
})
const void *check_getprop(void *fdt, int nodeoffset, const char *name,
int len, const void *val);
-#define check_getprop_typed(fdt, nodeoffset, name, val) \
+#define check_getprop_cell(fdt, nodeoffset, name, val) \
({ \
- typeof(val) x = val; \
+ uint32_t x = cpu_to_fdt32(val); \
check_getprop(fdt, nodeoffset, name, sizeof(x), &x); \
})
#define check_getprop_string(fdt, nodeoffset, name, s) \
diff --git a/tests/trees.S b/tests/trees.S
index 8ecae27..e3c5d47 100644
--- a/tests/trees.S
+++ b/tests/trees.S
@@ -50,8 +50,7 @@ tree##_rsvmap_end: ;
#define PROP_INT(tree, name, val) \
PROPHDR(tree, name, 4) \
- /* For ease of testing the property values go in native-endian */ \
- .long val ;
+ FDTLONG(val) ;
#define PROP_STR(tree, name, str) \
PROPHDR(tree, name, 55f - 54f) \
@@ -100,11 +99,11 @@ test_tree1_struct:
END_NODE
BEGIN_NODE("subnode@2")
- PROP_INT(test_tree1, phandle, cell_to_fdt(PHANDLE_1))
+ PROP_INT(test_tree1, phandle, PHANDLE_1)
PROP_INT(test_tree1, prop_int, TEST_VALUE_2)
BEGIN_NODE("subsubnode@0")
- PROP_INT(test_tree1, phandle, cell_to_fdt(PHANDLE_2))
+ PROP_INT(test_tree1, phandle, PHANDLE_2)
PROP_STR(test_tree1, compatible, "subsubnode2\0subsubnode")
PROP_INT(test_tree1, prop_int, TEST_VALUE_2)
END_NODE