diff options
author | David Hendricks <dhendrix@google.com> | 2011-06-14 01:35:36 +0000 |
---|---|---|
committer | David Hendricks <david.hendricks@gmail.com> | 2011-06-14 01:35:36 +0000 |
commit | f01e81ddc8548a02836f3c765d34a1fb4f7fcda9 (patch) | |
tree | a77cc4239b59731e98cf6c9681b5a7c665613038 /internal.c | |
parent | a07f3c00d9f70723ad923cf28875f73f3e5fa6e7 (diff) | |
download | flashrom-f01e81ddc8548a02836f3c765d34a1fb4f7fcda9.zip flashrom-f01e81ddc8548a02836f3c765d34a1fb4f7fcda9.tar.gz |
Use shutdown callback mechanism to shutdown programmers
This patch attempts to resolve some programmer shutdown ordering issues
by having the programmer init functions register shutdown callbacks explicitly
wherever it makes most sense. Before, assumptions were made that could lead to
the internal programmer's state changing before the external programmer could be
shut down properly. Now, each programmer cleans up after itself and (hopefully)
performs each operation in the correct order.
As a side-effect, this patch gives us a better usage model for reverse
operations such as rpci_* and rmmio_*. In the long-run, this should make
reversing the initialization process easier to understand, less tedious, and
less error-prone.
In short, this patch does the following:
- Registers a shutdown callback during initialization for each programmer.
- Kills the .shutdown function pointer from programmer_entry struct. Also,
make most shutdown functions static.
- Adds a few minor clean-ups and corrections (e.g. missing physunmap() calls).
TODO: Remove forward declaration of serprog_shutdown() (added to simplify diff)
Corresponding to flashrom svn r1338.
Signed-off-by: David Hendricks <dhendrix@google.com>
Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Diffstat (limited to 'internal.c')
-rw-r--r-- | internal.c | 15 |
1 files changed, 8 insertions, 7 deletions
@@ -127,6 +127,12 @@ int register_superio(struct superio s) int is_laptop = 0; int laptop_ok = 0; +static int internal_shutdown(void *data) +{ + release_io_perms(); + return 0; +} + int internal_init(void) { #if __FLASHROM_LITTLE_ENDIAN__ @@ -178,6 +184,8 @@ int internal_init(void) free(arg); get_io_perms(); + if (register_shutdown(internal_shutdown, NULL)) + return 1; /* Default to Parallel/LPC/FWH flash devices. If a known host controller * is found, the init routine sets the buses_supported bitfield. @@ -287,13 +295,6 @@ int internal_init(void) return 1; #endif } - -int internal_shutdown(void) -{ - release_io_perms(); - - return 0; -} #endif void internal_chip_writeb(uint8_t val, chipaddr addr) |