Diff between 90228fc151bac5f19b2d21c18d51ef90f3b0d1b5 and 391490491ac2508fab4341114fe5093686b4e2cd

Changed Files

File Additions Deletions Status
src/adapter.c +13 -1 modified
src/mgmt.c +0 -25 modified
src/mgmt.h +0 -2 modified

Full Patch

diff --git a/src/adapter.c b/src/adapter.c
index 6fef025..b14f122 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -3982,7 +3982,19 @@ int btd_adapter_disconnect_device(struct btd_adapter *adapter,
 int btd_adapter_remove_bonding(struct btd_adapter *adapter,
 				const bdaddr_t *bdaddr, uint8_t bdaddr_type)
 {
-	return mgmt_unpair_device(adapter->dev_id, bdaddr, bdaddr_type);
+	struct mgmt_cp_unpair_device cp;
+
+	memset(&cp, 0, sizeof(cp));
+	bacpy(&cp.addr.bdaddr, bdaddr);
+	cp.addr.type = bdaddr_type;
+	cp.disconnect = 1;
+
+	if (mgmt_send(adapter->mgmt, MGMT_OP_UNPAIR_DEVICE,
+				adapter->dev_id, sizeof(cp), &cp,
+				NULL, NULL, NULL) > 0)
+		return 0;
+
+	return -EIO;
 }
 
 int btd_adapter_pincode_reply(struct btd_adapter *adapter,
diff --git a/src/mgmt.c b/src/mgmt.c
index 53275dd..e7ea4be 100644
--- a/src/mgmt.c
+++ b/src/mgmt.c
@@ -1064,31 +1064,6 @@ int mgmt_unblock_device(int index, const bdaddr_t *bdaddr, uint8_t bdaddr_type)
 	return 0;
 }
 
-int mgmt_unpair_device(int index, const bdaddr_t *bdaddr, uint8_t bdaddr_type)
-{
-	char buf[MGMT_HDR_SIZE + sizeof(struct mgmt_cp_unpair_device)];
-	struct mgmt_hdr *hdr = (void *) buf;
-	struct mgmt_cp_unpair_device *cp = (void *) &buf[sizeof(*hdr)];
-	char addr[18];
-
-	ba2str(bdaddr, addr);
-	DBG("index %d addr %s", index, addr);
-
-	memset(buf, 0, sizeof(buf));
-	hdr->opcode = htobs(MGMT_OP_UNPAIR_DEVICE);
-	hdr->len = htobs(sizeof(*cp));
-	hdr->index = htobs(index);
-
-	bacpy(&cp->addr.bdaddr, bdaddr);
-	cp->addr.type = bdaddr_type;
-	cp->disconnect = 1;
-
-	if (write(mgmt_sock, buf, sizeof(buf)) < 0)
-		return -errno;
-
-	return 0;
-}
-
 int mgmt_set_did(int index, uint16_t vendor, uint16_t product,
 					uint16_t version, uint16_t source)
 {
diff --git a/src/mgmt.h b/src/mgmt.h
index 502cb82..653946d 100644
--- a/src/mgmt.h
+++ b/src/mgmt.h
@@ -28,8 +28,6 @@ void mgmt_cleanup(void);
 int mgmt_block_device(int index, const bdaddr_t *bdaddr, uint8_t bdaddr_type);
 int mgmt_unblock_device(int index, const bdaddr_t *bdaddr, uint8_t bdaddr_type);
 
-int mgmt_unpair_device(int index, const bdaddr_t *bdaddr, uint8_t bdaddr_type);
-
 int mgmt_set_did(int index, uint16_t vendor, uint16_t product,
 					uint16_t version, uint16_t source);