From a2136e6cbd732e627f9f33d9211ba0a67be52889 Mon Sep 17 00:00:00 2001 From: Herve Codina Date: Mon, 6 Jul 2015 09:36:43 +0200 Subject: exitcall: Add exitcall infrastructure exitcall infrastructure is based on initcall infrastructure. It allows to have and use exit call hooks on barebox shutdown. Signed-off-by: Herve Codina Signed-off-by: Sascha Hauer --- common/startup.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'common/startup.c') diff --git a/common/startup.c b/common/startup.c index 6178fc5353..45d8d86aee 100644 --- a/common/startup.c +++ b/common/startup.c @@ -45,6 +45,9 @@ extern initcall_t __barebox_initcalls_start[], __barebox_early_initcalls_end[], __barebox_initcalls_end[]; +extern exitcall_t __barebox_exitcalls_start[], __barebox_exitcalls_end[]; + + #if defined CONFIG_FS_RAMFS && defined CONFIG_FS_DEVFS static int mount_root(void) { @@ -140,6 +143,14 @@ void (*board_shutdown)(void); */ void shutdown_barebox(void) { + exitcall_t *exitcall; + + for (exitcall = __barebox_exitcalls_start; + exitcall < __barebox_exitcalls_end; exitcall++) { + pr_debug("exitcall-> %pS\n", *exitcall); + (*exitcall)(); + } + devices_shutdown(); #ifdef ARCH_SHUTDOWN arch_shutdown(); -- cgit v1.2.3