[PATCH v3 1/8] tool: Move ALIGN_MASK to header as common MACRO

Punit Agrawal punit1.agrawal at toshiba.co.jp
Fri Mar 27 04:27:09 CET 2020


Hi Kever,

Kever Yang <kever.yang at rock-chips.com> writes:

> The ALIGN code is need by many files who need handle structure or image
> align, so move the macro to imagetool.h file.
>
> Signed-off-by: Kever Yang <kever.yang at rock-chips.com>

Thanks for updating the patches.

For the series - 

Reviewed-by: Punit Agrawal <punit1.agrawal at toshiba.co.jp>

Thanks,
Punit

> ---
>
> Changes in v3: None
> Changes in v2: None
>
>  include/imx8image.h | 1 -
>  tools/ifwitool.c    | 4 +---
>  tools/imagetool.h   | 3 +++
>  tools/imx8mimage.c  | 2 --
>  tools/mksunxiboot.c | 4 +---
>  5 files changed, 5 insertions(+), 9 deletions(-)
>
> diff --git a/include/imx8image.h b/include/imx8image.h
> index 68ec9f5fcd..00c614ab6c 100644
> --- a/include/imx8image.h
> +++ b/include/imx8image.h
> @@ -11,7 +11,6 @@
>  #include <image.h>
>  #include <inttypes.h>
>  #include "imagetool.h"
> -#include "linux/kernel.h"
>  
>  #define __packed   __attribute__((packed))
>  
> diff --git a/tools/ifwitool.c b/tools/ifwitool.c
> index 543e9d4e70..b2b06cc921 100644
> --- a/tools/ifwitool.c
> +++ b/tools/ifwitool.c
> @@ -8,15 +8,13 @@
>  #include <assert.h>
>  #include <stdbool.h>
>  #include <getopt.h>
> +#include "imagetool.h"
>  #include "os_support.h"
>  
>  #ifndef __packed
>  #define __packed		__attribute__((packed))
>  #endif
>  #define KiB			1024
> -#define ALIGN(x, a)		__ALIGN_MASK((x), (typeof(x))(a) - 1)
> -#define __ALIGN_MASK(x, mask)	(((x) + (mask)) & ~(mask))
> -#define ARRAY_SIZE(x)		(sizeof(x) / sizeof((x)[0]))
>  
>  /*
>   * min()/max()/clamp() macros that also do
> diff --git a/tools/imagetool.h b/tools/imagetool.h
> index e1c778b0df..81e5cd0c5c 100644
> --- a/tools/imagetool.h
> +++ b/tools/imagetool.h
> @@ -25,6 +25,9 @@
>  
>  #define ARRAY_SIZE(x)		(sizeof(x) / sizeof((x)[0]))
>  
> +#define __ALIGN_MASK(x, mask)	(((x) + (mask)) & ~(mask))
> +#define ALIGN(x, a)		__ALIGN_MASK((x), (typeof(x))(a) - 1)
> +
>  #define IH_ARCH_DEFAULT		IH_ARCH_INVALID
>  
>  /* Information about a file that needs to be placed into the FIT */
> diff --git a/tools/imx8mimage.c b/tools/imx8mimage.c
> index 2b0d946a7d..7defb13962 100644
> --- a/tools/imx8mimage.c
> +++ b/tools/imx8mimage.c
> @@ -32,8 +32,6 @@ static uint32_t rom_version = ROM_V1;
>  
>  #define HDMI_FW_SIZE		0x17000 /* Use Last 0x1000 for IVT and CSF */
>  #define ALIGN_SIZE		0x1000
> -#define ALIGN(x,a)	__ALIGN_MASK((x), (__typeof__(x))(a) - 1, a)
> -#define __ALIGN_MASK(x,mask,mask2) (((x) + (mask)) / (mask2) * (mask2))
>  
>  static uint32_t get_cfg_value(char *token, char *name,  int linenr)
>  {
> diff --git a/tools/mksunxiboot.c b/tools/mksunxiboot.c
> index 1c8701e75e..a18c9d98bc 100644
> --- a/tools/mksunxiboot.c
> +++ b/tools/mksunxiboot.c
> @@ -14,6 +14,7 @@
>  #include <errno.h>
>  #include <sys/types.h>
>  #include <sys/stat.h>
> +#include "imagetool.h"
>  #include "../arch/arm/include/asm/arch-sunxi/spl.h"
>  
>  #define STAMP_VALUE                     0x5F0A6C39
> @@ -44,9 +45,6 @@ int gen_check_sum(struct boot_file_head *head_p)
>  	return 0;
>  }
>  
> -#define ALIGN(x, a) __ALIGN_MASK((x), (typeof(x))(a)-1)
> -#define __ALIGN_MASK(x, mask) (((x)+(mask))&~(mask))
> -
>  #define SUNXI_SRAM_SIZE 0x8000	/* SoC with smaller size are limited before */
>  #define SRAM_LOAD_MAX_SIZE (SUNXI_SRAM_SIZE - sizeof(struct boot_file_head))


More information about the U-Boot mailing list