Diff between 262e9eef41475b721bd71365b87d521924daeb5e and bfaa219eb6a5d1de4a23aecf3cff51fff070b854

Changed Files

File Additions Deletions Status
src/adapter.c +25 -4 modified
src/mgmt.c +0 -26 modified
src/mgmt.h +0 -3 modified

Full Patch

diff --git a/src/adapter.c b/src/adapter.c
index 0231a08..4aa2243 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -4214,6 +4214,29 @@ void adapter_foreach(adapter_cb func, gpointer user_data)
 	g_slist_foreach(adapters, (GFunc) func, user_data);
 }
 
+static int set_did(struct btd_adapter *adapter, uint16_t vendor,
+			uint16_t product, uint16_t version, uint16_t source)
+{
+	struct mgmt_cp_set_device_id cp;
+
+	DBG("hci%u source %x vendor %x product %x version %x",
+			adapter->dev_id, source, vendor, product, version);
+
+	memset(&cp, 0, sizeof(cp));
+
+	cp.source = htobs(source);
+	cp.vendor = htobs(vendor);
+	cp.product = htobs(product);
+	cp.version = htobs(version);
+
+	if (mgmt_send(adapter->mgmt, MGMT_OP_SET_DEVICE_ID,
+				adapter->dev_id, sizeof(cp), &cp,
+				NULL, NULL, NULL) > 0)
+		return 0;
+
+	return -EIO;
+}
+
 static int adapter_register(struct btd_adapter *adapter)
 {
 	struct agent *agent;
@@ -4263,10 +4286,8 @@ static int adapter_register(struct btd_adapter *adapter)
 		default_adapter_id = adapter->dev_id;
 
 	if (main_opts.did_source)
-		mgmt_set_did(adapter->dev_id, main_opts.did_vendor,
-						main_opts.did_product,
-						main_opts.did_version,
-						main_opts.did_source);
+		set_did(adapter, main_opts.did_vendor, main_opts.did_product,
+				main_opts.did_version, main_opts.did_source);
 
 	DBG("Adapter %s registered", adapter->path);
 
diff --git a/src/mgmt.c b/src/mgmt.c
index 685d376..5d2197a 100644
--- a/src/mgmt.c
+++ b/src/mgmt.c
@@ -1006,32 +1006,6 @@ void mgmt_cleanup(void)
 	}
 }
 
-int mgmt_set_did(int index, uint16_t vendor, uint16_t product,
-					uint16_t version, uint16_t source)
-{
-	char buf[MGMT_HDR_SIZE + sizeof(struct mgmt_cp_set_device_id)];
-	struct mgmt_hdr *hdr = (void *) buf;
-	struct mgmt_cp_set_device_id *cp = (void *) &buf[sizeof(*hdr)];
-
-	DBG("index %d source %x vendor %x product %x version %x",
-				index, source, vendor, product, version);
-
-	memset(buf, 0, sizeof(buf));
-	hdr->opcode = htobs(MGMT_OP_SET_DEVICE_ID);
-	hdr->len = htobs(sizeof(*cp));
-	hdr->index = htobs(index);
-
-	cp->source = htobs(source);
-	cp->vendor = htobs(vendor);
-	cp->product = htobs(product);
-	cp->version = htobs(version);
-
-	if (write(mgmt_sock, buf, sizeof(buf)) < 0)
-		return -errno;
-
-	return 0;
-}
-
 int mgmt_load_link_keys(int index, GSList *keys, gboolean debug_keys)
 {
 	char *buf;
diff --git a/src/mgmt.h b/src/mgmt.h
index 24f7e1d..5c0755c 100644
--- a/src/mgmt.h
+++ b/src/mgmt.h
@@ -25,9 +25,6 @@
 int mgmt_setup(void);
 void mgmt_cleanup(void);
 
-int mgmt_set_did(int index, uint16_t vendor, uint16_t product,
-					uint16_t version, uint16_t source);
-
 int mgmt_load_link_keys(int index, GSList *keys, gboolean debug_keys);
 int mgmt_load_ltks(int index, GSList *keys);