Get rid of perror()

It prints to stderr and that's not what we want necesserily;
using msg_*err gives us more control.

Corresponding to flashrom svn r1668.

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/physmap.c b/physmap.c
index 5aa9874..4ebfb06 100644
--- a/physmap.c
+++ b/physmap.c
@@ -172,7 +172,7 @@
 	if (-1 == fd_mem) {
 		/* Open the memory device UNCACHED. Important for MMIO. */
 		if (-1 == (fd_mem = open(MEM_DEV, O_RDWR | O_SYNC))) {
-			perror("Critical error: open(" MEM_DEV ")");
+			msg_perr("Critical error: open(" MEM_DEV "): %s\n", strerror(errno));
 			exit(2);
 		}
 	}
@@ -192,8 +192,7 @@
 	if (-1 == fd_mem_cached) {
 		/* Open the memory device CACHED. */
 		if (-1 == (fd_mem_cached = open(MEM_DEV, O_RDWR))) {
-			msg_perr("Critical error: open(" MEM_DEV "): %s",
-				 strerror(errno));
+			msg_perr("Critical error: open(" MEM_DEV "): %s\n", strerror(errno));
 			exit(2);
 		}
 	}
@@ -250,7 +249,7 @@
 			descr = "memory";
 		msg_perr("Error accessing %s, 0x%lx bytes at 0x%08lx\n", descr,
 			 (unsigned long)len, phys_addr);
-		perror(MEM_DEV " mmap failed");
+		msg_perr(MEM_DEV " mmap failed: %s\n", strerror(errno));
 #ifdef __linux__
 		if (EINVAL == errno) {
 			msg_perr("In Linux this error can be caused by the CONFIG_NONPROMISC_DEVMEM (<2.6.27),\n");
@@ -302,7 +301,7 @@
 	msr_t msr = { 0xffffffff, 0xffffffff };
 
 	if (lseek(fd_msr, (off_t) addr, SEEK_SET) == -1) {
-		perror("Could not lseek() to MSR");
+		msg_perr("Could not lseek() MSR: %s\n", strerror(errno));
 		close(fd_msr);
 		exit(1);
 	}
@@ -315,7 +314,7 @@
 
 	if (errno != EIO) {
 		// A severe error.
-		perror("Could not read() MSR");
+		msg_perr("Could not read() MSR: %s\n", strerror(errno));
 		close(fd_msr);
 		exit(1);
 	}
@@ -330,13 +329,13 @@
 	buf[1] = msr.hi;
 
 	if (lseek(fd_msr, (off_t) addr, SEEK_SET) == -1) {
-		perror("Could not lseek() to MSR");
+		msg_perr("Could not lseek() MSR: %s\n", strerror(errno));
 		close(fd_msr);
 		exit(1);
 	}
 
 	if (write(fd_msr, buf, 8) != 8 && errno != EIO) {
-		perror("Could not write() MSR");
+		msg_perr("Could not write() MSR: %s\n", strerror(errno));
 		close(fd_msr);
 		exit(1);
 	}
@@ -362,7 +361,7 @@
 	fd_msr = open(msrfilename, O_RDWR);
 
 	if (fd_msr < 0) {
-		perror("Error while opening /dev/cpu/0/msr");
+		msg_perr("Error while opening %s: %s\n", msrfilename, strerror(errno));
 		msg_pinfo("Did you run 'modprobe msr'?\n");
 		return -1;
 	}
@@ -404,7 +403,7 @@
 	args.msr = addr;
 
 	if (ioctl(fd_msr, CPU_RDMSR, &args) < 0) {
-		perror("CPU_RDMSR");
+		msg_perr("Error while executing CPU_RDMSR ioctl: %s\n", strerror(errno));
 		close(fd_msr);
 		exit(1);
 	}
@@ -423,7 +422,7 @@
 	args.data = (((uint64_t)msr.hi) << 32) | msr.lo;
 
 	if (ioctl(fd_msr, CPU_WRMSR, &args) < 0) {
-		perror("CPU_WRMSR");
+		msg_perr("Error while executing CPU_WRMSR ioctl: %s\n", strerror(errno));
 		close(fd_msr);
 		exit(1);
 	}
@@ -445,7 +444,7 @@
 	fd_msr = open(msrfilename, O_RDWR);
 
 	if (fd_msr < 0) {
-		perror("Error while opening /dev/cpu0");
+		msg_perr("Error while opening %s: %s\n", msrfilename, strerror(errno));
 		msg_pinfo("Did you install ports/sysutils/devcpu?\n");
 		return -1;
 	}