ARM: tegra11: clock: Update direct access to CPU backup source
Alex Frid [Tue, 29 Jan 2013 20:49:42 +0000 (12:49 -0800)]
Minimized locking calls in CPU backup source direct access API.

Change-Id: I483537ce55e360259d2fbfbf85b705b53fe42e55
Signed-off-by: Alex Frid <afrid@nvidia.com>
Reviewed-on: http://git-master/r/195398
(cherry picked from commit 85da379e26fd01e14e4934a79a3286a72b1167d9)
Reviewed-on: http://git-master/r/196813
Reviewed-by: Mrutyunjay Sawant <msawant@nvidia.com>
Tested-by: Mrutyunjay Sawant <msawant@nvidia.com>

arch/arm/mach-tegra/tegra11_clocks.c

index 90a646c..47c6c67 100644 (file)
@@ -6940,14 +6940,21 @@ static void tegra11_init_one_clock(struct clk *c)
 
 int tegra11_cpu_backup_rate_exchange(unsigned long *rate)
 {
+       int ret = 0;
        struct clk *backup = tegra_clk_cpu_cmplx.parent->u.cpu.backup;
-       unsigned long old_rate = clk_get_rate(backup);
+       unsigned long old_rate, flags;
        unsigned long new_rate = min(
                *rate, tegra_clk_cpu_cmplx.parent->u.cpu.backup_rate);
+
+       clk_lock_save(backup, &flags);
+
+       old_rate = clk_get_rate_locked(backup);
        *rate = old_rate;
        if (new_rate != old_rate)
-               return clk_set_rate(backup, new_rate);
-       return 0;
+               ret = clk_set_rate_locked(backup, new_rate);
+
+       clk_unlock_restore(backup, &flags);
+       return ret;
 }
 
 void tegra_edp_throttle_cpu_now(u8 factor)