Commit 357d2ceba0354e29462ac25924f5e42623c22b5b
Committed by
Simon Glass
1 parent
086336a225
Exists in
smarc_8mq_lf_v2020.04
and in
9 other branches
fdtdec: only create phandle if caller wants it in fdtdec_add_reserved_memory()
The phandlep pointer returning the phandle to the caller is optional and if it is not set when calling fdtdec_add_reserved_memory() it is highly likely that the caller is not interested in a phandle to the created reserved-memory area and really just wants that area added. So just don't create a phandle in that case. Signed-off-by: Heiko Stuebner <heiko.stuebner@theobroma-systems.com> Reviewed-by: Simon Glass <sjg@chromium.org>
Showing 2 changed files with 10 additions and 8 deletions Side-by-side Diff
include/fdtdec.h
... | ... | @@ -1061,7 +1061,7 @@ |
1061 | 1061 | * @param basename base name of the node to create |
1062 | 1062 | * @param carveout information about the carveout region |
1063 | 1063 | * @param phandlep return location for the phandle of the carveout region |
1064 | - * can be NULL | |
1064 | + * can be NULL if no phandle should be added | |
1065 | 1065 | * @return 0 on success or a negative error code on failure |
1066 | 1066 | */ |
1067 | 1067 | int fdtdec_add_reserved_memory(void *blob, const char *basename, |
lib/fdtdec.c
... | ... | @@ -1339,13 +1339,15 @@ |
1339 | 1339 | if (node < 0) |
1340 | 1340 | return node; |
1341 | 1341 | |
1342 | - err = fdt_generate_phandle(blob, &phandle); | |
1343 | - if (err < 0) | |
1344 | - return err; | |
1342 | + if (phandlep) { | |
1343 | + err = fdt_generate_phandle(blob, &phandle); | |
1344 | + if (err < 0) | |
1345 | + return err; | |
1345 | 1346 | |
1346 | - err = fdtdec_set_phandle(blob, node, phandle); | |
1347 | - if (err < 0) | |
1348 | - return err; | |
1347 | + err = fdtdec_set_phandle(blob, node, phandle); | |
1348 | + if (err < 0) | |
1349 | + return err; | |
1350 | + } | |
1349 | 1351 | |
1350 | 1352 | /* store one or two address cells */ |
1351 | 1353 | if (na > 1) |