diff options
Diffstat (limited to 'arch/arm/mach-omap2/clockdomain.c')
| -rw-r--r-- | arch/arm/mach-omap2/clockdomain.c | 18 | 
1 files changed, 13 insertions, 5 deletions
diff --git a/arch/arm/mach-omap2/clockdomain.c b/arch/arm/mach-omap2/clockdomain.c index cbb879139c5..64e50465a4b 100644 --- a/arch/arm/mach-omap2/clockdomain.c +++ b/arch/arm/mach-omap2/clockdomain.c @@ -27,7 +27,8 @@  #include <linux/bitops.h> -#include <plat/clock.h> +#include "soc.h" +#include "clock.h"  #include "clockdomain.h"  /* clkdm_list contains all registered struct clockdomains */ @@ -925,15 +926,18 @@ static int _clkdm_clk_hwmod_enable(struct clockdomain *clkdm)  	if (!clkdm || !arch_clkdm || !arch_clkdm->clkdm_clk_enable)  		return -EINVAL; +	spin_lock_irqsave(&clkdm->lock, flags); +  	/*  	 * For arch's with no autodeps, clkcm_clk_enable  	 * should be called for every clock instance or hwmod that is  	 * enabled, so the clkdm can be force woken up.  	 */ -	if ((atomic_inc_return(&clkdm->usecount) > 1) && autodeps) +	if ((atomic_inc_return(&clkdm->usecount) > 1) && autodeps) { +		spin_unlock_irqrestore(&clkdm->lock, flags);  		return 0; +	} -	spin_lock_irqsave(&clkdm->lock, flags);  	arch_clkdm->clkdm_clk_enable(clkdm);  	pwrdm_state_switch(clkdm->pwrdm.ptr);  	spin_unlock_irqrestore(&clkdm->lock, flags); @@ -950,15 +954,19 @@ static int _clkdm_clk_hwmod_disable(struct clockdomain *clkdm)  	if (!clkdm || !arch_clkdm || !arch_clkdm->clkdm_clk_disable)  		return -EINVAL; +	spin_lock_irqsave(&clkdm->lock, flags); +  	if (atomic_read(&clkdm->usecount) == 0) { +		spin_unlock_irqrestore(&clkdm->lock, flags);  		WARN_ON(1); /* underflow */  		return -ERANGE;  	} -	if (atomic_dec_return(&clkdm->usecount) > 0) +	if (atomic_dec_return(&clkdm->usecount) > 0) { +		spin_unlock_irqrestore(&clkdm->lock, flags);  		return 0; +	} -	spin_lock_irqsave(&clkdm->lock, flags);  	arch_clkdm->clkdm_clk_disable(clkdm);  	pwrdm_state_switch(clkdm->pwrdm.ptr);  	spin_unlock_irqrestore(&clkdm->lock, flags);  |