pm: remove pm_lock spinlock wrapper
Signed-off-by: buxiasen <buxiasen@xiaomi.com>
This commit is contained in:
parent
870d989d6c
commit
142a1e186e
|
@ -101,7 +101,7 @@ static enum pm_state_e greedy_governor_checkstate(int domain)
|
|||
* invoked, which modifies the stay count which we are about to read
|
||||
*/
|
||||
|
||||
flags = pm_lock(&pdom->lock);
|
||||
flags = spin_lock_irqsave(&pdom->lock);
|
||||
|
||||
/* Find the lowest power-level which is not locked. */
|
||||
|
||||
|
@ -110,7 +110,7 @@ static enum pm_state_e greedy_governor_checkstate(int domain)
|
|||
state++;
|
||||
}
|
||||
|
||||
pm_unlock(&pdom->lock, flags);
|
||||
spin_unlock_irqrestore(&pdom->lock, flags);
|
||||
|
||||
/* Return the found state */
|
||||
|
||||
|
|
|
@ -114,44 +114,6 @@ EXTERN struct pm_domain_s g_pmdomains[CONFIG_PM_NDOMAINS];
|
|||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: pm_lock
|
||||
*
|
||||
* Description:
|
||||
* Lock the power management operation.
|
||||
*
|
||||
* Input Parameters:
|
||||
* lock - The lock subjuct
|
||||
*
|
||||
* Returned Value:
|
||||
* Return current state
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static inline irqstate_t pm_lock(FAR spinlock_t *lock)
|
||||
{
|
||||
return spin_lock_irqsave(lock);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: pm_unlock
|
||||
*
|
||||
* Description:
|
||||
* Unlock the power management operation.
|
||||
*
|
||||
* Input Parameters:
|
||||
* lock - The lock subjuct
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static inline void pm_unlock(FAR spinlock_t *lock, irqstate_t flags)
|
||||
{
|
||||
spin_unlock_irqrestore(lock, flags);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: pm_domain_lock
|
||||
*
|
||||
|
|
|
@ -305,7 +305,7 @@ void pm_wakelock_uninit(FAR struct pm_wakelock_s *wakelock)
|
|||
dq = &pdom->wakelock[wakelock->state];
|
||||
wdog = &wakelock->wdog;
|
||||
|
||||
flags = pm_lock(&pdom->lock);
|
||||
flags = spin_lock_irqsave(&pdom->lock);
|
||||
|
||||
if (wakelock->count > 0)
|
||||
{
|
||||
|
@ -316,7 +316,7 @@ void pm_wakelock_uninit(FAR struct pm_wakelock_s *wakelock)
|
|||
wd_cancel(wdog);
|
||||
pm_wakelock_stats_rm(wakelock);
|
||||
|
||||
pm_unlock(&pdom->lock, flags);
|
||||
spin_unlock_irqrestore(&pdom->lock, flags);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -353,7 +353,7 @@ void pm_wakelock_stay(FAR struct pm_wakelock_s *wakelock)
|
|||
pdom = &g_pmdomains[domain];
|
||||
dq = &pdom->wakelock[wakelock->state];
|
||||
|
||||
flags = pm_lock(&pdom->lock);
|
||||
flags = spin_lock_irqsave(&pdom->lock);
|
||||
|
||||
DEBUGASSERT(wakelock->count < UINT32_MAX);
|
||||
if (wakelock->count++ == 0)
|
||||
|
@ -362,7 +362,7 @@ void pm_wakelock_stay(FAR struct pm_wakelock_s *wakelock)
|
|||
pm_wakelock_stats(wakelock, true);
|
||||
}
|
||||
|
||||
pm_unlock(&pdom->lock, flags);
|
||||
spin_unlock_irqrestore(&pdom->lock, flags);
|
||||
|
||||
pm_auto_updatestate(domain);
|
||||
}
|
||||
|
@ -400,7 +400,7 @@ void pm_wakelock_relax(FAR struct pm_wakelock_s *wakelock)
|
|||
pdom = &g_pmdomains[domain];
|
||||
dq = &pdom->wakelock[wakelock->state];
|
||||
|
||||
flags = pm_lock(&pdom->lock);
|
||||
flags = spin_lock_irqsave(&pdom->lock);
|
||||
|
||||
DEBUGASSERT(wakelock->count > 0);
|
||||
if (--wakelock->count == 0)
|
||||
|
@ -409,7 +409,7 @@ void pm_wakelock_relax(FAR struct pm_wakelock_s *wakelock)
|
|||
pm_wakelock_stats(wakelock, false);
|
||||
}
|
||||
|
||||
pm_unlock(&pdom->lock, flags);
|
||||
spin_unlock_irqrestore(&pdom->lock, flags);
|
||||
|
||||
pm_auto_updatestate(domain);
|
||||
}
|
||||
|
@ -452,7 +452,7 @@ void pm_wakelock_staytimeout(FAR struct pm_wakelock_s *wakelock, int ms)
|
|||
dq = &pdom->wakelock[wakelock->state];
|
||||
wdog = &wakelock->wdog;
|
||||
|
||||
flags = pm_lock(&pdom->lock);
|
||||
flags = spin_lock_irqsave(&pdom->lock);
|
||||
|
||||
if (!WDOG_ISACTIVE(wdog))
|
||||
{
|
||||
|
@ -469,7 +469,7 @@ void pm_wakelock_staytimeout(FAR struct pm_wakelock_s *wakelock, int ms)
|
|||
wd_start(wdog, MSEC2TICK(ms), pm_waklock_cb, (wdparm_t)wakelock);
|
||||
}
|
||||
|
||||
pm_unlock(&pdom->lock, flags);
|
||||
spin_unlock_irqrestore(&pdom->lock, flags);
|
||||
|
||||
pm_auto_updatestate(domain);
|
||||
}
|
||||
|
|
|
@ -23,12 +23,7 @@
|
|||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/power/pm.h>
|
||||
#include <assert.h>
|
||||
#include <sched.h>
|
||||
#include "pm.h"
|
||||
|
||||
#if defined(CONFIG_PM)
|
||||
|
@ -37,14 +32,42 @@
|
|||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: pm_domain_lock
|
||||
*
|
||||
* Description:
|
||||
* Lock the power management operation.
|
||||
*
|
||||
* Input Parameters:
|
||||
* domain - The PM domain to lock
|
||||
*
|
||||
* Returned Value:
|
||||
* Return current state
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
irqstate_t pm_domain_lock(int domain)
|
||||
{
|
||||
return pm_lock(&g_pmdomains[domain].lock);
|
||||
return spin_lock_irqsave(&g_pmdomains[domain].lock);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: pm_domain_unlock
|
||||
*
|
||||
* Description:
|
||||
* Unlock the power management operation.
|
||||
*
|
||||
* Input Parameters:
|
||||
* domain - The PM domain to unlock
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void pm_domain_unlock(int domain, irqstate_t flags)
|
||||
{
|
||||
pm_unlock(&g_pmdomains[domain].lock, flags);
|
||||
spin_unlock_irqrestore(&g_pmdomains[domain].lock, flags);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_PM */
|
||||
|
|
|
@ -58,8 +58,8 @@
|
|||
int pm_domain_register(int domain, FAR struct pm_callback_s *cb)
|
||||
{
|
||||
irqstate_t flags;
|
||||
FAR struct pm_domain_s *pdom = &g_pmdomains[domain];
|
||||
flags = pm_lock(&pdom->lock);
|
||||
struct pm_domain_s *pdom = &g_pmdomains[domain];
|
||||
flags = spin_lock_irqsave(&pdom->lock);
|
||||
|
||||
/* Add the new entry to the end of the list of registered callbacks */
|
||||
|
||||
|
@ -67,7 +67,7 @@ int pm_domain_register(int domain, FAR struct pm_callback_s *cb)
|
|||
#if defined (CONFIG_PM_PROCFS)
|
||||
cb->preparefail.state = PM_RESTORE;
|
||||
#endif
|
||||
pm_unlock(&pdom->lock, flags);
|
||||
spin_unlock_irqrestore(&pdom->lock, flags);
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -58,12 +58,12 @@ int pm_domain_unregister(int domain, FAR struct pm_callback_s *cb)
|
|||
{
|
||||
irqstate_t flags;
|
||||
struct pm_domain_s *pdom = &g_pmdomains[domain];
|
||||
flags = pm_lock(&pdom->lock);
|
||||
flags = spin_lock_irqsave(&pdom->lock);
|
||||
|
||||
/* Remove entry from the list of registered callbacks. */
|
||||
|
||||
dq_rem(&cb->entry, &pdom->registry);
|
||||
pm_unlock(&pdom->lock, flags);
|
||||
spin_unlock_irqrestore(&pdom->lock, flags);
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -165,7 +165,7 @@ static enum pm_state_e stability_governor_checkstate(int domain)
|
|||
* invoked, which modifies the stay count which we are about to read
|
||||
*/
|
||||
|
||||
flags = pm_lock(&pdom->lock);
|
||||
flags = spin_lock_irqsave(&pdom->lock);
|
||||
|
||||
/* Find the lowest power-level which is not locked. */
|
||||
|
||||
|
@ -201,7 +201,7 @@ static enum pm_state_e stability_governor_checkstate(int domain)
|
|||
}
|
||||
}
|
||||
|
||||
pm_unlock(&pdom->lock, flags);
|
||||
spin_unlock_irqrestore(&pdom->lock, flags);
|
||||
|
||||
/* Return the found state */
|
||||
|
||||
|
|
Loading…
Reference in New Issue