Re: [PATCH v2 11/11] FIT: add support to cache opened fit images

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jun 13, 2024 at 02:58:18PM +0200, Marco Felsch wrote:
> Cache the FIT image fit_open() calls to avoid loading the same FIT image
> twice. This is very useful if the same FIT image is used to provide the
> base devicetree, kernel and initrd as well as devicetree overlays.
> 
> Signed-off-by: Marco Felsch <m.felsch@xxxxxxxxxxxxxx>
> ---
>  common/image-fit.c  | 38 +++++++++++++++++++++++++++++++++++++-
>  include/image-fit.h |  4 ++++
>  2 files changed, 41 insertions(+), 1 deletion(-)
> 
> diff --git a/common/image-fit.c b/common/image-fit.c
> index c5c88ebe4c1e..061825f5f22c 100644
> --- a/common/image-fit.c
> +++ b/common/image-fit.c
> @@ -18,6 +18,8 @@
>  #include <fnmatch.h>
>  #include <malloc.h>
>  #include <linux/ctype.h>
> +#include <linux/minmax.h>
> +#include <linux/refcount.h>
>  #include <asm/byteorder.h>
>  #include <errno.h>
>  #include <linux/err.h>
> @@ -34,6 +36,8 @@
>  #define CHECK_LEVEL_SIG 2
>  #define CHECK_LEVEL_MAX 3
>  
> +LIST_HEAD(open_fits);

Should be static

> +
>  static uint32_t dt_struct_advance(struct fdt_header *f, uint32_t dt, int size)
>  {
>  	dt += size;
> @@ -861,6 +865,22 @@ void *fit_open_configuration(struct fit_handle *handle, const char *name)
>  	return conf_node;
>  }
>  
> +static struct fit_handle *fit_get_handle(const char *filename)
> +{
> +	size_t query_len = strlen(filename);
> +	struct fit_handle *handle;
> +
> +	list_for_each_entry(handle, &open_fits, entry) {
> +		size_t len = strlen(handle->filename);
> +
> +		len = min(len, query_len);
> +		if (!strncmp(filename, handle->filename, len))
> +			return handle;

Why not plain strcmp() here?

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |




[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux