From: Nishanth Aravamudan <[EMAIL PROTECTED]>


Rather than use custom code in DRM_WAIT_ON() to do exactly
what wait_event_interruptible_timeout() does, use the function and just
change the return values appropriately.

Signed-off-by: Nishanth Aravamudan <[EMAIL PROTECTED]>
Signed-off-by: Domen Puncer <[EMAIL PROTECTED]>
---
 drm_os_linux.h |   27 +++++++--------------------
 1 files changed, 7 insertions(+), 20 deletions(-)

Index: quilt/drivers/char/drm/drm_os_linux.h
===================================================================
--- quilt.orig/drivers/char/drm/drm_os_linux.h
+++ quilt/drivers/char/drm/drm_os_linux.h
@@ -6,6 +6,7 @@
 
 #include <linux/interrupt.h>   /* For task queue support */
 #include <linux/delay.h>
+#include <linux/wait.h>
 
 /** File pointer type */
 #define DRMFILE                         struct file *
@@ -121,26 +122,12 @@ do {                                                      
                 \
 
 #define DRM_WAIT_ON( ret, queue, timeout, condition )          \
 do {                                                           \
-       DECLARE_WAITQUEUE(entry, current);                      \
-       unsigned long end = jiffies + (timeout);                \
-       add_wait_queue(&(queue), &entry);                       \
-                                                               \
-       for (;;) {                                              \
-               __set_current_state(TASK_INTERRUPTIBLE);        \
-               if (condition)                                  \
-                       break;                                  \
-               if (time_after_eq(jiffies, end)) {              \
-                       ret = -EBUSY;                           \
-                       break;                                  \
-               }                                               \
-               schedule_timeout((HZ/100 > 1) ? HZ/100 : 1);    \
-               if (signal_pending(current)) {                  \
-                       ret = -EINTR;                           \
-                       break;                                  \
-               }                                               \
-       }                                                       \
-       __set_current_state(TASK_RUNNING);                      \
-       remove_wait_queue(&(queue), &entry);                    \
+       long __ret;                                             \
+       __ret = wait_event_interruptible_timeout(queue, condition, timeout); \
+       if (__ret == 0)                                         \
+               ret = -EBUSY;                                   \
+       else if (__ret == -ERESTARTSYS)                         \
+               ret = -EINTR;                                   \
 } while (0)
 
 

--


-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
--
_______________________________________________
Dri-devel mailing list
Dri-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dri-devel

Reply via email to