diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2018-01-29 10:35:05 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2018-02-08 08:55:58 +0100 |
commit | 174fae19b89c6fac49bbe5de0fb4f57498ff9aac (patch) | |
tree | e5537e8ef848129f6b25e97efa7c41bb2cd0adeb /common | |
parent | d2411eaf76ef52f2ccf7f3e39226082fbdd3dcd1 (diff) | |
download | barebox-174fae19b89c6fac49bbe5de0fb4f57498ff9aac.tar.gz barebox-174fae19b89c6fac49bbe5de0fb4f57498ff9aac.tar.xz |
FIT: store device_nodes in fit_handle
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>
Diffstat (limited to 'common')
-rw-r--r-- | common/image-fit.c | 20 |
1 files changed, 12 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); |