From 2d8b7ef4a84e4946619fa8e4d1b9fcaa15208440 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20S=C3=B6derlund?= Date: Fri, 13 Sep 2013 19:19:25 +0000 Subject: [PATCH] Remove exit call from sys_physmap_* MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit All callers are prepared to handle error if ERROR_PTR is returned. The Manpage mentioning the respective return code is readapted. Corresponding to flashrom svn r1744. Signed-off-by: Niklas Söderlund Acked-by: Stefan Tauner --- flashrom.8.tmpl | 3 +-- physmap.c | 12 +++++------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/flashrom.8.tmpl b/flashrom.8.tmpl index 5ede423ee..9f8af039c 100644 --- a/flashrom.8.tmpl +++ b/flashrom.8.tmpl @@ -857,8 +857,7 @@ backuplog.txt, writelog.txt and restorelog.txt. See section .B BUGS for contact info. .SH EXIT STATUS -flashrom exits with 0 on success, 1 on most failures but with 2 if /dev/mem -(/dev/xsvc on Solaris) can not be opened and with 3 if a call to mmap() fails. +flashrom exits with 0 on success, 1 on most failures but with 3 if a call to mmap() fails. .SH REQUIREMENTS flashrom needs different access permissions for different programmers. .sp diff --git a/physmap.c b/physmap.c index 9cac86858..caad1ca5a 100644 --- a/physmap.c +++ b/physmap.c @@ -165,12 +165,11 @@ static void *sys_physmap_rw_uncached(uintptr_t phys_addr, size_t len) /* Open the memory device UNCACHED. Important for MMIO. */ if (-1 == (fd_mem = open(MEM_DEV, O_RDWR | O_SYNC))) { msg_perr("Critical error: open(" MEM_DEV "): %s\n", strerror(errno)); - exit(2); + return ERROR_PTR; } } - virt_addr = mmap(NULL, len, PROT_WRITE | PROT_READ, MAP_SHARED, - fd_mem, (off_t)phys_addr); + virt_addr = mmap(NULL, len, PROT_WRITE | PROT_READ, MAP_SHARED, fd_mem, (off_t)phys_addr); return MAP_FAILED == virt_addr ? ERROR_PTR : virt_addr; } @@ -185,12 +184,11 @@ static void *sys_physmap_ro_cached(uintptr_t phys_addr, size_t len) /* Open the memory device CACHED. */ if (-1 == (fd_mem_cached = open(MEM_DEV, O_RDWR))) { msg_perr("Critical error: open(" MEM_DEV "): %s\n", strerror(errno)); - exit(2); + return ERROR_PTR; } } - virt_addr = mmap(NULL, len, PROT_READ, MAP_SHARED, - fd_mem_cached, (off_t)phys_addr); + virt_addr = mmap(NULL, len, PROT_READ, MAP_SHARED, fd_mem_cached, (off_t)phys_addr); return MAP_FAILED == virt_addr ? ERROR_PTR : virt_addr; } @@ -200,7 +198,7 @@ void physunmap(void *virt_addr, size_t len) msg_pspew("Not unmapping zero size at %p\n", virt_addr); return; } - + munmap(virt_addr, len); } #endif