You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ma...@apache.org on 2022/02/22 08:33:23 UTC

[incubator-nuttx] 02/02: Revert "pm: remove unnecessary depends on OSINIT_OS_READY"

This is an automated email from the ASF dual-hosted git repository.

masayuki pushed a commit to branch revert-5577-mine
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 8781ae546f4736a5648fc9f509670c93c859bf1d
Author: Masayuki Ishikawa <ma...@gmail.com>
AuthorDate: Tue Feb 22 17:33:14 2022 +0900

    Revert "pm: remove unnecessary depends on OSINIT_OS_READY"
    
    This reverts commit 8785673a7048d83d49327bbc1c9a6a17e6a8b27c.
---
 drivers/power/pm_register.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/power/pm_register.c b/drivers/power/pm_register.c
index fa95b8e..3c68f31 100644
--- a/drivers/power/pm_register.c
+++ b/drivers/power/pm_register.c
@@ -62,11 +62,19 @@ int pm_register(FAR struct pm_callback_s *callbacks)
 
   /* Add the new entry to the end of the list of registered callbacks */
 
-  ret = pm_lock();
-  if (ret == OK)
+  if (OSINIT_OS_READY())
+    {
+      ret = pm_lock();
+      if (ret == OK)
+        {
+          dq_addlast(&callbacks->entry, &g_pmglobals.registry);
+          pm_unlock();
+        }
+    }
+  else
     {
       dq_addlast(&callbacks->entry, &g_pmglobals.registry);
-      pm_unlock();
+      ret = OK;
     }
 
   return ret;