diff options
author | Simon Glass <sjg@chromium.org> | 2018-10-01 21:22:08 +0300 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2018-10-09 13:40:27 +0300 |
commit | e6c5c94a79d9e1dd20f869a3169bf2be00d53d14 (patch) | |
tree | 658f9ce8514a3217360cc91bff053359e3583964 /drivers/core/of_extra.c | |
parent | cdb6aa0afb52da34306c4339f2f4d6cbd3b0ad02 (diff) | |
download | u-boot-e6c5c94a79d9e1dd20f869a3169bf2be00d53d14.tar.xz |
dm: core: Update ofnode to read binman-style flash entry
At present ofnode_read_fmap_entry() reads a flash map entry in a format
which is not supported by binman. To allow use to use binman-format
descriptions, update this function.
Also add a simple test.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/core/of_extra.c')
-rw-r--r-- | drivers/core/of_extra.c | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/drivers/core/of_extra.c b/drivers/core/of_extra.c index aa48917ddd..f1f393c359 100644 --- a/drivers/core/of_extra.c +++ b/drivers/core/of_extra.c @@ -13,19 +13,30 @@ int ofnode_read_fmap_entry(ofnode node, struct fmap_entry *entry) { const char *prop; - u32 reg[2]; - if (ofnode_read_u32_array(node, "reg", reg, 2)) { - debug("Node '%s' has bad/missing 'reg' property\n", + if (ofnode_read_u32(node, "image-pos", &entry->offset)) { + debug("Node '%s' has bad/missing 'image-pos' property\n", ofnode_get_name(node)); - return -log_ret(ENOENT); + return log_ret(-ENOENT); + } + if (ofnode_read_u32(node, "size", &entry->length)) { + debug("Node '%s' has bad/missing 'size' property\n", + ofnode_get_name(node)); + return log_ret(-ENOENT); } - entry->offset = reg[0]; - entry->length = reg[1]; entry->used = ofnode_read_s32_default(node, "used", entry->length); prop = ofnode_read_string(node, "compress"); - entry->compress_algo = prop && !strcmp(prop, "lzo") ? - FMAP_COMPRESS_LZO : FMAP_COMPRESS_NONE; + if (prop) { + if (!strcmp(prop, "lz4")) + entry->compress_algo = FMAP_COMPRESS_LZ4; + else + return log_msg_ret("Unknown compression algo", + -EINVAL); + } else { + entry->compress_algo = FMAP_COMPRESS_NONE; + } + entry->unc_length = ofnode_read_s32_default(node, "uncomp-size", + entry->length); prop = ofnode_read_string(node, "hash"); if (prop) entry->hash_size = strlen(prop); |