path: root/satamv.c
diff options
authorDavid Hendricks <>2011-06-14 01:35:36 +0000
committerDavid Hendricks <>2011-06-14 01:35:36 +0000
commit8bb2021d77c8ee213b53d671687b7a1179335522 (patch)
treea77cc4239b59731e98cf6c9681b5a7c665613038 /satamv.c
parent9d9a1042332cd08aa66eee6f37d80c0f09f47d70 (diff)
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 <> Acked-by: Carl-Daniel Hailfinger <>
Diffstat (limited to 'satamv.c')
1 files changed, 11 insertions, 8 deletions
diff --git a/satamv.c b/satamv.c
index 0c0dace..01919d0 100644
--- a/satamv.c
+++ b/satamv.c
@@ -40,6 +40,14 @@ const struct pcidev_status satas_mv[] = {
#define PCI_BAR2_CONTROL 0x00c08
#define GPIO_PORT_CONTROL 0x104f0
+static int satamv_shutdown(void *data)
+ physunmap(mv_bar, 0x20000);
+ pci_cleanup(pacc);
+ release_io_perms();
+ return 0;
* Random notes:
* FCE# Flash Chip Enable
@@ -73,6 +81,9 @@ int satamv_init(void)
if (mv_bar == ERROR_PTR)
goto error_out;
+ if (register_shutdown(satamv_shutdown, NULL))
+ return 1;
tmp = pci_mmio_readl(mv_bar + FLASH_PARAM);
msg_pspew("Flash Parameters:\n");
msg_pspew("TurnOff=0x%01x\n", (tmp >> 0) & 0x7);
@@ -139,14 +150,6 @@ error_out:
return 1;
-int satamv_shutdown(void)
- physunmap(mv_bar, 0x20000);
- pci_cleanup(pacc);
- release_io_perms();
- return 0;
/* BAR2 (MEM) can map NVRAM and flash. We set it to flash in the init function.
* If BAR2 is disabled, it still can be accessed indirectly via BAR1 (I/O).
* This code only supports indirect accesses for now.
OpenPOWER on IntegriCloud