These changes are the raw update to linux-4.4.6-rt14. Kernel sources
[kvmfornfv.git] / kernel / drivers / clk / mxs / clk-frac.c
index e6aa6b5..f8dd10f 100644 (file)
@@ -9,7 +9,6 @@
  * http://www.gnu.org/copyleft/gpl.html
  */
 
-#include <linux/clk.h>
 #include <linux/clk-provider.h>
 #include <linux/err.h>
 #include <linux/io.h>
@@ -42,11 +41,13 @@ static unsigned long clk_frac_recalc_rate(struct clk_hw *hw,
 {
        struct clk_frac *frac = to_clk_frac(hw);
        u32 div;
+       u64 tmp_rate;
 
        div = readl_relaxed(frac->reg) >> frac->shift;
        div &= (1 << frac->width) - 1;
 
-       return (parent_rate >> frac->width) * div;
+       tmp_rate = (u64)parent_rate * div;
+       return tmp_rate >> frac->width;
 }
 
 static long clk_frac_round_rate(struct clk_hw *hw, unsigned long rate,
@@ -55,7 +56,7 @@ static long clk_frac_round_rate(struct clk_hw *hw, unsigned long rate,
        struct clk_frac *frac = to_clk_frac(hw);
        unsigned long parent_rate = *prate;
        u32 div;
-       u64 tmp;
+       u64 tmp, tmp_rate, result;
 
        if (rate > parent_rate)
                return -EINVAL;
@@ -68,7 +69,11 @@ static long clk_frac_round_rate(struct clk_hw *hw, unsigned long rate,
        if (!div)
                return -EINVAL;
 
-       return (parent_rate >> frac->width) * div;
+       tmp_rate = (u64)parent_rate * div;
+       result = tmp_rate >> frac->width;
+       if ((result << frac->width) < tmp_rate)
+               result += 1;
+       return result;
 }
 
 static int clk_frac_set_rate(struct clk_hw *hw, unsigned long rate,