pcm: Fix usage of oops() function for use of strerror.

The oops() function expected errno to be passed in, but at some
point it was broken to look at errno itself, and ignore the
passed-in value.

Fix the oops() function to check the passed-in value, and modify
uses of oops() to actually pass in errno and not -errno or the
return value from the errored function call.

Bug: None
Test: pcm error code printed correctly.
Change-Id: I555e1eda0cdd0cc9b94e05423d341f1c08f8e485
(cherry picked from commit 2c1d902ace5f78dcff0c39740642d269b2e17dff)
diff --git a/pcm.c b/pcm.c
index d8e9d36..614a14e 100644
--- a/pcm.c
+++ b/pcm.c
@@ -284,7 +284,7 @@
     va_end(ap);
     sz = strlen(pcm->error);
 
-    if (errno)
+    if (e)
         snprintf(pcm->error + sz, PCM_ERROR_MAX - sz,
                  ": %s", strerror(e));
     return -1;
@@ -436,7 +436,7 @@
         pcm_areas_copy(pcm, pcm_offset, buf, offset, frames);
         commit = pcm_mmap_commit(pcm, pcm_offset, frames);
         if (commit < 0) {
-            oops(pcm, commit, "failed to commit %d frames\n", frames);
+            oops(pcm, errno, "failed to commit %d frames\n", frames);
             return commit;
         }
 
@@ -924,7 +924,7 @@
 
     if (flags & PCM_NOIRQ) {
         if (!(flags & PCM_MMAP)) {
-            oops(pcm, -EINVAL, "noirq only currently supported with mmap().");
+            oops(pcm, EINVAL, "noirq only currently supported with mmap().");
             goto fail_close;
         }
 
@@ -953,7 +953,7 @@
         pcm->mmap_buffer = mmap(NULL, pcm_frames_to_bytes(pcm, pcm->buffer_size),
                                 PROT_READ | PROT_WRITE, MAP_FILE | MAP_SHARED, pcm->fd, 0);
         if (pcm->mmap_buffer == MAP_FAILED) {
-            oops(pcm, -errno, "failed to mmap buffer %d bytes\n",
+            oops(pcm, errno, "failed to mmap buffer %d bytes\n",
                  pcm_frames_to_bytes(pcm, pcm->buffer_size));
             goto fail_close;
         }
@@ -1007,7 +1007,7 @@
 
     rc = pcm_hw_mmap_status(pcm);
     if (rc < 0) {
-        oops(pcm, rc, "mmap status failed");
+        oops(pcm, errno, "mmap status failed");
         goto fail;
     }
 
@@ -1016,7 +1016,7 @@
         int arg = SNDRV_PCM_TSTAMP_TYPE_MONOTONIC;
         rc = ioctl(pcm->fd, SNDRV_PCM_IOCTL_TTSTAMP, &arg);
         if (rc < 0) {
-            oops(pcm, rc, "cannot set timestamp type");
+            oops(pcm, errno, "cannot set timestamp type");
             goto fail;
         }
     }
@@ -1278,7 +1278,7 @@
                 if (err < 0) {
                     pcm->prepared = 0;
                     pcm->running = 0;
-                    oops(pcm, err, "wait error: hw 0x%x app 0x%x avail 0x%x\n",
+                    oops(pcm, errno, "wait error: hw 0x%x app 0x%x avail 0x%x\n",
                         (unsigned int)pcm->mmap_status->hw_ptr,
                         (unsigned int)pcm->mmap_control->appl_ptr,
                         avail);