aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/net/bluetooth/hci_core.h3
-rw-r--r--net/bluetooth/hci_core.c36
-rw-r--r--net/bluetooth/mgmt.c5
3 files changed, 41 insertions, 3 deletions
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index ed842c7e5cf1..c0d2506e2019 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -852,7 +852,8 @@ int hci_white_list_del(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type);
852 852
853struct hci_conn_params *hci_conn_params_lookup(struct hci_dev *hdev, 853struct hci_conn_params *hci_conn_params_lookup(struct hci_dev *hdev,
854 bdaddr_t *addr, u8 addr_type); 854 bdaddr_t *addr, u8 addr_type);
855int hci_conn_params_add(struct hci_dev *hdev, bdaddr_t *addr, u8 addr_type, 855int hci_conn_params_add(struct hci_dev *hdev, bdaddr_t *addr, u8 addr_type);
856int hci_conn_params_set(struct hci_dev *hdev, bdaddr_t *addr, u8 addr_type,
856 u8 auto_connect, u16 conn_min_interval, 857 u8 auto_connect, u16 conn_min_interval,
857 u16 conn_max_interval); 858 u16 conn_max_interval);
858void hci_conn_params_del(struct hci_dev *hdev, bdaddr_t *addr, u8 addr_type); 859void hci_conn_params_del(struct hci_dev *hdev, bdaddr_t *addr, u8 addr_type);
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 6c28687c9286..adea7de95633 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -3472,7 +3472,41 @@ void hci_pend_le_conns_clear(struct hci_dev *hdev)
3472} 3472}
3473 3473
3474/* This function requires the caller holds hdev->lock */ 3474/* This function requires the caller holds hdev->lock */
3475int hci_conn_params_add(struct hci_dev *hdev, bdaddr_t *addr, u8 addr_type, 3475int hci_conn_params_add(struct hci_dev *hdev, bdaddr_t *addr, u8 addr_type)
3476{
3477 struct hci_conn_params *params;
3478
3479 if (!is_identity_address(addr, addr_type))
3480 return -EINVAL;
3481
3482 params = hci_conn_params_lookup(hdev, addr, addr_type);
3483 if (params)
3484 return 0;
3485
3486 params = kzalloc(sizeof(*params), GFP_KERNEL);
3487 if (!params) {
3488 BT_ERR("Out of memory");
3489 return -ENOMEM;
3490 }
3491
3492 bacpy(&params->addr, addr);
3493 params->addr_type = addr_type;
3494
3495 list_add(&params->list, &hdev->le_conn_params);
3496
3497 params->conn_min_interval = hdev->le_conn_min_interval;
3498 params->conn_max_interval = hdev->le_conn_max_interval;
3499 params->conn_latency = hdev->le_conn_latency;
3500 params->supervision_timeout = hdev->le_supv_timeout;
3501 params->auto_connect = HCI_AUTO_CONN_DISABLED;
3502
3503 BT_DBG("addr %pMR (type %u)", addr, addr_type);
3504
3505 return 0;
3506}
3507
3508/* This function requires the caller holds hdev->lock */
3509int hci_conn_params_set(struct hci_dev *hdev, bdaddr_t *addr, u8 addr_type,
3476 u8 auto_connect, u16 conn_min_interval, 3510 u8 auto_connect, u16 conn_min_interval,
3477 u16 conn_max_interval) 3511 u16 conn_max_interval)
3478{ 3512{
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index d83197f9e727..e30d0ebb5018 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -5014,7 +5014,10 @@ static int add_device(struct sock *sk, struct hci_dev *hdev,
5014 else 5014 else
5015 auto_conn = HCI_AUTO_CONN_DISABLED; 5015 auto_conn = HCI_AUTO_CONN_DISABLED;
5016 5016
5017 if (hci_conn_params_add(hdev, &cp->addr.bdaddr, addr_type, auto_conn, 5017 /* If the connection parameters don't exist for this device,
5018 * they will be created and configured with defaults.
5019 */
5020 if (hci_conn_params_set(hdev, &cp->addr.bdaddr, addr_type, auto_conn,
5018 hdev->le_conn_min_interval, 5021 hdev->le_conn_min_interval,
5019 hdev->le_conn_max_interval) < 0) { 5022 hdev->le_conn_max_interval) < 0) {
5020 err = cmd_complete(sk, hdev->id, MGMT_OP_ADD_DEVICE, 5023 err = cmd_complete(sk, hdev->id, MGMT_OP_ADD_DEVICE,