From 247970978d3de3e46537550e83137df586d9dee9 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Tue, 26 Sep 2023 08:14:37 -0600 Subject: [PATCH] dm: core: Reverse the argument order in ofnode_copy_props() Follow the order used by memcpy() as it may be less confusing. Signed-off-by: Simon Glass --- boot/vbe_request.c | 2 +- boot/vbe_simple_os.c | 2 +- drivers/core/ofnode.c | 2 +- include/dm/ofnode.h | 6 +++--- test/dm/ofnode.c | 9 ++++----- 5 files changed, 10 insertions(+), 11 deletions(-) diff --git a/boot/vbe_request.c b/boot/vbe_request.c index 2f218d4bf9..917251afa1 100644 --- a/boot/vbe_request.c +++ b/boot/vbe_request.c @@ -187,7 +187,7 @@ static int bootmeth_vbe_ft_fixup(void *ctx, struct event *event) ret = ofnode_add_subnode(dest_parent, name, &dest); if (ret && ret != -EEXIST) return log_msg_ret("add", ret); - ret = ofnode_copy_props(node, dest); + ret = ofnode_copy_props(dest, node); if (ret) return log_msg_ret("cp", ret); diff --git a/boot/vbe_simple_os.c b/boot/vbe_simple_os.c index 3285e438a5..84626cdeaf 100644 --- a/boot/vbe_simple_os.c +++ b/boot/vbe_simple_os.c @@ -94,7 +94,7 @@ static int bootmeth_vbe_simple_ft_fixup(void *ctx, struct event *event) /* Copy over the vbe properties for fwupd */ log_debug("Fixing up: %s\n", dev->name); - ret = ofnode_copy_props(dev_ofnode(dev), subnode); + ret = ofnode_copy_props(subnode, dev_ofnode(dev)); if (ret) return log_msg_ret("cp", ret); diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c index 2cafa7bca5..515396c62f 100644 --- a/drivers/core/ofnode.c +++ b/drivers/core/ofnode.c @@ -1731,7 +1731,7 @@ int ofnode_add_subnode(ofnode node, const char *name, ofnode *subnodep) return ret; /* 0 or -EEXIST */ } -int ofnode_copy_props(ofnode src, ofnode dst) +int ofnode_copy_props(ofnode dst, ofnode src) { struct ofprop prop; diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h index 06c969c61f..32917f6615 100644 --- a/include/dm/ofnode.h +++ b/include/dm/ofnode.h @@ -1598,7 +1598,7 @@ int ofnode_add_subnode(ofnode parent, const char *name, ofnode *nodep); /** * ofnode_copy_props() - copy all properties from one node to another * - * Makes a copy of all properties from the source note in the destination node. + * Makes a copy of all properties from the source node to the destination node. * Existing properties in the destination node remain unchanged, except that * any with the same name are overwritten, including changing the size of the * property. @@ -1606,9 +1606,9 @@ int ofnode_add_subnode(ofnode parent, const char *name, ofnode *nodep); * For livetree, properties are copied / allocated, so the source tree does not * need to be present afterwards. * + * @dst: Destination node to write properties to * @src: Source node to read properties from - * @dst: Destination node to write properties too */ -int ofnode_copy_props(ofnode src, ofnode dst); +int ofnode_copy_props(ofnode dst, ofnode src); #endif diff --git a/test/dm/ofnode.c b/test/dm/ofnode.c index d71faac0ee..dee71ee5e5 100644 --- a/test/dm/ofnode.c +++ b/test/dm/ofnode.c @@ -1209,12 +1209,11 @@ static int dm_test_ofnode_too_many(struct unit_test_state *uts) } DM_TEST(dm_test_ofnode_too_many, UT_TESTF_SCAN_FDT); -static int check_copy_props(struct unit_test_state *uts, ofnode src, - ofnode dst) +static int check_copy_props(struct unit_test_state *uts, ofnode dst, ofnode src) { u32 reg[2], val; - ut_assertok(ofnode_copy_props(src, dst)); + ut_assertok(ofnode_copy_props(dst, src)); ut_assertok(ofnode_read_u32(dst, "ping-expect", &val)); ut_asserteq(3, val); @@ -1246,7 +1245,7 @@ static int dm_test_ofnode_copy_props(struct unit_test_state *uts) src = ofnode_path("/b-test"); dst = ofnode_path("/some-bus"); - ut_assertok(check_copy_props(uts, src, dst)); + ut_assertok(check_copy_props(uts, dst, src)); /* check a property that is in the destination already */ ut_asserteq_str("mux0", ofnode_read_string(dst, "mux-control-names")); @@ -1262,7 +1261,7 @@ static int dm_test_ofnode_copy_props_ot(struct unit_test_state *uts) src = ofnode_path("/b-test"); dst = oftree_path(otree, "/node/subnode2"); - ut_assertok(check_copy_props(uts, src, dst)); + ut_assertok(check_copy_props(uts, dst, src)); return 0; } -- 2.39.5