diff options
author | Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at> | 2013-09-14 09:02:27 +0000 |
---|---|---|
committer | Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at> | 2013-09-14 09:02:27 +0000 |
commit | ed2e1e479a6f445b9053b5ce014bb84ed56af9e9 (patch) | |
tree | 1d4a18ad60037ced5824c9f509dd77997f56054a /physmap.c | |
parent | a782c3ef48ffde52432aa0ac716a9a45adc83ac0 (diff) | |
download | flashrom-ed2e1e479a6f445b9053b5ce014bb84ed56af9e9.zip flashrom-ed2e1e479a6f445b9053b5ce014bb84ed56af9e9.tar.gz |
Remove exit call and mayfail parameter from physmap_common()
The only call path where exit was reached was from physmap functions.
Callers of physmap() et al. which were not prepared to handle
ERROR_PTR return values have been adjusted.
physmap_try_ro() has been renamed to physmap_ro() and physmap_common()
slightly refactored due to the now removed *FAIL parameters.
Binary file (standard input) matches
Corresponding to flashrom svn r1745.
Diffstat (limited to 'physmap.c')
-rw-r--r-- | physmap.c | 32 |
1 files changed, 12 insertions, 20 deletions
@@ -203,8 +203,6 @@ void physunmap(void *virt_addr, size_t len) } #endif -#define PHYSM_NOFAIL 0 -#define PHYSM_MAYFAIL 1 #define PHYSM_RW 0 #define PHYSM_RO 1 #define PHYSM_NOCLEANUP 0 @@ -249,8 +247,8 @@ static int undo_physmap(void *data) return 0; } -static void *physmap_common(const char *descr, uintptr_t phys_addr, size_t len, bool mayfail, - bool readonly, bool autocleanup, bool round) +static void *physmap_common(const char *descr, uintptr_t phys_addr, size_t len, bool readonly, bool autocleanup, + bool round) { void *virt_addr; uintptr_t offset = 0; @@ -287,53 +285,47 @@ static void *physmap_common(const char *descr, uintptr_t phys_addr, size_t len, "and reboot, or reboot into\n" "single user mode.\n"); #endif - if (mayfail) - return ERROR_PTR; - else - exit(3); + return ERROR_PTR; } if (autocleanup) { struct undo_physmap_data *d = malloc(sizeof(struct undo_physmap_data)); if (d == NULL) { msg_perr("%s: Out of memory!\n", __func__); - goto unmap_out; + physunmap(virt_addr, len); + return ERROR_PTR; } d->virt_addr = virt_addr; d->len = len; if (register_shutdown(undo_physmap, d) != 0) { msg_perr("%s: Could not register shutdown function!\n", __func__); - goto unmap_out; + physunmap(virt_addr, len); + return ERROR_PTR; } } return virt_addr + offset; -unmap_out: - physunmap(virt_addr, len); - if (!mayfail) - exit(3); - return ERROR_PTR; } void *physmap(const char *descr, uintptr_t phys_addr, size_t len) { - return physmap_common(descr, phys_addr, len, PHYSM_NOFAIL, PHYSM_RW, PHYSM_NOCLEANUP, PHYSM_EXACT); + return physmap_common(descr, phys_addr, len, PHYSM_RW, PHYSM_NOCLEANUP, PHYSM_EXACT); } void *rphysmap(const char *descr, uintptr_t phys_addr, size_t len) { - return physmap_common(descr, phys_addr, len, PHYSM_NOFAIL, PHYSM_RW, PHYSM_CLEANUP, PHYSM_ROUND); + return physmap_common(descr, phys_addr, len, PHYSM_RW, PHYSM_CLEANUP, PHYSM_ROUND); } void *physmap_round(const char *descr, uintptr_t phys_addr, size_t len) { - return physmap_common(descr, phys_addr, len, PHYSM_NOFAIL, PHYSM_RW, PHYSM_NOCLEANUP, PHYSM_ROUND); + return physmap_common(descr, phys_addr, len, PHYSM_RW, PHYSM_NOCLEANUP, PHYSM_ROUND); } -void *physmap_try_ro(const char *descr, uintptr_t phys_addr, size_t len) +void *physmap_ro(const char *descr, uintptr_t phys_addr, size_t len) { - return physmap_common(descr, phys_addr, len, PHYSM_MAYFAIL, PHYSM_RO, PHYSM_NOCLEANUP, PHYSM_EXACT); + return physmap_common(descr, phys_addr, len, PHYSM_RO, PHYSM_NOCLEANUP, PHYSM_EXACT); } /* MSR abstraction implementations for Linux, OpenBSD, FreeBSD/Dragonfly, OSX, libpayload |