From: Erik Gilling <konkers@android.com>
Date: Wed, 22 Aug 2012 00:57:19 +0000 (-0700)
Subject: sync: change wait timeout to mirror poll semantics
X-Git-Tag: firefly_0821_release~7563
X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=c9ac59a938adb6bc8568ef6c68b8c5155727cc5e;p=firefly-linux-kernel-4.4.55.git

sync: change wait timeout to mirror poll semantics

Change-Id: Ib38e6d339d41885a33027752690d65a52b6897f6
Signed-off-by: Erik Gilling <konkers@android.com>
---

diff --git a/drivers/base/sync.c b/drivers/base/sync.c
index d12efbf0d24e..59631d512650 100644
--- a/drivers/base/sync.c
+++ b/drivers/base/sync.c
@@ -560,14 +560,14 @@ EXPORT_SYMBOL(sync_fence_cancel_async);
 
 int sync_fence_wait(struct sync_fence *fence, long timeout)
 {
-	int err;
+	int err = 0;
 
-	if (timeout) {
+	if (timeout > 0) {
 		timeout = msecs_to_jiffies(timeout);
 		err = wait_event_interruptible_timeout(fence->wq,
 						       fence->status != 0,
 						       timeout);
-	} else {
+	} else if (timeout < 0{
 		err = wait_event_interruptible(fence->wq, fence->status != 0);
 	}
 
diff --git a/include/linux/sync.h b/include/linux/sync.h
index 15863a6ebe51..75ed5f1b75da 100644
--- a/include/linux/sync.h
+++ b/include/linux/sync.h
@@ -329,8 +329,8 @@ int sync_fence_cancel_async(struct sync_fence *fence,
  * @fence:	fence to wait on
  * @tiemout:	timeout in ms
  *
- * Wait for @fence to be signaled or have an error.  Waits indefintly
- * if @timeout = 0
+ * Wait for @fence to be signaled or have an error.  Waits indefinitely
+ * if @timeout < 0
  */
 int sync_fence_wait(struct sync_fence *fence, long timeout);
 
@@ -389,9 +389,9 @@ struct sync_fence_info_data {
 /**
  * DOC: SYNC_IOC_WAIT - wait for a fence to signal
  *
- * pass timeout in milliseconds.
+ * pass timeout in milliseconds.  Waits indefinitely timeout < 0.
  */
-#define SYNC_IOC_WAIT		_IOW(SYNC_IOC_MAGIC, 0, __u32)
+#define SYNC_IOC_WAIT		_IOW(SYNC_IOC_MAGIC, 0, __s32)
 
 /**
  * DOC: SYNC_IOC_MERGE - merge two fences