
The current name is quite confusing. Mostly this struct holds function pointers, not parameters. Rename it to imgtool_funcs, so that is has the same prefix as imgtool (introduced in the next patch) and it is clear that it provides functions. Signed-off-by: Simon Glass <sjg@chromium.org> --- tools/aisimage.c | 4 ++-- tools/atmelimage.c | 2 +- tools/dumpimage.c | 6 +++--- tools/imagetool.c | 20 ++++++++++---------- tools/imagetool.h | 28 +++++++++++++--------------- tools/imximage.c | 2 +- tools/kwbimage.c | 2 +- tools/mkimage.c | 6 +++--- tools/mtk_image.c | 2 +- tools/mxsimage.c | 4 ++-- tools/renesas_spkgimage.c | 2 +- tools/rkcommon.c | 2 +- tools/rkcommon.h | 2 +- tools/rkspi.c | 2 +- tools/sfspl.c | 2 +- tools/socfpgaimage.c | 6 +++--- tools/sunxi_egon.c | 2 +- tools/sunxi_toc0.c | 2 +- tools/zynqmpimage.c | 2 +- 19 files changed, 48 insertions(+), 50 deletions(-) diff --git a/tools/aisimage.c b/tools/aisimage.c index c5b33b559b0..697b3c0bad7 100644 --- a/tools/aisimage.c +++ b/tools/aisimage.c @@ -157,7 +157,7 @@ static void aisimage_print_header(const void *hdr, struct image_tool_params *par } static uint32_t *ais_insert_cmd_header(uint32_t cmd, uint32_t nargs, - uint32_t *parms, struct image_type_params *tparams, + uint32_t *parms, struct imgtool_funcs *tparams, uint32_t *ptr) { int i; @@ -252,7 +252,7 @@ static uint32_t *ais_copy_image(struct image_tool_params *params, } static int aisimage_generate(struct image_tool_params *params, - struct image_type_params *tparams) + struct imgtool_funcs *tparams) { FILE *fd = NULL; char *line = NULL; diff --git a/tools/atmelimage.c b/tools/atmelimage.c index 6a2d9d8feab..e1909f39c45 100644 --- a/tools/atmelimage.c +++ b/tools/atmelimage.c @@ -238,7 +238,7 @@ static int atmel_check_params(struct image_tool_params *params) } static int atmel_vrec_header(struct image_tool_params *params, - struct image_type_params *tparams) + struct imgtool_funcs *tparams) { uint32_t tmp; size_t pos; diff --git a/tools/dumpimage.c b/tools/dumpimage.c index 4791dd0dfe1..b15aee934c9 100644 --- a/tools/dumpimage.c +++ b/tools/dumpimage.c @@ -25,8 +25,8 @@ static struct image_tool_params params; * returns negative if input image format does not match with any of * supported image types */ -static int dumpimage_extract_subimage(struct image_type_params *tparams, - void *ptr, struct stat *sbuf) +static int dumpimage_extract_subimage(struct imgtool_funcs *tparams, + void *ptr, struct stat *sbuf) { int retval = -1; @@ -68,7 +68,7 @@ int main(int argc, char **argv) struct stat sbuf; char *ptr; int retval = EXIT_SUCCESS; - struct image_type_params *tparams = NULL; + struct imgtool_funcs *tparams = NULL; params.cmdname = *argv; diff --git a/tools/imagetool.c b/tools/imagetool.c index b293211cf88..b36b8d735a4 100644 --- a/tools/imagetool.c +++ b/tools/imagetool.c @@ -9,13 +9,13 @@ #include <image.h> -struct image_type_params *imagetool_get_type(int type) +struct imgtool_funcs *imagetool_get_type(int type) { - struct image_type_params **curr; + struct imgtool_funcs **curr; INIT_SECTION(image_type); - struct image_type_params **start = __start_image_type; - struct image_type_params **end = __stop_image_type; + struct imgtool_funcs **start = __start_image_type; + struct imgtool_funcs **end = __stop_image_type; for (curr = start; curr != end; curr++) { if ((*curr)->check_image_type) { @@ -29,21 +29,21 @@ struct image_type_params *imagetool_get_type(int type) static int imagetool_verify_print_header_by_type( void *ptr, struct stat *sbuf, - struct image_type_params *tparams, + struct imgtool_funcs *tparams, struct image_tool_params *params); int imagetool_verify_print_header( void *ptr, struct stat *sbuf, - struct image_type_params *tparams, + struct imgtool_funcs *tparams, struct image_tool_params *params) { int retval = -1; - struct image_type_params **curr; + struct imgtool_funcs **curr; INIT_SECTION(image_type); - struct image_type_params **start = __start_image_type; - struct image_type_params **end = __stop_image_type; + struct imgtool_funcs **start = __start_image_type; + struct imgtool_funcs **end = __stop_image_type; if (tparams) return imagetool_verify_print_header_by_type(ptr, sbuf, tparams, params); @@ -88,7 +88,7 @@ int imagetool_verify_print_header( static int imagetool_verify_print_header_by_type( void *ptr, struct stat *sbuf, - struct image_type_params *tparams, + struct imgtool_funcs *tparams, struct image_tool_params *params) { int retval = -1; diff --git a/tools/imagetool.h b/tools/imagetool.h index 57be608210a..3cbb053e42b 100644 --- a/tools/imagetool.h +++ b/tools/imagetool.h @@ -101,10 +101,8 @@ struct image_tool_params { struct image_summary summary; /* results of signing process */ }; -/* - * image type specific variables and callback functions - */ -struct image_type_params { +/** struct imgtool_funcs - image-type-specific variables and callbacks */ +struct imgtool_funcs { /* name is an identification tag string for added support */ char *name; /* @@ -163,13 +161,13 @@ struct image_type_params { /* * This callback function will be executed for variable size record * It is expected to build this header in memory and return its length - * and a pointer to it by using image_type_params.header_size and - * image_type_params.hdr. The return value shall indicate if an + * and a pointer to it by using imgtool_funcs.header_size and + * imgtool_funcs.hdr. The return value shall indicate if an * additional padding should be used when copying the data image * by returning the padding length. */ - int (*vrec_header) (struct image_tool_params *, - struct image_type_params *); + int (*vrec_header)(struct image_tool_params *, + struct imgtool_funcs *funcs); }; /** @@ -179,11 +177,11 @@ struct image_type_params { * checks the input type for each supported image type * * if successful, - * returns respective image_type_params pointer if success + * returns respective imgtool_funcs pointer if success * if input type_id is not supported by any of image_type_support * returns NULL */ -struct image_type_params *imagetool_get_type(int type); +struct imgtool_funcs *imagetool_get_type(int type); /* * imagetool_verify_print_header() - verifies the image header @@ -203,7 +201,7 @@ struct image_type_params *imagetool_get_type(int type); int imagetool_verify_print_header( void *ptr, struct stat *sbuf, - struct image_type_params *tparams, + struct imgtool_funcs *tparams, struct image_tool_params *params); /** @@ -286,14 +284,14 @@ int rockchip_copy_image(int fd, struct image_tool_params *mparams); } while (0) #define SECTION(name) __attribute__((section("__DATA, " #name))) -struct image_type_params **__start_image_type, **__stop_image_type; +struct imgtool_funcs **__start_image_type, **__stop_image_type; #else #define INIT_SECTION(name) /* no-op for ELF */ #define SECTION(name) __attribute__((section(#name))) /* We construct a table of pointers in an ELF section (pointers generally * go unpadded by gcc). ld creates boundary syms for us. */ -extern struct image_type_params *__start_image_type[], *__stop_image_type[]; +extern struct imgtool_funcs *__start_image_type[], *__stop_image_type[]; #endif /* __MACH__ */ #if !defined(__used) @@ -318,7 +316,7 @@ extern struct image_type_params *__start_image_type[], *__stop_image_type[]; _fflag_handle, \ _vrec_header \ ) \ - static struct image_type_params __cat(image_type_, _id) = \ + static struct imgtool_funcs __cat(image_type_, _id) = \ { \ .name = _name, \ .header_size = _header_size, \ @@ -332,7 +330,7 @@ extern struct image_type_params *__start_image_type[], *__stop_image_type[]; .fflag_handle = _fflag_handle, \ .vrec_header = _vrec_header \ }; \ - static struct image_type_params *SECTION(image_type) __used \ + static struct imgtool_funcs *SECTION(image_type) __used \ __cat(image_type_ptr_, _id) = &__cat(image_type_, _id) #endif /* _IMAGETOOL_H_ */ diff --git a/tools/imximage.c b/tools/imximage.c index 55231caf8f3..7a5dde617d9 100644 --- a/tools/imximage.c +++ b/tools/imximage.c @@ -967,7 +967,7 @@ static void generate_fspi_header(int ifd) #endif static int imximage_generate(struct image_tool_params *params, - struct image_type_params *tparams) + struct imgtool_funcs *tparams) { struct imx_header *imxhdr; size_t alloc_len; diff --git a/tools/kwbimage.c b/tools/kwbimage.c index 3dcf5ba66b9..d6c7206868e 100644 --- a/tools/kwbimage.c +++ b/tools/kwbimage.c @@ -2160,7 +2160,7 @@ static int kwbimage_verify_header(unsigned char *ptr, int image_size, } static int kwbimage_generate(struct image_tool_params *params, - struct image_type_params *tparams) + struct imgtool_funcs *tparams) { FILE *fcfg; struct stat s; diff --git a/tools/mkimage.c b/tools/mkimage.c index 8a132362a5b..6e50254452d 100644 --- a/tools/mkimage.c +++ b/tools/mkimage.c @@ -414,7 +414,7 @@ static int process_args(int argc, char **argv) return 0; } -static void verify_image(const struct image_type_params *tparams) +static void verify_image(const struct imgtool_funcs *tparams) { struct stat sbuf; void *ptr; @@ -462,7 +462,7 @@ static void copy_file(int ifd, const char *datafile, int pad) uint8_t zeros[4096]; int offset = 0; int size, ret; - struct image_type_params *tparams = imagetool_get_type(params.type); + struct imgtool_funcs *tparams = imagetool_get_type(params.type); memset(zeros, 0, sizeof(zeros)); @@ -595,7 +595,7 @@ void copy_datafile(int ifd, char *file) */ static int run_mkimage(void) { - struct image_type_params *tparams = NULL; + struct imgtool_funcs *tparams = NULL; struct stat sbuf; int pad_len = 0; int retval = 0; diff --git a/tools/mtk_image.c b/tools/mtk_image.c index 1b1aed59924..8a22b4ef789 100644 --- a/tools/mtk_image.c +++ b/tools/mtk_image.c @@ -244,7 +244,7 @@ static int mtk_image_check_params(struct image_tool_params *params) } static int mtk_image_vrec_header(struct image_tool_params *params, - struct image_type_params *tparams) + struct imgtool_funcs *tparams) { if (use_lk_hdr) { tparams->header_size = sizeof(union lk_hdr); diff --git a/tools/mxsimage.c b/tools/mxsimage.c index 42df0698ca2..45c6e3624c9 100644 --- a/tools/mxsimage.c +++ b/tools/mxsimage.c @@ -2245,7 +2245,7 @@ static void mxsimage_print_header(const void *hdr, struct image_tool_params *par } static int sb_build_image(struct sb_image_ctx *ictx, - struct image_type_params *tparams) + struct imgtool_funcs *tparams) { struct sb_boot_image_header *sb_header = &ictx->payload; struct sb_section_ctx *sctx; @@ -2315,7 +2315,7 @@ static int sb_build_image(struct sb_image_ctx *ictx, } static int mxsimage_generate(struct image_tool_params *params, - struct image_type_params *tparams) + struct imgtool_funcs *tparams) { int ret; struct sb_image_ctx ctx; diff --git a/tools/renesas_spkgimage.c b/tools/renesas_spkgimage.c index ce3b2b28ae7..ed80aec3c6b 100644 --- a/tools/renesas_spkgimage.c +++ b/tools/renesas_spkgimage.c @@ -217,7 +217,7 @@ static inline uint32_t roundup(uint32_t x, uint32_t y) } static int spkgimage_vrec_header(struct image_tool_params *params, - struct image_type_params *tparams) + struct imgtool_funcs *tparams) { struct stat s; struct spkg_file *out_buf; diff --git a/tools/rkcommon.c b/tools/rkcommon.c index a0caa029cc0..f938b524329 100644 --- a/tools/rkcommon.c +++ b/tools/rkcommon.c @@ -544,7 +544,7 @@ void rkcommon_rc4_encode_spl(void *buf, unsigned int offset, unsigned int size) } int rkcommon_vrec_header(struct image_tool_params *params, - struct image_type_params *tparams) + struct imgtool_funcs *tparams) { /* * The SPL image looks as follows: diff --git a/tools/rkcommon.h b/tools/rkcommon.h index 5d2770a80f1..792a046c7af 100644 --- a/tools/rkcommon.h +++ b/tools/rkcommon.h @@ -102,6 +102,6 @@ void rkcommon_rc4_encode_spl(void *buf, unsigned int offset, unsigned int size); * Return: 0 (always) */ int rkcommon_vrec_header(struct image_tool_params *params, - struct image_type_params *tparams); + struct imgtool_funcs *tparams); #endif diff --git a/tools/rkspi.c b/tools/rkspi.c index f2530f7bde3..284d9dbc02c 100644 --- a/tools/rkspi.c +++ b/tools/rkspi.c @@ -58,7 +58,7 @@ static int rkspi_check_image_type(uint8_t type) * (i.e. only the first 2K of each 4K sector is used). */ static int rkspi_vrec_header(struct image_tool_params *params, - struct image_type_params *tparams) + struct imgtool_funcs *tparams) { rkcommon_vrec_header(params, tparams); diff --git a/tools/sfspl.c b/tools/sfspl.c index 516e96e8dd9..e0c15243c9d 100644 --- a/tools/sfspl.c +++ b/tools/sfspl.c @@ -153,7 +153,7 @@ static void sfspl_set_header(void *buf, struct stat *sbuf, int infd, } static int sfspl_vrec_header(struct image_tool_params *params, - struct image_type_params *tparams) + struct imgtool_funcs *tparams) { tparams->hdr = calloc(sizeof(struct spl_hdr), 1); diff --git a/tools/socfpgaimage.c b/tools/socfpgaimage.c index 953dfeed4d5..64c5f498355 100644 --- a/tools/socfpgaimage.c +++ b/tools/socfpgaimage.c @@ -398,7 +398,7 @@ static int sfp_fake_header_size(unsigned int size, uint8_t ver) } static int sfp_vrec_header(struct image_tool_params *params, - struct image_type_params *tparams, uint8_t ver) + struct imgtool_funcs *tparams, uint8_t ver) { struct stat sbuf; @@ -413,13 +413,13 @@ static int sfp_vrec_header(struct image_tool_params *params, } static int socfpgaimage_vrec_header_v0(struct image_tool_params *params, - struct image_type_params *tparams) + struct imgtool_funcs *tparams) { return sfp_vrec_header(params, tparams, 0); } static int socfpgaimage_vrec_header_v1(struct image_tool_params *params, - struct image_type_params *tparams) + struct imgtool_funcs *tparams) { return sfp_vrec_header(params, tparams, 1); } diff --git a/tools/sunxi_egon.c b/tools/sunxi_egon.c index a514427809a..d0a55226a9e 100644 --- a/tools/sunxi_egon.c +++ b/tools/sunxi_egon.c @@ -172,7 +172,7 @@ static int egon_check_image_type(uint8_t type) } static int egon_vrec_header(struct image_tool_params *params, - struct image_type_params *tparams) + struct imgtool_funcs *tparams) { int pad_size = ALIGN(params->bl_len ?: PAD_SIZE, PAD_SIZE_MIN); diff --git a/tools/sunxi_toc0.c b/tools/sunxi_toc0.c index 76693647a09..e52cbe325a3 100644 --- a/tools/sunxi_toc0.c +++ b/tools/sunxi_toc0.c @@ -889,7 +889,7 @@ static int toc0_check_image_type(uint8_t type) } static int toc0_vrec_header(struct image_tool_params *params, - struct image_type_params *tparams) + struct imgtool_funcs *tparams) { tparams->hdr = calloc(tparams->header_size, 1); diff --git a/tools/zynqmpimage.c b/tools/zynqmpimage.c index 4db9877127e..a075ac22bdd 100644 --- a/tools/zynqmpimage.c +++ b/tools/zynqmpimage.c @@ -499,7 +499,7 @@ static int zynqmpimage_extract_contents(void *ptr, struct image_tool_params *par } static int zynqmpimage_vrec_header(struct image_tool_params *params, - struct image_type_params *tparams) + struct imgtool_funcs *tparams) { struct stat path_stat; char *filename = params->imagename; -- 2.43.0