drm/i915: Fixed point fixed16 wrapper cleanup
authorKumar, Mahesh <mahesh1.kumar@intel.com>
Thu, 17 Aug 2017 13:45:22 +0000 (19:15 +0530)
committerMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
Thu, 7 Sep 2017 11:33:45 +0000 (13:33 +0200)
As per suggestion from Jani, cleanup the code. Cleanup includes
 - Instead of left shifting & check, compare with U32/16_MAX
 - Use typecast instead of clamp_t

Signed-off-by: Mahesh Kumar <mahesh1.kumar@intel.com>
Cc: Jani Nikula <jani.nikula@intel.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20170817134529.2839-2-mahesh1.kumar@intel.com
drivers/gpu/drm/i915/i915_drv.h

index 2b08bbf608aa10908d9ebff1ba1ed410182bf2c5..2f12373d2f547bcea7001a7dfa9cce15cabd4c1e 100644 (file)
@@ -126,7 +126,7 @@ static inline uint_fixed_16_16_t u32_to_fixed16(uint32_t val)
 {
        uint_fixed_16_16_t fp;
 
-       WARN_ON(val >> 16);
+       WARN_ON(val > U16_MAX);
 
        fp.val = val << 16;
        return fp;
@@ -163,8 +163,8 @@ static inline uint_fixed_16_16_t max_fixed16(uint_fixed_16_16_t max1,
 static inline uint_fixed_16_16_t clamp_u64_to_fixed16(uint64_t val)
 {
        uint_fixed_16_16_t fp;
-       WARN_ON(val >> 32);
-       fp.val = clamp_t(uint32_t, val, 0, ~0);
+       WARN_ON(val > U32_MAX);
+       fp.val = (uint32_t) val;
        return fp;
 }
 
@@ -181,8 +181,8 @@ static inline uint32_t mul_round_up_u32_fixed16(uint32_t val,
 
        intermediate_val = (uint64_t) val * mul.val;
        intermediate_val = DIV_ROUND_UP_ULL(intermediate_val, 1 << 16);
-       WARN_ON(intermediate_val >> 32);
-       return clamp_t(uint32_t, intermediate_val, 0, ~0);
+       WARN_ON(intermediate_val > U32_MAX);
+       return (uint32_t) intermediate_val;
 }
 
 static inline uint_fixed_16_16_t mul_fixed16(uint_fixed_16_16_t val,
@@ -211,8 +211,8 @@ static inline uint32_t div_round_up_u32_fixed16(uint32_t val,
 
        interm_val = (uint64_t)val << 16;
        interm_val = DIV_ROUND_UP_ULL(interm_val, d.val);
-       WARN_ON(interm_val >> 32);
-       return clamp_t(uint32_t, interm_val, 0, ~0);
+       WARN_ON(interm_val > U32_MAX);
+       return (uint32_t) interm_val;
 }
 
 static inline uint_fixed_16_16_t mul_u32_fixed16(uint32_t val,