Merge tag 'omap-for-v3.17/soc-fixes' of git://git.kernel.org/pub/scm/linux/kernel...
authorOlof Johansson <olof@lixom.net>
Sat, 9 Aug 2014 15:23:27 +0000 (08:23 -0700)
committerOlof Johansson <olof@lixom.net>
Sat, 9 Aug 2014 15:23:27 +0000 (08:23 -0700)
Merge "few omap fixes for v3.17 merge window" from Tony Lindgren:

Few fixes for the v3.17 merge window:

- Fix for DPLL rate rounding
- Fix for omap3 ES3.1.2 suspend
- Few coding style fixes

* tag 'omap-for-v3.17/soc-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tmlind/linux-omap:
  ARM: OMAP3: Fix coding style problems in arch/arm/mach-omap2/control.c
  ARM: OMAP3: Fix choice of omap3_restore_es function in OMAP34XX rev3.1.2 case.
  ARM: OMAP2+: clock: allow omap2_dpll_round_rate() to round to next-lowest rate

Signed-off-by: Olof Johansson <olof@lixom.net>
1  2 
arch/arm/mach-omap2/clkt_dpll.c

index b2ff6cd7ca9f0f35e01208475a9daa58f92a7e63,950308fa30d34334746fc210faf1bb58eb6bde95..f251a14cbf16a05b1cfd1f3157a83ae0053d8203
@@@ -65,7 -65,7 +65,7 @@@
   * (assuming that it is counting N upwards), or -2 if the enclosing loop
   * should skip to the next iteration (again assuming N is increasing).
   */
 -static int _dpll_test_fint(struct clk_hw_omap *clk, u8 n)
 +static int _dpll_test_fint(struct clk_hw_omap *clk, unsigned int n)
  {
        struct dpll_data *dd;
        long fint, fint_min, fint_max;
@@@ -285,10 -285,13 +285,13 @@@ long omap2_dpll_round_rate(struct clk_h
  {
        struct clk_hw_omap *clk = to_clk_hw_omap(hw);
        int m, n, r, scaled_max_m;
+       int min_delta_m = INT_MAX, min_delta_n = INT_MAX;
        unsigned long scaled_rt_rp;
        unsigned long new_rate = 0;
        struct dpll_data *dd;
        unsigned long ref_rate;
+       long delta;
+       long prev_min_delta = LONG_MAX;
        const char *clk_name;
  
        if (!clk || !clk->dpll_data)
                if (r == DPLL_MULT_UNDERFLOW)
                        continue;
  
+               /* skip rates above our target rate */
+               delta = target_rate - new_rate;
+               if (delta < 0)
+                       continue;
+               if (delta < prev_min_delta) {
+                       prev_min_delta = delta;
+                       min_delta_m = m;
+                       min_delta_n = n;
+               }
                pr_debug("clock: %s: m = %d: n = %d: new_rate = %lu\n",
                         clk_name, m, n, new_rate);
  
-               if (target_rate == new_rate) {
-                       dd->last_rounded_m = m;
-                       dd->last_rounded_n = n;
-                       dd->last_rounded_rate = target_rate;
+               if (delta == 0)
                        break;
-               }
        }
  
-       if (target_rate != new_rate) {
+       if (prev_min_delta == LONG_MAX) {
                pr_debug("clock: %s: cannot round to rate %lu\n",
                         clk_name, target_rate);
                return ~0;
        }
  
-       return target_rate;
+       dd->last_rounded_m = min_delta_m;
+       dd->last_rounded_n = min_delta_n;
+       dd->last_rounded_rate = target_rate - prev_min_delta;
+       return dd->last_rounded_rate;
  }