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 | 8bb2021d77c8ee213b53d671687b7a1179335522 (patch) | |
tree | a77cc4239b59731e98cf6c9681b5a7c665613038 /nicnatsemi.c | |
parent | 9d9a1042332cd08aa66eee6f37d80c0f09f47d70 (diff) | |
download | flashrom-8bb2021d77c8ee213b53d671687b7a1179335522.tar.gz flashrom-8bb2021d77c8ee213b53d671687b7a1179335522.tar.bz2 flashrom-8bb2021d77c8ee213b53d671687b7a1179335522.zip |
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 'nicnatsemi.c')
-rw-r--r-- | nicnatsemi.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/nicnatsemi.c b/nicnatsemi.c index 3cae25366..ac37cf0cd 100644 --- a/nicnatsemi.c +++ b/nicnatsemi.c @@ -35,6 +35,13 @@ const struct pcidev_status nics_natsemi[] = { {}, }; +static int nicnatsemi_shutdown(void *data) +{ + pci_cleanup(pacc); + release_io_perms(); + return 0; +} + int nicnatsemi_init(void) { get_io_perms(); @@ -51,13 +58,8 @@ int nicnatsemi_init(void) */ max_rom_decode.parallel = 131072; - return 0; -} - -int nicnatsemi_shutdown(void) -{ - pci_cleanup(pacc); - release_io_perms(); + if (register_shutdown(nicnatsemi_shutdown, NULL)) + return 1; return 0; } |