From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 4/8] FIT: store device_nodes in fit_handle
Date: Wed, 31 Jan 2018 12:11:12 +0100 [thread overview]
Message-ID: <20180131111116.9638-5-s.hauer@pengutronix.de> (raw)
In-Reply-To: <20180131111116.9638-1-s.hauer@pengutronix.de>
We need the /images and /configurations nodes more than once,
so store them in the fit_handle rather than searching for them
each time again.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
common/image-fit.c | 20 ++++++++++++--------
include/image-fit.h | 2 ++
2 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/common/image-fit.c b/common/image-fit.c
index 138696ab78..21b547a1da 100644
--- a/common/image-fit.c
+++ b/common/image-fit.c
@@ -416,7 +416,7 @@ int fit_open_image(struct fit_handle *handle, void *configuration,
const char *name, const void **outdata,
unsigned long *outsize)
{
- struct device_node *image = NULL, *hash;
+ struct device_node *image, *hash;
const char *unit, *type = NULL, *desc= "(no description)";
const void *data;
int data_len;
@@ -431,11 +431,7 @@ int fit_open_image(struct fit_handle *handle, void *configuration,
return -ENOENT;
}
- image = of_get_child_by_name(handle->root, "images");
- if (!image)
- return -ENOENT;
-
- image = of_get_child_by_name(image, unit);
+ image = of_get_child_by_name(handle->images, unit);
if (!image)
return -ENOENT;
@@ -561,11 +557,10 @@ default_unit:
*/
void *fit_open_configuration(struct fit_handle *handle, const char *name)
{
- struct device_node *conf_node = NULL;
+ struct device_node *conf_node = handle->configurations;
const char *unit, *desc = "(no description)";
int ret;
- conf_node = of_get_child_by_name(handle->root, "configurations");
if (!conf_node)
return ERR_PTR(-ENOENT);
@@ -622,6 +617,15 @@ struct fit_handle *fit_open(const char *filename, bool verbose,
handle->root = root;
handle->verify = verify;
+ handle->images = of_get_child_by_name(handle->root, "images");
+ if (!handle->images) {
+ ret = -ENOENT;
+ goto err;
+ }
+
+ handle->configurations = of_get_child_by_name(handle->root,
+ "configurations");
+
of_property_read_string(handle->root, "description", &desc);
pr_info("'%s': %s\n", filename, desc);
diff --git a/include/image-fit.h b/include/image-fit.h
index 31e23b235a..79b8101b83 100644
--- a/include/image-fit.h
+++ b/include/image-fit.h
@@ -29,6 +29,8 @@ struct fit_handle {
enum bootm_verify verify;
struct device_node *root;
+ struct device_node *images;
+ struct device_node *configurations;
};
struct fit_handle *fit_open(const char *filename, bool verbose,
--
2.15.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2018-01-31 11:11 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-31 11:11 [PATCH 0/8] FIT: Add support for opening images without a /configuration/ Sascha Hauer
2018-01-31 11:11 ` [PATCH 1/8] bootm: FIT: do not depend on FIT pre-opened images Sascha Hauer
2018-01-31 11:11 ` [PATCH 2/8] FIT: Do not pre-open images Sascha Hauer
2018-01-31 11:11 ` [PATCH 3/8] FIT: Let user specify the configuration to use Sascha Hauer
2018-01-31 11:11 ` Sascha Hauer [this message]
2018-01-31 11:11 ` [PATCH 5/8] FIT: move handle->verify check to fit_verify_hash() Sascha Hauer
2018-01-31 11:11 ` [PATCH 6/8] FIT: factor out some helper functions Sascha Hauer
2018-01-31 11:11 ` [PATCH 7/8] FIT: Implement opening images with no configuration Sascha Hauer
2018-01-31 11:11 ` [PATCH 8/8] FIT: Allow to open buffer as FIT image Sascha Hauer
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=20180131111116.9638-5-s.hauer@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
/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