From 142a1e186e1189ee206a61616fead7fc366989bb Mon Sep 17 00:00:00 2001 From: buxiasen Date: Fri, 31 May 2024 23:17:06 +0800 Subject: [PATCH] pm: remove pm_lock spinlock wrapper Signed-off-by: buxiasen --- drivers/power/pm/greedy_governor.c | 4 +-- drivers/power/pm/pm.h | 38 --------------------------- drivers/power/pm/pm_activity.c | 16 +++++------ drivers/power/pm/pm_lock.c | 37 +++++++++++++++++++++----- drivers/power/pm/pm_register.c | 6 ++--- drivers/power/pm/pm_unregister.c | 4 +-- drivers/power/pm/stability_governor.c | 4 +-- 7 files changed, 47 insertions(+), 62 deletions(-) diff --git a/drivers/power/pm/greedy_governor.c b/drivers/power/pm/greedy_governor.c index 8bf4675052..09e182caad 100644 --- a/drivers/power/pm/greedy_governor.c +++ b/drivers/power/pm/greedy_governor.c @@ -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 */ diff --git a/drivers/power/pm/pm.h b/drivers/power/pm/pm.h index a925196fc8..2b78ffdf62 100644 --- a/drivers/power/pm/pm.h +++ b/drivers/power/pm/pm.h @@ -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 * diff --git a/drivers/power/pm/pm_activity.c b/drivers/power/pm/pm_activity.c index c7b10e7a0d..2398cd25b5 100644 --- a/drivers/power/pm/pm_activity.c +++ b/drivers/power/pm/pm_activity.c @@ -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); } diff --git a/drivers/power/pm/pm_lock.c b/drivers/power/pm/pm_lock.c index aa0f1a6ed3..3690355670 100644 --- a/drivers/power/pm/pm_lock.c +++ b/drivers/power/pm/pm_lock.c @@ -23,12 +23,7 @@ ****************************************************************************/ #include - -#include -#include #include -#include -#include #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 */ diff --git a/drivers/power/pm/pm_register.c b/drivers/power/pm/pm_register.c index 84e155ac01..a9e5093de3 100644 --- a/drivers/power/pm/pm_register.c +++ b/drivers/power/pm/pm_register.c @@ -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; } diff --git a/drivers/power/pm/pm_unregister.c b/drivers/power/pm/pm_unregister.c index 9cb003215a..12a9ebcb5e 100644 --- a/drivers/power/pm/pm_unregister.c +++ b/drivers/power/pm/pm_unregister.c @@ -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; } diff --git a/drivers/power/pm/stability_governor.c b/drivers/power/pm/stability_governor.c index f132630015..bffa27f6df 100644 --- a/drivers/power/pm/stability_governor.c +++ b/drivers/power/pm/stability_governor.c @@ -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 */