mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-24 21:54:01 +00:00
dm: core: Support writing a 64-bit value
Add support for writing a single 64-bit value into a property. Repurpose the existing tests to handle this case too. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
d9216c8683
commit
7071c82bdc
3 changed files with 39 additions and 3 deletions
|
@ -1621,7 +1621,22 @@ int ofnode_write_u32(ofnode node, const char *propname, u32 value)
|
|||
return -ENOMEM;
|
||||
*val = cpu_to_fdt32(value);
|
||||
|
||||
return ofnode_write_prop(node, propname, val, sizeof(value), false);
|
||||
return ofnode_write_prop(node, propname, val, sizeof(value), true);
|
||||
}
|
||||
|
||||
int ofnode_write_u64(ofnode node, const char *propname, u64 value)
|
||||
{
|
||||
fdt64_t *val;
|
||||
|
||||
assert(ofnode_valid(node));
|
||||
|
||||
log_debug("%s = %llx", propname, (unsigned long long)value);
|
||||
val = malloc(sizeof(*val));
|
||||
if (!val)
|
||||
return -ENOMEM;
|
||||
*val = cpu_to_fdt64(value);
|
||||
|
||||
return ofnode_write_prop(node, propname, val, sizeof(value), true);
|
||||
}
|
||||
|
||||
int ofnode_write_bool(ofnode node, const char *propname, bool value)
|
||||
|
|
|
@ -1461,6 +1461,16 @@ int ofnode_write_string(ofnode node, const char *propname, const char *value);
|
|||
*/
|
||||
int ofnode_write_u32(ofnode node, const char *propname, u32 value);
|
||||
|
||||
/**
|
||||
* ofnode_write_u64() - Set an integer property of an ofnode
|
||||
*
|
||||
* @node: The node for whose string property should be set
|
||||
* @propname: The name of the string property to set
|
||||
* @value: The new value of the 64-bit integer property
|
||||
* Return: 0 if successful, -ve on error
|
||||
*/
|
||||
int ofnode_write_u64(ofnode node, const char *propname, u64 value);
|
||||
|
||||
/**
|
||||
* ofnode_write_bool() - Set a boolean property of an ofnode
|
||||
*
|
||||
|
|
|
@ -1009,7 +1009,8 @@ static int dm_test_ofnode_u32_array(struct unit_test_state *uts)
|
|||
}
|
||||
DM_TEST(dm_test_ofnode_u32_array, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
|
||||
|
||||
static int dm_test_ofnode_read_u64(struct unit_test_state *uts)
|
||||
/* test ofnode_read_u64() and ofnode_write_u64() */
|
||||
static int dm_test_ofnode_u64(struct unit_test_state *uts)
|
||||
{
|
||||
ofnode node;
|
||||
u64 val;
|
||||
|
@ -1018,6 +1019,10 @@ static int dm_test_ofnode_read_u64(struct unit_test_state *uts)
|
|||
ut_assert(ofnode_valid(node));
|
||||
ut_assertok(ofnode_read_u64(node, "int64-value", &val));
|
||||
ut_asserteq_64(0x1111222233334444, val);
|
||||
ut_assertok(ofnode_write_u64(node, "new-int64-value", 0x9876543210));
|
||||
ut_assertok(ofnode_read_u64(node, "new-int64-value", &val));
|
||||
ut_asserteq_64(0x9876543210, val);
|
||||
|
||||
ut_asserteq(-EINVAL, ofnode_read_u64(node, "missing", &val));
|
||||
|
||||
ut_assertok(ofnode_read_u64_index(node, "int64-array", 0, &val));
|
||||
|
@ -1028,9 +1033,15 @@ static int dm_test_ofnode_read_u64(struct unit_test_state *uts)
|
|||
ofnode_read_u64_index(node, "int64-array", 2, &val));
|
||||
ut_asserteq(-EINVAL, ofnode_read_u64_index(node, "missing", 0, &val));
|
||||
|
||||
ut_assertok(ofnode_write_u64(node, "int64-array", 0x9876543210));
|
||||
ut_assertok(ofnode_read_u64_index(node, "int64-array", 0, &val));
|
||||
ut_asserteq_64(0x9876543210, val);
|
||||
ut_asserteq(-EOVERFLOW,
|
||||
ofnode_read_u64_index(node, "int64-array", 1, &val));
|
||||
|
||||
return 0;
|
||||
}
|
||||
DM_TEST(dm_test_ofnode_read_u64, UT_TESTF_SCAN_FDT);
|
||||
DM_TEST(dm_test_ofnode_u64, UT_TESTF_SCAN_FDT);
|
||||
|
||||
static int dm_test_ofnode_add_subnode(struct unit_test_state *uts)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue