You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ma...@apache.org on 2016/09/21 16:09:06 UTC

[2/2] incubator-mynewt-core git commit: newtmgr; don't export os_eventq for newtmgr task.

newtmgr; don't export os_eventq for newtmgr task.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/f4a35434
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/f4a35434
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/f4a35434

Branch: refs/heads/develop
Commit: f4a3543447811d76e154fa220aad2ce18f9424f6
Parents: ad9ce1c
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Wed Sep 21 09:07:59 2016 -0700
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Wed Sep 21 09:07:59 2016 -0700

----------------------------------------------------------------------
 libs/newtmgr/include/newtmgr/newtmgr_priv.h     | 24 --------------------
 libs/newtmgr/nmgr_os/include/nmgr_os/nmgr_os.h  |  3 ++-
 libs/newtmgr/nmgr_os/src/newtmgr_os.c           |  9 +++-----
 libs/newtmgr/src/newtmgr.c                      |  8 +++----
 libs/newtmgr_oic/include/newtmgr/newtmgr_priv.h | 24 --------------------
 libs/newtmgr_oic/src/newtmgr.c                  | 22 ++++++++----------
 6 files changed, 17 insertions(+), 73 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f4a35434/libs/newtmgr/include/newtmgr/newtmgr_priv.h
----------------------------------------------------------------------
diff --git a/libs/newtmgr/include/newtmgr/newtmgr_priv.h b/libs/newtmgr/include/newtmgr/newtmgr_priv.h
deleted file mode 100644
index 7217711..0000000
--- a/libs/newtmgr/include/newtmgr/newtmgr_priv.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-#ifndef __NETMGR_PRIV_H_
-#define __NETMGR_PRIV_H_
-
-extern struct os_eventq g_nmgr_evq;
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f4a35434/libs/newtmgr/nmgr_os/include/nmgr_os/nmgr_os.h
----------------------------------------------------------------------
diff --git a/libs/newtmgr/nmgr_os/include/nmgr_os/nmgr_os.h b/libs/newtmgr/nmgr_os/include/nmgr_os/nmgr_os.h
index 49b6725..43de227 100644
--- a/libs/newtmgr/nmgr_os/include/nmgr_os/nmgr_os.h
+++ b/libs/newtmgr/nmgr_os/include/nmgr_os/nmgr_os.h
@@ -30,6 +30,7 @@
 #define NMGR_ID_DATETIME_STR    4
 #define NMGR_ID_RESET           5
 
-int nmgr_os_groups_register(void);
+struct os_eventq;
+int nmgr_os_groups_register(struct os_eventq *nmgr_evq);
 
 #endif /* _NMGR_OS_H_ */

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f4a35434/libs/newtmgr/nmgr_os/src/newtmgr_os.c
----------------------------------------------------------------------
diff --git a/libs/newtmgr/nmgr_os/src/newtmgr_os.c b/libs/newtmgr/nmgr_os/src/newtmgr_os.c
index cab692b..6c1a12f 100644
--- a/libs/newtmgr/nmgr_os/src/newtmgr_os.c
+++ b/libs/newtmgr/nmgr_os/src/newtmgr_os.c
@@ -26,7 +26,6 @@
 #include <hal/hal_system.h>
 
 #include <newtmgr/newtmgr.h>
-#include <newtmgr/newtmgr_priv.h>
 
 #include <console/console.h>
 #include <util/datetime.h>
@@ -309,10 +308,6 @@ nmgr_reset_tmo(void *arg)
 static int
 nmgr_reset(struct nmgr_jbuf *njb)
 {
-    if (nmgr_reset_callout.cf_func == NULL) {
-        os_callout_func_init(&nmgr_reset_callout, &g_nmgr_evq,
-          nmgr_reset_tmo, NULL);
-    }
     log_reboot(SOFT_REBOOT);
     os_callout_reset(&nmgr_reset_callout.cf_c, OS_TICKS_PER_SEC / 4);
 
@@ -322,8 +317,10 @@ nmgr_reset(struct nmgr_jbuf *njb)
 }
 
 int
-nmgr_os_groups_register(void)
+nmgr_os_groups_register(struct os_eventq *nmgr_evq)
 {
+    os_callout_func_init(&nmgr_reset_callout, nmgr_evq, nmgr_reset_tmo, NULL);
+
     return nmgr_group_register(&nmgr_def_group);
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f4a35434/libs/newtmgr/src/newtmgr.c
----------------------------------------------------------------------
diff --git a/libs/newtmgr/src/newtmgr.c b/libs/newtmgr/src/newtmgr.c
index f9d3846..8ff2ea3 100644
--- a/libs/newtmgr/src/newtmgr.c
+++ b/libs/newtmgr/src/newtmgr.c
@@ -27,14 +27,12 @@
 #include <newtmgr/newtmgr.h>
 #include <nmgr_os/nmgr_os.h>
 
-#include "newtmgr/newtmgr_priv.h"
-
 struct nmgr_transport g_nmgr_shell_transport;
 
 struct os_mutex g_nmgr_group_list_lock;
 
-struct os_eventq g_nmgr_evq;
-struct os_task g_nmgr_task;
+static struct os_eventq g_nmgr_evq;
+static struct os_task g_nmgr_task;
 
 STAILQ_HEAD(, nmgr_group) g_nmgr_group_list =
     STAILQ_HEAD_INITIALIZER(g_nmgr_group_list);
@@ -552,7 +550,7 @@ nmgr_task_init(uint8_t prio, os_stack_t *stack_ptr, uint16_t stack_len)
         goto err;
     }
 
