• Carl-Daniel Hailfinger's avatar
    Allow the registration of functions to be called at programmer shutdown · cc389fc6
    Carl-Daniel Hailfinger authored
    
    Some programmers want to run certain functions during programmer
    shutdown, but the function choice depends on the code path taken
    during programmer init. Rather than rebuilding the whole init logic in
    the shutdown function, it is now possible to register functions for
    execution on programmer shutdown. The behaviour is similar to atexit(),
    but the registered functions will be run on programmer shutdown instead
    of on exit and the functions will be called with a void * argument
    that is specified on registration. Registered functions must have
    the prototype void function(void *); and will be executed in reverse
    registration order directly before calling the programmer-specific
    shutdown() function. It is recommended to have shutdown() only disable
    programmer/hardware access and leave all code path sensitive shutdown to
    functions registered with register_shutdown().
    
    The most prominent use case is resetting the EC after flashing on
    laptops.
    
    Note: There are quite a few code paths in flashrom which proceed to
    terminate flashrom without any programmer shutdown. Those code paths
    will not get the benefit of register_shutdown() and they should be
    changed wherever possible.
    
    Corresponding to flashrom svn r904.
    Signed-off-by: default avatarCarl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
    Acked-by: default avatarMichael Karcher <flashrom@mkarcher.dialup.fu-berlin.de>
    cc389fc6
flashrom.c 35 KB