You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by vi...@apache.org on 2021/02/10 20:02:36 UTC
[mynewt-mcumgr] branch master updated: mgmt: Add support for
un-registering a group along with the same support in img_mgmt (#108)
This is an automated email from the ASF dual-hosted git repository.
vipulrahane pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-mcumgr.git
The following commit(s) were added to refs/heads/master by this push:
new fb489e1 mgmt: Add support for un-registering a group along with the same support in img_mgmt (#108)
fb489e1 is described below
commit fb489e1f9b3bcc536d467a9f04a59fc0fde8ea07
Author: Vipul Rahane <vi...@apache.org>
AuthorDate: Wed Feb 10 12:02:30 2021 -0800
mgmt: Add support for un-registering a group along with the same support in img_mgmt (#108)
- Add support for unregistering command group at runtime
- Add support for unregistering img_mgmt_group at runtime
---
cmd/img_mgmt/include/img_mgmt/img_mgmt.h | 5 +++++
cmd/img_mgmt/src/img_mgmt.c | 6 ++++++
mgmt/include/mgmt/mgmt.h | 8 ++++++++
mgmt/src/mgmt.c | 25 +++++++++++++++++++++++++
4 files changed, 44 insertions(+)
diff --git a/cmd/img_mgmt/include/img_mgmt/img_mgmt.h b/cmd/img_mgmt/include/img_mgmt/img_mgmt.h
index 78e6ba5..69f6f1b 100644
--- a/cmd/img_mgmt/include/img_mgmt/img_mgmt.h
+++ b/cmd/img_mgmt/include/img_mgmt/img_mgmt.h
@@ -120,6 +120,11 @@ struct img_mgmt_upload_action {
void img_mgmt_register_group(void);
/**
+ * @brief Unregisters the image management command handler group.
+ */
+void img_mgmt_unregister_group(void);
+
+/*
* @brief Read info of an image give the slot number
*
* @param image_slot Image slot to read info from
diff --git a/cmd/img_mgmt/src/img_mgmt.c b/cmd/img_mgmt/src/img_mgmt.c
index 1a40ffc..9cb7b7d 100644
--- a/cmd/img_mgmt/src/img_mgmt.c
+++ b/cmd/img_mgmt/src/img_mgmt.c
@@ -608,3 +608,9 @@ img_mgmt_register_group(void)
{
mgmt_register_group(&img_mgmt_group);
}
+
+void
+img_mgmt_unregister_group(void)
+{
+ mgmt_unregister_group(&img_mgmt_group);
+}
diff --git a/mgmt/include/mgmt/mgmt.h b/mgmt/include/mgmt/mgmt.h
index 7ad22df..cb7e896 100644
--- a/mgmt/include/mgmt/mgmt.h
+++ b/mgmt/include/mgmt/mgmt.h
@@ -367,6 +367,14 @@ void mgmt_streamer_free_buf(struct mgmt_streamer *streamer, void *buf);
void mgmt_register_group(struct mgmt_group *group);
/**
+ * @brief Unregisters a full command group.
+ *
+ * @param group The group to register.
+ */
+void
+mgmt_unregister_group(struct mgmt_group *group);
+
+/**
* @brief Finds a registered command handler.
*
* @param group_id The group of the command to find.
diff --git a/mgmt/src/mgmt.c b/mgmt/src/mgmt.c
index 08343bb..77aa631 100644
--- a/mgmt/src/mgmt.c
+++ b/mgmt/src/mgmt.c
@@ -71,6 +71,31 @@ mgmt_streamer_free_buf(struct mgmt_streamer *streamer, void *buf)
streamer->cfg->free_buf(buf, streamer->cb_arg);
}
+void
+mgmt_unregister_group(struct mgmt_group *group)
+{
+ struct mgmt_group *curr = mgmt_group_list, *prev;
+
+ if (curr && curr == group) {
+ mgmt_group_list = curr->mg_next;
+ return;
+ }
+
+ while (curr && curr != group) {
+ prev = curr;
+ curr = curr->mg_next;
+ }
+
+ if (!curr) {
+ return;
+ }
+
+ prev->mg_next = curr->mg_next;
+ if (curr->mg_next == NULL) {
+ mgmt_group_list_end = curr;
+ }
+}
+
static struct mgmt_group *
mgmt_find_group(uint16_t group_id, uint16_t command_id)
{