Automatically unmap physmap()s
Similarly to the previous PCI self-clean up patch this one allows to get rid
of a huge number of programmer shutdown functions and makes introducing
bugs harder. It adds a new function rphysmap() that takes care of unmapping
at shutdown. Callers are changed where it makes sense.
Corresponding to flashrom svn r1714.
Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
diff --git a/drkaiser.c b/drkaiser.c
index b94d6dd..8c9fb6a 100644
--- a/drkaiser.c
+++ b/drkaiser.c
@@ -56,12 +56,6 @@
.chip_writen = fallback_chip_writen,
};
-static int drkaiser_shutdown(void *data)
-{
- physunmap(drkaiser_bar, DRKAISER_MEMMAP_SIZE);
- return 0;
-}
-
int drkaiser_init(void)
{
struct pci_dev *dev = NULL;
@@ -80,10 +74,8 @@
rpci_write_word(dev, PCI_MAGIC_DRKAISER_ADDR, PCI_MAGIC_DRKAISER_VALUE);
/* Map 128kB flash memory window. */
- drkaiser_bar = physmap("Dr. Kaiser PC-Waechter flash memory",
- addr, DRKAISER_MEMMAP_SIZE);
-
- if (register_shutdown(drkaiser_shutdown, NULL))
+ drkaiser_bar = rphysmap("Dr. Kaiser PC-Waechter flash memory", addr, DRKAISER_MEMMAP_SIZE);
+ if (drkaiser_bar == ERROR_PTR)
return 1;
max_rom_decode.parallel = 128 * 1024;