diff options
author | Dario Binacchi <dariobin@libero.it> | 2020-03-29 18:04:42 +0200 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2020-04-16 08:07:58 -0600 |
commit | 59006608d65b242b19176f1a1fdeeb99391654d2 (patch) | |
tree | a1ee79c9c96125e0589a60651fe5298d86161f75 /drivers/core/ofnode.c | |
parent | 4bb7075c830c6f4e4512fe0277ff1f08c5a9e084 (diff) | |
download | u-boot-59006608d65b242b19176f1a1fdeeb99391654d2.tar.gz |
dm: core: refactor functions reading an u32 from dt
Now reading a 32 bit value from a device-tree property can be expressed
as reading the first element of an array with a single value.
Signed-off-by: Dario Binacchi <dariobin@libero.it>
Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/core/ofnode.c')
-rw-r--r-- | drivers/core/ofnode.c | 23 |
1 files changed, 2 insertions, 21 deletions
diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c index 5bc3b02996..b0be7cbe19 100644 --- a/drivers/core/ofnode.c +++ b/drivers/core/ofnode.c @@ -18,32 +18,13 @@ int ofnode_read_u32(ofnode node, const char *propname, u32 *outp) { - assert(ofnode_valid(node)); - debug("%s: %s: ", __func__, propname); - - if (ofnode_is_np(node)) { - return of_read_u32(ofnode_to_np(node), propname, outp); - } else { - const fdt32_t *cell; - int len; - - cell = fdt_getprop(gd->fdt_blob, ofnode_to_offset(node), - propname, &len); - if (!cell || len < sizeof(int)) { - debug("(not found)\n"); - return -EINVAL; - } - *outp = fdt32_to_cpu(cell[0]); - } - debug("%#x (%d)\n", *outp, *outp); - - return 0; + return ofnode_read_u32_index(node, propname, 0, outp); } u32 ofnode_read_u32_default(ofnode node, const char *propname, u32 def) { assert(ofnode_valid(node)); - ofnode_read_u32(node, propname, &def); + ofnode_read_u32_index(node, propname, 0, &def); return def; } |