From: Heiko Stuebner <heiko@sntech.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 2/4] fdtdec: only create phandle if caller wants it in fdtdec_add_reserved_memory()
Date: Tue, 22 Oct 2019 21:04:26 +0200 [thread overview]
Message-ID: <20191022190428.14868-2-heiko@sntech.de> (raw)
In-Reply-To: <20191022190428.14868-1-heiko@sntech.de>
From: Heiko Stuebner <heiko.stuebner@theobroma-systems.com>
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>
---
changes in v2:
- update function comment
include/fdtdec.h | 2 +-
lib/fdtdec.c | 16 +++++++++-------
2 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/include/fdtdec.h b/include/fdtdec.h
index 54509a25ad..fe8e7770ec 100644
--- a/include/fdtdec.h
+++ b/include/fdtdec.h
@@ -1078,7 +1078,7 @@ static inline int fdtdec_set_phandle(void *blob, int node, uint32_t phandle)
* @param basename base name of the node to create
* @param carveout information about the carveout region
* @param phandlep return location for the phandle of the carveout region
- * can be NULL
+ * can be NULL if no phandle should be added
* @return 0 on success or a negative error code on failure
*/
int fdtdec_add_reserved_memory(void *blob, const char *basename,
diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index d7c3684145..c841aafa2a 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -1393,13 +1393,15 @@ int fdtdec_add_reserved_memory(void *blob, const char *basename,
if (node < 0)
return node;
- err = fdt_generate_phandle(blob, &phandle);
- if (err < 0)
- return err;
-
- err = fdtdec_set_phandle(blob, node, phandle);
- if (err < 0)
- return err;
+ if (phandlep) {
+ err = fdt_generate_phandle(blob, &phandle);
+ if (err < 0)
+ return err;
+
+ err = fdtdec_set_phandle(blob, node, phandle);
+ if (err < 0)
+ return err;
+ }
/* store one or two address cells */
if (na > 1)
--
2.23.0
next prev parent reply other threads:[~2019-10-22 19:04 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-22 19:04 [U-Boot] [PATCH v2 1/4] fdtdec: protect against another NULL phandlep in fdtdec_add_reserved_memory() Heiko Stuebner
2019-10-22 19:04 ` Heiko Stuebner [this message]
2019-10-30 1:48 ` [U-Boot] [PATCH v2 2/4] fdtdec: only create phandle if caller wants it " Simon Glass
2019-10-22 19:04 ` [U-Boot] [PATCH v2 3/4] image: fdt: copy possible optee nodes to a loaded devicetree Heiko Stuebner
2019-10-23 6:46 ` Jens Wiklander
2019-10-23 7:10 ` Patrick DELAUNAY
2019-10-23 8:32 ` Heiko Stübner
2019-10-23 15:53 ` Patrick DELAUNAY
2019-10-22 19:04 ` [U-Boot] [PATCH v2 4/4] tests: add OP-TEE test suite Heiko Stuebner
2019-10-30 1:48 ` Simon Glass
2019-10-30 1:48 ` [U-Boot] [PATCH v2 1/4] fdtdec: protect against another NULL phandlep in fdtdec_add_reserved_memory() Simon Glass
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191022190428.14868-2-heiko@sntech.de \
--to=heiko@sntech.de \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox