drm/msm: split out timeout_to_jiffies helper
authorRob Clark <robdclark@gmail.com>
Wed, 16 Mar 2016 18:57:22 +0000 (14:57 -0400)
committerRob Clark <robdclark@gmail.com>
Sun, 8 May 2016 14:16:03 +0000 (10:16 -0400)
Signed-off-by: Rob Clark <robdclark@gmail.com>
drivers/gpu/drm/msm/msm_drv.h
drivers/gpu/drm/msm/msm_fence.c

index 86b7b3796d8f09d155fc2f28c0d91f16ac3ce78b..af007ac8c73399ebd856685a9154be6b2b416625 100644 (file)
@@ -302,5 +302,20 @@ static inline int align_pitch(int width, int bpp)
 /* for conditionally setting boolean flag(s): */
 #define COND(bool, val) ((bool) ? (val) : 0)
 
+static inline unsigned long timeout_to_jiffies(const ktime_t *timeout)
+{
+       ktime_t now = ktime_get();
+       unsigned long remaining_jiffies;
+
+       if (ktime_compare(*timeout, now) < 0) {
+               remaining_jiffies = 0;
+       } else {
+               ktime_t rem = ktime_sub(*timeout, now);
+               struct timespec ts = ktime_to_timespec(rem);
+               remaining_jiffies = timespec_to_jiffies(&ts);
+       }
+
+       return remaining_jiffies;
+}
 
 #endif /* __MSM_DRV_H__ */
index 55a5f9280088cd6783484f9aaeadad0e8f6a6119..002eecb3934e43931b51db6e7f0263eca51e7a42 100644 (file)
@@ -44,16 +44,7 @@ int msm_wait_fence(struct drm_device *dev, uint32_t fence,
                /* no-wait: */
                ret = fence_completed(dev, fence) ? 0 : -EBUSY;
        } else {
-               ktime_t now = ktime_get();
-               unsigned long remaining_jiffies;
-
-               if (ktime_compare(*timeout, now) < 0) {
-                       remaining_jiffies = 0;
-               } else {
-                       ktime_t rem = ktime_sub(*timeout, now);
-                       struct timespec ts = ktime_to_timespec(rem);
-                       remaining_jiffies = timespec_to_jiffies(&ts);
-               }
+               unsigned long remaining_jiffies = timeout_to_jiffies(timeout);
 
                if (interruptible)
                        ret = wait_event_interruptible_timeout(priv->fence_event,