[flashrom] [PATCH] register_shutdown for execution on programmer shutdown
Michael Karcher
flashrom at mkarcher.dialup.fu-berlin.de
Sat Feb 13 00:59:36 CET 2010
Am Freitag, den 12.02.2010, 03:59 +0100 schrieb Carl-Daniel Hailfinger:
> +#define SHUTDOWN_MAXFN 4
> +static int shutdown_fn_count = 0;
> +void (*shutdown_fn[SHUTDOWN_MAXFN]) (void);
style hint: Use a typedef for the function pointer type:
typedef void (*shutdown_proc)(void);
shutdown_proc shutdownfn[SHUTDOWN_MAXFN];
> +int register_shutdown(void (*function)(void))
And this gets "int register_shutdown(shutdown_proc function)
> +{
> + if (shutdown_fn_count >= SHUTDOWN_MAXFN) {
> + msg_perr("Tried to register more than %n shutdown functions.\n",
> + SHUTDOWN_MAXFN);
> + return 1;
> + }
> + shutdown_fn[shutdown_fn_count++] = function;
> +
> + return 0;
> +}
> +
> int programmer_shutdown(void)
> {
> + int i;
> +
> + for (i = shutdown_fn_count - 1; i >= 0; i--)
> + shutdown_fn[i]();
> return programmer_table[programmer].shutdown();
> }
Except for the style hint, everything looks great, so
Acked-by: Michael Karcher <flashrom at mkarcher.dialup.fu-berlin.de>
More information about the flashrom
mailing list