Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/riastradh-drm2]: src/sys/external/bsd/drm2/include/linux Fix return valu...



details:   https://anonhg.NetBSD.org/src/rev/0c70882d74c0
branches:  riastradh-drm2
changeset: 788652:0c70882d74c0
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Fri Mar 07 15:39:18 2014 +0000

description:
Fix return value of wait_for_completion_interruptible_timeout.

diffstat:

 sys/external/bsd/drm2/include/linux/completion.h |  25 ++++++++++++++++++++---
 1 files changed, 21 insertions(+), 4 deletions(-)

diffs (62 lines):

diff -r 74d7cec25c2c -r 0c70882d74c0 sys/external/bsd/drm2/include/linux/completion.h
--- a/sys/external/bsd/drm2/include/linux/completion.h  Fri Mar 07 15:39:08 2014 +0000
+++ b/sys/external/bsd/drm2/include/linux/completion.h  Fri Mar 07 15:39:18 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: completion.h,v 1.1.2.5 2013/09/08 16:01:49 riastradh Exp $     */
+/*     $NetBSD: completion.h,v 1.1.2.6 2014/03/07 15:39:18 riastradh Exp $     */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -38,6 +38,8 @@
 
 #include <machine/limits.h>
 
+#include <linux/errno.h>
+
 struct completion {
        kmutex_t        c_lock;
        kcondvar_t      c_cv;
@@ -152,17 +154,25 @@
 wait_for_completion_interruptible_timeout(struct completion *completion,
     unsigned long ticks)
 {
+       /* XXX Arithmetic overflow...?  */
+       unsigned int start = hardclock_ticks, now;
        int error;
 
        mutex_enter(&completion->c_lock);
 
        /* Wait until c_done is nonzero.  */
        while (completion->c_done == 0) {
-               /* XXX errno NetBSD->Linux */
-               error = -cv_timedwait_sig(&completion->c_cv,
+               error = cv_timedwait_sig(&completion->c_cv,
                    &completion->c_lock, ticks);
                if (error)
                        goto out;
+               now = hardclock_ticks;
+               if (ticks < (now - start)) {
+                       error = EWOULDBLOCK;
+                       goto out;
+               }
+               ticks -= (now - start);
+               start = now;
        }
 
        /* Claim a completion if it's not open season.  */
@@ -175,7 +185,14 @@
        error = 0;
 
 out:   mutex_exit(&completion->c_lock);
-       return error;
+       if (error == EWOULDBLOCK) {
+               return 0;
+       } else if ((error == EINTR) || (error == ERESTART)) {
+               return -ERESTARTSYS;
+       } else {
+               KASSERTMSG((error == 0), "error = %d", error);
+               return ticks;
+       }
 }
 
 #endif /* _LINUX_COMPLETION_H_ */



Home | Main Index | Thread Index | Old Index