[flashrom] [Patch] + RFC: Use shutdown callback mechanism to shutdown programmers

David Hendricks dhendrix at google.com
Tue May 17 01:00:06 CEST 2011


Finally got a chance to revise this. There are a lot of small, tedious
changes to all the programmer .c files and some interesting changes to
flashrom.c. Otherwise it's a pretty simple patch.

To recap from earlier discussion, this version does the following:
- Registers a shutdown callback during initialization for each programmer.
See notes below.
- Kills the .shutdown function pointer from programmer_entry struct
- Updates all programmer shutdown functions to return an int and take a void
*data arg. Also, make them static.
- programmer_shutdown() checks the return code of all shutdown callbacks.

A few minor questions:
- If programmer_init() fails when called in cli_classic(), should we call
programmer_shutdown()? As Carl-Daniel noted earlier, this could potentially
be used to do stuff like release_io_perms(), or perhaps free resources
allocated by an init routine that fails.
- nicintel_spi -- Looks like flash write enable/disable should be done using
rpci?
- drkaiser - shutdown function missing a physunmap?

Additional notes:
- Most programmers have a simple init routines with no failure condition, so
placement of register_shutdown() doesn't really matter.
- serialport_shutdown non-static since it's used by buspirate.
- There were cases where the programmer's init routine would do something
less simple, like open a file or map physical memory, and the shutdown
callback would undo it. In those cases, placement took a little more
thought. Someone more familiar with those should double-check that this
patch does the right thing for buspirate, serprog, and satamv.

I did a quick test using an NM10/ICH7 platform and callbacks were shown in
verbose mode output as expected.
Signed-off-by: David Hendricks <dhendrix at google.com>

-- 
David Hendricks (dhendrix)
Systems Software Engineer, Google Inc.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.flashrom.org/pipermail/flashrom/attachments/20110516/ddab2dae/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: call_programmer_shutdown_using_callbacks.patch
Type: text/x-patch
Size: 41907 bytes
Desc: not available
URL: <http://www.flashrom.org/pipermail/flashrom/attachments/20110516/ddab2dae/attachment.patch>


More information about the flashrom mailing list