aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-omap2/clockdomain.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-omap2/clockdomain.c')
-rw-r--r--arch/arm/mach-omap2/clockdomain.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/arch/arm/mach-omap2/clockdomain.c b/arch/arm/mach-omap2/clockdomain.c
index cbb879139c51..512e79a842cb 100644
--- a/arch/arm/mach-omap2/clockdomain.c
+++ b/arch/arm/mach-omap2/clockdomain.c
@@ -925,15 +925,18 @@ static int _clkdm_clk_hwmod_enable(struct clockdomain *clkdm)
925 if (!clkdm || !arch_clkdm || !arch_clkdm->clkdm_clk_enable) 925 if (!clkdm || !arch_clkdm || !arch_clkdm->clkdm_clk_enable)
926 return -EINVAL; 926 return -EINVAL;
927 927
928 spin_lock_irqsave(&clkdm->lock, flags);
929
928 /* 930 /*
929 * For arch's with no autodeps, clkcm_clk_enable 931 * For arch's with no autodeps, clkcm_clk_enable
930 * should be called for every clock instance or hwmod that is 932 * should be called for every clock instance or hwmod that is
931 * enabled, so the clkdm can be force woken up. 933 * enabled, so the clkdm can be force woken up.
932 */ 934 */
933 if ((atomic_inc_return(&clkdm->usecount) > 1) && autodeps) 935 if ((atomic_inc_return(&clkdm->usecount) > 1) && autodeps) {
936 spin_unlock_irqrestore(&clkdm->lock, flags);
934 return 0; 937 return 0;
938 }
935 939
936 spin_lock_irqsave(&clkdm->lock, flags);
937 arch_clkdm->clkdm_clk_enable(clkdm); 940 arch_clkdm->clkdm_clk_enable(clkdm);
938 pwrdm_state_switch(clkdm->pwrdm.ptr); 941 pwrdm_state_switch(clkdm->pwrdm.ptr);
939 spin_unlock_irqrestore(&clkdm->lock, flags); 942 spin_unlock_irqrestore(&clkdm->lock, flags);
@@ -950,15 +953,19 @@ static int _clkdm_clk_hwmod_disable(struct clockdomain *clkdm)
950 if (!clkdm || !arch_clkdm || !arch_clkdm->clkdm_clk_disable) 953 if (!clkdm || !arch_clkdm || !arch_clkdm->clkdm_clk_disable)
951 return -EINVAL; 954 return -EINVAL;
952 955
956 spin_lock_irqsave(&clkdm->lock, flags);
957
953 if (atomic_read(&clkdm->usecount) == 0) { 958 if (atomic_read(&clkdm->usecount) == 0) {
959 spin_unlock_irqrestore(&clkdm->lock, flags);
954 WARN_ON(1); /* underflow */ 960 WARN_ON(1); /* underflow */
955 return -ERANGE; 961 return -ERANGE;
956 } 962 }
957 963
958 if (atomic_dec_return(&clkdm->usecount) > 0) 964 if (atomic_dec_return(&clkdm->usecount) > 0) {
965 spin_unlock_irqrestore(&clkdm->lock, flags);
959 return 0; 966 return 0;
967 }
960 968
961 spin_lock_irqsave(&clkdm->lock, flags);
962 arch_clkdm->clkdm_clk_disable(clkdm); 969 arch_clkdm->clkdm_clk_disable(clkdm);
963 pwrdm_state_switch(clkdm->pwrdm.ptr); 970 pwrdm_state_switch(clkdm->pwrdm.ptr);
964 spin_unlock_irqrestore(&clkdm->lock, flags); 971 spin_unlock_irqrestore(&clkdm->lock, flags);