From: Mike Frysinger Date: Mon, 14 May 2012 01:20:44 -0400 Subject: [U-Boot] [PATCH 5/6] cmd_nvedit.c: allow board-specific code before/after saving the environment In-Reply-To: <1336170092-22538-5-git-send-email-timur@freescale.com> References: <1336170092-22538-1-git-send-email-timur@freescale.com> <1336170092-22538-5-git-send-email-timur@freescale.com> Message-ID: <201205140120.45712.vapier@gentoo.org> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de 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: