diff options
author | Simon Glass <sjg@chromium.org> | 2023-10-01 19:13:28 -0600 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2023-10-11 15:43:55 -0400 |
commit | 117617c7c1d8f82304e019e5a2c7f1c23f78da8f (patch) | |
tree | 0e2e249afb34ca8f52aaa817a4cfade96cf26543 | |
parent | d88edd2bda2150b253fac702dd26ec4c01ccf988 (diff) | |
download | u-boot-117617c7c1d8f82304e019e5a2c7f1c23f78da8f.zip u-boot-117617c7c1d8f82304e019e5a2c7f1c23f78da8f.tar.gz u-boot-117617c7c1d8f82304e019e5a2c7f1c23f78da8f.tar.bz2 |
expo: Add a function to write a property to a devicetree
When the devicetree is too small for the property being written, we need
to expand the devicetree and retry the write.
Put this logic into a function so it can be reused.
Signed-off-by: Simon Glass <sjg@chromium.org>
-rw-r--r-- | boot/cedit.c | 38 |
1 files changed, 26 insertions, 12 deletions
diff --git a/boot/cedit.c b/boot/cedit.c index b7329c3..bb194af 100644 --- a/boot/cedit.c +++ b/boot/cedit.c @@ -269,6 +269,28 @@ static int get_cur_menuitem_text(const struct scene_obj_menu *menu, return 0; } +static int write_dt_string(struct abuf *buf, const char *name, const char *str) +{ + int ret, i; + + /* write the text of the current item */ + ret = -EAGAIN; + for (i = 0; ret && i < 2; i++) { + ret = fdt_property_string(abuf_data(buf), name, str); + if (!i) { + ret = check_space(ret, buf); + if (ret) + return log_msg_ret("rs2", -ENOMEM); + } + } + + /* this should not happen */ + if (ret) + return log_msg_ret("str", -EFAULT); + + return 0; +} + static int h_write_settings(struct scene_obj *obj, void *vpriv) { struct cedit_iter_priv *priv = vpriv; @@ -285,6 +307,7 @@ static int h_write_settings(struct scene_obj *obj, void *vpriv) char name[80]; int ret, i; + /* write the ID of the current item */ menu = (struct scene_obj_menu *)obj; ret = -EAGAIN; for (i = 0; ret && i < 2; i++) { @@ -304,20 +327,11 @@ static int h_write_settings(struct scene_obj *obj, void *vpriv) if (ret) return log_msg_ret("mis", ret); + /* write the text of the current item */ snprintf(name, sizeof(name), "%s-str", obj->name); - ret = -EAGAIN; - for (i = 0; ret && i < 2; i++) { - ret = fdt_property_string(abuf_data(buf), name, str); - if (!i) { - ret = check_space(ret, buf); - if (ret) - return log_msg_ret("rs2", -ENOMEM); - } - } - - /* this should not happen */ + ret = write_dt_string(buf, name, str); if (ret) - return log_msg_ret("wr2", -EFAULT); + return log_msg_ret("wr2", ret); break; } |