-    rc = nmgr_os_groups_register();
+    rc = nmgr_os_groups_register(&g_nmgr_evq);
     if (rc != 0) {
         goto err;
     }

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f4a35434/libs/newtmgr_oic/include/newtmgr/newtmgr_priv.h
----------------------------------------------------------------------
diff --git a/libs/newtmgr_oic/include/newtmgr/newtmgr_priv.h b/libs/newtmgr_oic/include/newtmgr/newtmgr_priv.h
deleted file mode 100644
index 7217711..0000000
--- a/libs/newtmgr_oic/include/newtmgr/newtmgr_priv.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-#ifndef __NETMGR_PRIV_H_
-#define __NETMGR_PRIV_H_
-
-extern struct os_eventq g_nmgr_evq;
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f4a35434/libs/newtmgr_oic/src/newtmgr.c
----------------------------------------------------------------------
diff --git a/libs/newtmgr_oic/src/newtmgr.c b/libs/newtmgr_oic/src/newtmgr.c
index 434bf46..4d7f25b 100644
--- a/libs/newtmgr_oic/src/newtmgr.c
+++ b/libs/newtmgr_oic/src/newtmgr.c
@@ -28,18 +28,17 @@
 
 #include <iotivity/oc_api.h>
 
-#include "newtmgr/newtmgr_priv.h"
-
 #define NMGR_OC_EVENT	(OS_EVENT_T_PERUSER)
 #define NMGR_OC_TIMER	(OS_EVENT_T_PERUSER + 1)
 
 struct nmgr_state {
     struct os_mutex ns_group_lock;
     STAILQ_HEAD(, nmgr_group) ns_groups;
+    struct os_eventq ns_evq;
     struct os_event ns_oc_event;
     struct os_callout ns_oc_timer;
     struct os_task ns_task;
-    struct nmgr_jbuf ns_jbuf;
+    struct nmgr_jbuf ns_jbuf;		/* JSON buffer for NMGR task */
     char ns_rsp[NMGR_MAX_MTU];
 };
 
@@ -47,13 +46,8 @@ static struct nmgr_state nmgr_state = {
   .ns_groups = STAILQ_HEAD_INITIALIZER(nmgr_state.ns_groups),
   .ns_oc_event.ev_type = NMGR_OC_EVENT,
   .ns_oc_timer.c_ev.ev_type = NMGR_OC_TIMER,
-  .ns_oc_timer.c_evq = &g_nmgr_evq
+  .ns_oc_timer.c_evq = &nmgr_state.ns_evq
 };
-struct os_eventq g_nmgr_evq;
-
-/* JSON buffer for NMGR task
- */
-
 
 static void nmgr_oic_get(oc_request_t *request, oc_interface_mask_t interface);
 static void nmgr_oic_put(oc_request_t *request, oc_interface_mask_t interface);
@@ -445,7 +439,9 @@ static const oc_handler_t nmgr_oc_handler = {
 void
 oc_signal_main_loop(void)
 {
-    os_eventq_put(&g_nmgr_evq, &nmgr_state.ns_oc_event);
+    struct nmgr_state *ns = &nmgr_state;
+
+    os_eventq_put(&ns->ns_evq, &ns->ns_oc_event);
 }
 
 void
@@ -460,7 +456,7 @@ nmgr_oic_task(void *arg)
 
     oc_main_init((oc_handler_t *)&nmgr_oc_handler);
     while (1) {
-        ev = os_eventq_get(&g_nmgr_evq);
+        ev = os_eventq_get(&ns->ns_evq);
         switch (ev->ev_type) {
         case NMGR_OC_EVENT:
         case NMGR_OC_TIMER:
@@ -485,7 +481,7 @@ nmgr_oic_init(uint8_t prio, os_stack_t *stack_ptr, uint16_t stack_len)
     struct nmgr_state *ns = &nmgr_state;
     int rc;
 
-    os_eventq_init(&g_nmgr_evq);
+    os_eventq_init(&ns->ns_evq);
 
     rc = os_task_init(&ns->ns_task, "newtmgr_oic", nmgr_oic_task, NULL, prio,
             OS_WAIT_FOREVER, stack_ptr, stack_len);
@@ -493,7 +489,7 @@ nmgr_oic_init(uint8_t prio, os_stack_t *stack_ptr, uint16_t stack_len)
         goto err;
     }
 
-    rc = nmgr_os_groups_register();
+    rc = nmgr_os_groups_register(&ns->ns_evq);
     if (rc != 0) {
         goto err;
     }