[U-Boot] [PATCH 5/6] cmd_nvedit.c: allow board-specific code before/after saving the environment

Mike Frysinger vapier at gentoo.org
Mon May 14 07:20:44 CEST 2012


On Friday 04 May 2012 18:21:31 Timur Tabi wrote:
> Introduce board_start_saveenv() and board_finish_saveenv(), two "weak"
> functions that are called before and after saving the environment.  This
> allows for board-specific functions that "prepare" the board for saving
> the environment.  This is useful if, for some reason, the non-volatile
> storage is normally unavailable (e.g. blocked via a mux).

all these board hooks are paper-cutting us to death with unused bloat

> --- a/common/cmd_nvedit.c
> +++ b/common/cmd_nvedit.c
> 
>  #if defined(CONFIG_CMD_SAVEENV) && !defined(CONFIG_ENV_IS_NOWHERE)
> +
> +static int __board_start_saveenv(void)
> +{
> +	return 0;
> +}
> +int board_start_saveenv(void) __attribute__((weak,
> alias("__board_start_saveenv"))); +
> +static void __board_finish_saveenv(void)
> +{
> +}
> +void board_finish_saveenv(void) __attribute__((weak,
> alias("__board_finish_saveenv"))); +
>  int do_env_save(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
>  {
> +	int ret;
> +
>  	printf("Saving Environment to %s...\n", env_name_spec);
> 
> -	return saveenv() ? 1 : 0;
> +	ret = board_start_saveenv();
> +	if (ret)
> +		return 0;
> +
> +	ret = saveenv() ? 1 : 0;
> +
> +	board_finish_saveenv();
> +
> +	return ret;
>  }

this is less bloat:
int board_start_saveenv(void) __attribute__((weak, alias("saveenv")));

int do_env_save(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
	printf("Saving Environment to %s...\n", env_name_spec);
	return board_saveenv() ? 1 : 0;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20120514/5fd0154f/attachment.pgp>


More information about the U-Boot mailing list