Skip to contentSkip to conversation

mesh: Remove redundant code in mesh IO mgmt

PATCH Applied Inga Stotland 2 participants 4 messages Dec 10, 2019 – Dec 15, 2019 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mesh: Remove redundant code in mesh IO mgmt

This removes unnecessary housekeeping for hci controllers

---
 mesh/mesh-mgmt.c | 22 ++--------------------
 1 file changed, 2 insertions(+), 20 deletions(-)
mesh/mesh-mgmt.c +2 -20
index 27272d4d2..2cf2ebac2 100644
@@ -42,14 +42,8 @@ struct read_info_req {
 };
 
 static struct mgmt *mgmt_mesh;
-static struct l_queue *controllers;
 static struct l_queue *read_info_regs;
 
-static bool simple_match(const void *a, const void *b)
-{
-	return a == b;
-}
-
 static void process_read_info_req(void *data, void *user_data)
 {
 	struct read_info_reg *reg = data;
@@ -101,23 +95,14 @@ static void read_info_cb(uint8_t status, uint16_t length,
 static void index_added(uint16_t index, uint16_t length, const void *param,
 							void *user_data)
 {
-	if (l_queue_find(controllers, simple_match, L_UINT_TO_PTR(index)))
-		return;
-
-	l_queue_push_tail(controllers, L_UINT_TO_PTR(index));
-
-	if (mgmt_send(mgmt_mesh, MGMT_OP_READ_INFO, index, 0, NULL,
-			read_info_cb, L_UINT_TO_PTR(index), NULL) != 0)
-		return;
-
-	l_queue_remove(controllers, L_UINT_TO_PTR(index));
+	mgmt_send(mgmt_mesh, MGMT_OP_READ_INFO, index, 0, NULL,
+				read_info_cb, L_UINT_TO_PTR(index), NULL);
 }
 
 static void index_removed(uint16_t index, uint16_t length, const void *param,
 							void *user_data)
 {
 	l_warn("Hci dev %4.4x removed", index);
-	l_queue_remove(controllers, L_UINT_TO_PTR(index));
 }
 
 static void read_index_list_cb(uint8_t status, uint16_t length,
@@ -157,9 +142,6 @@ static void read_index_list_cb(uint8_t status, uint16_t length,
 
 static bool mesh_mgmt_init(void)
 {
-	if (!controllers)
-		controllers = l_queue_new();
-
 	if (!read_info_regs)
 		read_info_regs = l_queue_new();
 
Signature · 1 line
2.21.0
#1 lore raw

Hi Inga,

Quoted 25 lines · Inga Stotland

This removes unnecessary housekeeping for hci controllers

---
 mesh/mesh-mgmt.c | 22 ++--------------------
 1 file changed, 2 insertions(+), 20 deletions(-)
mesh/mesh-mgmt.c +0 -6
index 27272d4d2..2cf2ebac2 100644
@@ -42,14 +42,8 @@ struct read_info_req {
 };
 
 static struct mgmt *mgmt_mesh;
-static struct l_queue *controllers;
 static struct l_queue *read_info_regs;
 
-static bool simple_match(const void *a, const void *b)
-{
-	return a == b;
-}
-
 static void process_read_info_req(void *data, void *user_data)
 {
 	struct read_info_reg *reg = data;

mesh/mesh-mgmt.c static void read_info_cb(uint8_t status, uint16_t length, · line 107

Quoted 7 lines
mesh/mesh-mgmt.c +0 -4
@@ -101,23 +95,14 @@ static void read_info_cb(uint8_t status, uint16_t length,
 static void index_added(uint16_t index, uint16_t length, const void *param,
 							void *user_data)
 {
-	if (l_queue_find(controllers, simple_match, L_UINT_TO_PTR(index)))
-		return;
-
-	l_queue_push_tail(controllers, L_UINT_TO_PTR(index));

I think before applying this, we should re-work the controller index to be consistently uint16_t, rather than the awkward mix of int and uint16_t.

Quoted 28 lines
mesh/mesh-mgmt.c +2 -10
-
-	if (mgmt_send(mgmt_mesh, MGMT_OP_READ_INFO, index, 0, NULL,
-			read_info_cb, L_UINT_TO_PTR(index), NULL) != 0)
-		return;
-
-	l_queue_remove(controllers, L_UINT_TO_PTR(index));
+	mgmt_send(mgmt_mesh, MGMT_OP_READ_INFO, index, 0, NULL,
+				read_info_cb, L_UINT_TO_PTR(index), NULL);
 }
 
 static void index_removed(uint16_t index, uint16_t length, const void *param,
 							void *user_data)
 {
 	l_warn("Hci dev %4.4x removed", index);
-	l_queue_remove(controllers, L_UINT_TO_PTR(index));
 }
 
 static void read_index_list_cb(uint8_t status, uint16_t length,
@@ -157,9 +142,6 @@ static void read_index_list_cb(uint8_t status, uint16_t length,
 
 static bool mesh_mgmt_init(void)
 {
-	if (!controllers)
-		controllers = l_queue_new();
-
 	if (!read_info_regs)
 		read_info_regs = l_queue_new();
 
#2 lore raw

Hi Brian,

Quoted 30 lines · Brian

Hi Inga,

Quoted 27 lines · Inga Stotland

This removes unnecessary housekeeping for hci controllers

---
 mesh/mesh-mgmt.c | 22 ++--------------------
 1 file changed, 2 insertions(+), 20 deletions(-)
mesh/mesh-mgmt.c +0 -6
index 27272d4d2..2cf2ebac2 100644
@@ -42,14 +42,8 @@ struct read_info_req {
 };
 
 static struct mgmt *mgmt_mesh;
-static struct l_queue *controllers;
 static struct l_queue *read_info_regs;
 
-static bool simple_match(const void *a, const void *b)
-{
-	return a == b;
-}
-
 static void process_read_info_req(void *data, void *user_data)
 {
 	struct read_info_reg *reg = data;
@@ -101,23 +95,14 @@ static void read_info_cb(uint8_t status, uint16_t length,
 static void index_added(uint16_t index, uint16_t length, const void *param,
 							void *user_data)
Quoted 8 lines

mesh/mesh-mgmt.c static void read_info_cb(uint8_t status, uint16_t length, · line 107

Quoted 5 lines
mesh/mesh-mgmt.c +0 -4
 {
-	if (l_queue_find(controllers, simple_match, L_UINT_TO_PTR(index)))
-		return;
-
-	l_queue_push_tail(controllers, L_UINT_TO_PTR(index));

I think before applying this, we should re-work the controller index to be consistently uint16_t, rather than the awkward mix of int and uint16_t.

I agree that consistency would be good.
However, I disagree that this needs to be a part of this patch: thios patch removes code that is not needed. Nothing to do with indices.

Quoted 21 lines
Quoted 21 lines
mesh/mesh-mgmt.c +2 -7
-
-	if (mgmt_send(mgmt_mesh, MGMT_OP_READ_INFO, index, 0, NULL,
-			read_info_cb, L_UINT_TO_PTR(index), NULL) != 0)
-		return;
-
-	l_queue_remove(controllers, L_UINT_TO_PTR(index));
+	mgmt_send(mgmt_mesh, MGMT_OP_READ_INFO, index, 0, NULL,
+				read_info_cb, L_UINT_TO_PTR(index), NULL);
 }
 
 static void index_removed(uint16_t index, uint16_t length, const void *param,
 							void *user_data)
 {
 	l_warn("Hci dev %4.4x removed", index);
-	l_queue_remove(controllers, L_UINT_TO_PTR(index));
 }
 
 static void read_index_list_cb(uint8_t status, uint16_t length,
@@ -157,9 +142,6 @@ static void read_index_list_cb(uint8_t status, uint16_t length,
 
Quoted 8 lines

mesh/mesh-mgmt.c static void read_index_list_cb(uint8_t status, uint16_t length, · line 147

Quoted 8 lines
mesh/mesh-mgmt.c +0 -3
 static bool mesh_mgmt_init(void)
 {
-	if (!controllers)
-		controllers = l_queue_new();
-
 	if (!read_info_regs)
 		read_info_regs = l_queue_new();
 

Best regards,

Inga

Applied
#3 lore raw
In reply to Inga Stotland

Applied

Quoted 60 lines · Inga Stotland

This removes unnecessary housekeeping for hci controllers

---
 mesh/mesh-mgmt.c | 22 ++--------------------
 1 file changed, 2 insertions(+), 20 deletions(-)
mesh/mesh-mgmt.c +2 -20
index 27272d4d2..2cf2ebac2 100644
@@ -42,14 +42,8 @@ struct read_info_req {
 };
 
 static struct mgmt *mgmt_mesh;
-static struct l_queue *controllers;
 static struct l_queue *read_info_regs;
 
-static bool simple_match(const void *a, const void *b)
-{
-	return a == b;
-}
-
 static void process_read_info_req(void *data, void *user_data)
 {
 	struct read_info_reg *reg = data;
@@ -101,23 +95,14 @@ static void read_info_cb(uint8_t status, uint16_t length,
 static void index_added(uint16_t index, uint16_t length, const void *param,
 							void *user_data)
 {
-	if (l_queue_find(controllers, simple_match, L_UINT_TO_PTR(index)))
-		return;
-
-	l_queue_push_tail(controllers, L_UINT_TO_PTR(index));
-
-	if (mgmt_send(mgmt_mesh, MGMT_OP_READ_INFO, index, 0, NULL,
-			read_info_cb, L_UINT_TO_PTR(index), NULL) != 0)
-		return;
-
-	l_queue_remove(controllers, L_UINT_TO_PTR(index));
+	mgmt_send(mgmt_mesh, MGMT_OP_READ_INFO, index, 0, NULL,
+				read_info_cb, L_UINT_TO_PTR(index), NULL);
 }
 
 static void index_removed(uint16_t index, uint16_t length, const void *param,
 							void *user_data)
 {
 	l_warn("Hci dev %4.4x removed", index);
-	l_queue_remove(controllers, L_UINT_TO_PTR(index));
 }
 
 static void read_index_list_cb(uint8_t status, uint16_t length,
@@ -157,9 +142,6 @@ static void read_index_list_cb(uint8_t status, uint16_t length,
 
 static bool mesh_mgmt_init(void)
 {
-	if (!controllers)
-		controllers = l_queue_new();
-
 	if (!read_info_regs)
 		read_info_regs = l_queue_new();